-
-
Notifications
You must be signed in to change notification settings - Fork 804
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: serve AsyncAPI JSON Schema definitions #680
Conversation
✅ Deploy Preview for asyncapi-website ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-680--asyncapi-website.netlify.app/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just one tiny suggestion @smoya 🐼
Interesting approach 🤔
|
Co-authored-by: Alejandra Quetzalli <alejandra.quetzalli@postman.com>
Yes, that's right.
Yes I know, but right now it is a public beta which has been passed through the private beta stage.
I still believe Netlify availability is pretty reliable and superior to what we can support ourselves with the people who are involved. Including using beta features such as Edge Functions.
You made a good point here. The authentication token is going to be needed to have those 5k req/hour. However, there is something to consider here and it's the fact Netlify should cache each request for "some time":
If we run the following: curl -I -H "Authorization: $MY_TOKEN" https://raw.githubusercontent.com/asyncapi/spec/v2.4.0/examples/websocket-gemini.yml
HTTP/2 200
cache-control: max-age=300
content-security-policy: default-src 'none'; style-src 'unsafe-inline'; sandbox
content-type: text/plain; charset=utf-8
etag: "755fbfddca88cfd66072e57e21f9a33f3fabbe6ae24ce7c0249d83ab8d3d7788"
strict-transport-security: max-age=31536000
x-content-type-options: nosniff
x-frame-options: deny
x-xss-protection: 1; mode=block
x-github-request-id: F288:9F7F:6918C6:6DD3EC:626FDD1E
accept-ranges: bytes
date: Mon, 02 May 2022 13:31:10 GMT
via: 1.1 varnish
x-served-by: cache-mad22067-MAD
x-cache: MISS
x-cache-hits: 0
x-timer: S1651498270.022946,VS0,VE205
vary: Authorization,Accept-Encoding,Origin
access-control-allow-origin: *
x-fastly-request-id: 5327fa939e275e7ddbd14bc99a8fb310421282a5
expires: Mon, 02 May 2022 13:36:10 GMT
source-age: 0
content-length: 9100 We can see the content should be cached for 5 mins (300 seconds):
That would give us a really big number of requests allowed (cached or non cached), all pending to be tested and confirmed. In the really worst scenario, we could switch to what @jonaslagoni suggested in #502 so we serve the files right from Netlify instead of GH, but keeping the Edge Function in there for the Headers change + metrics collection. |
request.headers.delete("origin"); | ||
|
||
// Setting GH Token to increase GH rate limit to 5,000 req/h. | ||
request.headers.set("Authorization", "token " + Deno.env.get("GITHUB_TOKEN")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would need to use a GH token here. Preferably, a token from a user is not being used in any automation yet. cc @derberg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a token from a user
what do you mean? why user token. We can use AsyncAPI token
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, i meant using a new user because requests to GH API are counted across the whole account, no matters wich toke you use. Important for the rate limit.
I added the following:
Some env vars will be needed to be set at Netlify level:
As a side note, the URL to NewRelic insights collector should be changed in case AsyncAPI New Relic Account is not hosted in EU to Here a screenshot of how our dashboard could look in New Relic: |
I think we need some page under https://deploy-preview-680--asyncapi-website.netlify.app/schema-store that explains the concept and lists all available schemas also to go further lets make sure others have nothing against new relic and hosting from GitHub Raw atm -> #780 |
Who could help on that part?
It seems people agreed on this finally! |
@derberg redirects have been added to the schemas README from asyncapi/spec-json-schemas#229, which will be located at https://github.com/asyncapi/spec-json-schemas/tree/master/schemas |
This is ready for review. Tested locally through |
Co-authored-by: Lukasz Gornicki <lpgornicki@gmail.com>
@derberg I checked the retention New Relic provides to the free and standard tier: As I was sending custom events, I decided to change it to send metrics instead, so we can take profit of the 13 months of retention. That means the code changed a bit so you will need to review it again (sorry for that). Also, the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really cool 🔝
Everything looks good to me. Do you want to wait for @derberg's review?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
Once it is merged we need to open PR to schemastore
I'm happy to do it |
/rtm |
/rtm |
/help |
Hello, @smoya! 👋🏼 I'm Genie from the magic lamp. Looks like somebody needs a hand! 🆘 At the moment the following comments are supported in pull requests:
|
@alequetzalli I need your review again after all suggestions were applied. 🙏 thank you! |
Changes are pushed to my fork but waiting for this PR to be merged (approval by @alequetzalli is required) to be turned into a PR. https://github.com/SchemaStore/schemastore/compare/master...smoya:feat/asyncapiSchemaStore?expand=1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤪🥳🫡
/rtm |
Description
This PR let's our website to serve all AsyncAPI JSON Schema definition files from it.
All AsyncAPI JSON Schema definition files are being served within the
/definitions/<file>
path. The content is literally being served from GH, in particular from https://github.com/asyncapi/spec-json-schemas/tree/master/schemas.This is possible thanks to the following:
/definitions/<file>
path, serving the content from GH without having an HTTP redirect.Content-Type
header of the rewrite response to becomeapplication/schema+json
. This lets tooling, such as Hyperjump, to fetch the schemas directly from their URL.In order to see what the final result is, just grab the Netlify build preview link and run:
Btw, this Netlify edge function could be used also for pushing metrics on the hit count, solving #780.
Related issue(s)
Iteration over #502
cc @jonaslagoni @derberg @fmvilas @magicmatatjahu