Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: init ssr-opengraph #41

Merged
merged 6 commits into from
Mar 23, 2023
Merged

Conversation

preschian
Copy link
Member

@preschian preschian commented Mar 22, 2023

related kodadot/nft-gallery#5268

the method is quite similar

  1. if the request is coming from a non-bot https://github.com/kodadot/workers/pull/41/files#diff-1860af2eaf6e2c14cc185436d808d762199ab1e9ec51fd94afe805d52bf8570eR18 it will continue the request
  2. if the request is coming from a crawler (bot) it will fetch data to subsquid and then render static html https://github.com/kodadot/workers/pull/41/files#diff-1860af2eaf6e2c14cc185436d808d762199ab1e9ec51fd94afe805d52bf8570eR54

todo:

  • collection detail
  • rmrk2
  • put rmrk to @kodadot1/static?

step to deploy:

  1. after merging this PR, make sure to deploy the prerender-opengraph worker first
  2. and then deploy ssr-opengraph. to avoid routes conflict https://github.com/kodadot/workers/pull/41/files#diff-50d1a6082b03f808cc776ab435488ebf63e81e82829e73e9fc76d094f2d5199aR4

additional notes:

  • seems like prerender on netlify not working anymore. so, it will works on kodadot.xyz only

@preschian preschian marked this pull request as ready for review March 22, 2023 16:27
@preschian
Copy link
Member Author

cc @yangwao @vikiival @roiLeo

Copy link
Member

@vikiival vikiival left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use uniquery and minipfs

@vikiival
Copy link
Member

https://github.com/poppyseedDev/polkadot-fandom-page/blob/main/src/helper/index.ts

@vikiival
Copy link
Member

@preschian preschian requested a review from vikiival March 23, 2023 04:30
Copy link
Member

@vikiival vikiival left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really good job, small things

// TODO: put 'rmrk' into Prefix type
export type Chain = 'rmrk' & Prefix;

export const endpoints: Record<Chain, string> = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be imported also from static

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest keeping it as it is. once we add rmrk in static/types, we can import all endpoints from static https://github.com/kodadot/packages/blob/main/static/src/types.ts#L1

};

export const getNftById = async (chain: Chain, id: string) => {
const client = getClient();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to use fetch on client you need pass prefix here 😇

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I already added TODO here https://github.com/kodadot/workers/pull/41/files#diff-a17dc2c4fda697859be2b120d60f29831b5af50e3800aa7930fa3dcc861b325dR22-R23

for now not using client.fetch(query) is because there is no rmrk in the Prefix

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rmrk prefix was replaced to ksm

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oohh, ok will update that 🙏🏻

@socket-security
Copy link

Socket Security Pull Request Report

Dependency issues detected: If you merge this pull request, you will not be alerted to the instances of these issues again.

📜 Install scripts

Install scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.

Packages should not be running non-essential scripts during install and there are often solutions to problems people solve with install scripts that can be run at publish time instead.

Package Script field Source
esbuild@0.16.3 (added) postinstall ssr-opengraph/package-lock.json via wrangler@2.13.0
Pull request report summary
Issue Status
Install scripts ⚠️ 1 issue
Native code ✅ 0 issues
Bin script shell injection ✅ 0 issues
Unresolved require ✅ 0 issues
Invalid package.json ✅ 0 issues
HTTP dependency ✅ 0 issues
Git dependency ✅ 0 issues
Potential typo squat ✅ 0 issues
Known Malware ✅ 0 issues
Telemetry ✅ 0 issues
Protestware/Troll package ✅ 0 issues
Bot Commands

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of package-name@version specifiers. e.g. @SocketSecurity ignore foo@1.0.0 bar@* or ignore all packages with @SocketSecurity ignore-all

  • @SocketSecurity ignore esbuild@0.16.3

Powered by socket.dev

@yangwao
Copy link
Member

yangwao commented Mar 23, 2023

Somewhre on gaming nft marketplaces I've seen they've been pushing different numbers on card from collections, can create on that issue once I spot it again, that would be amazing to have it, otherwise looking forward to deploying this to beta & production

@preschian
Copy link
Member Author

@vikiival updated 🙏🏻🙏🏻🙏🏻

@vikiival vikiival merged commit 3f9ed12 into kodadot:main Mar 23, 2023
@preschian preschian deleted the feat/ssr-opengraph branch March 24, 2023 02:18
@preschian
Copy link
Member Author

step to deploy:

  1. after merging this PR, make sure to deploy the prerender-opengraph worker first
  2. and then deploy ssr-opengraph. to avoid routes conflict #41 (files)

can we deploy it also to production? cc @yangwao @vikiival

@vikiival
Copy link
Member

vikiival commented Mar 24, 2023

cc @preschian

➜  prerender-opengraph git:(main) ✗ npx wrangler publish
 ⛅️ wrangler 2.1.13 (update available 2.13.0)
-------------------------------------------------------
Total Upload: 2.34 KiB / gzip: 1.02 KiB
Uploaded prerender-opengraph (3.64 sec)
Published prerender-opengraph (15.99 sec)
  kodadot.xyz/rmrk/detail/*
  kodadot.xyz/bsx/detail/*
  kodadot.xyz/snek/detail/*
  kodadot.xyz/glmr/gallery/*
  kodadot.xyz/glmr/detail/*
➜  prerender-opengraph git:(main) ✗ cd ../ssr-opengraph
➜  ssr-opengraph git:(main) ✗ npx wrangler publish
 ⛅️ wrangler 2.13.0
--------------------

✘ [ERROR] Missing entry-point: The entry-point should be specified via the command line (e.g. `wrangler publish path/to/script`) or the `main` config field.


If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose

@preschian
Copy link
Member Author

Missing entry-point: The entry-point should be specified via the command line

eh, hhmm

let's try to deploy it through github actions?

@preschian
Copy link
Member Author

oohh, you need to run npm run deploy or wrangler publish src/index.tsx

@vikiival
Copy link
Member

fixed in 6ee53ca

@vikiival
Copy link
Member

➜  ssr-opengraph git:(main) ✗ npx wrangler publish
 ⛅️ wrangler 2.13.0
--------------------
Total Upload: 218.96 KiB / gzip: 42.82 KiB
Uploaded ssr-opengraph (2.98 sec)
Published ssr-opengraph (17.02 sec)
  kodadot.xyz/rmrk/gallery/*
  kodadot.xyz/rmrk/collection/*
  kodadot.xyz/bsx/gallery/*
  kodadot.xyz/bsx/collection/*
  kodadot.xyz/snek/gallery/*
  kodadot.xyz/snek/collection/*
Current Deployment ID: 4e190bd2-13ca-40ce-9094-0f3f7077f2c4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants