-
Notifications
You must be signed in to change notification settings - Fork 407
feat(fastify)!: Support Fastify v5 #4270
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
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
e8c2a4a
update fastify deps
LekoArts f02e87d
update readme with new requirements
LekoArts 5a29f3f
update plugin
LekoArts d591449
update playground deps
LekoArts c2add47
update playground
LekoArts 9cba788
update playground deps
LekoArts 0c321f5
add changeset
LekoArts b9b5d00
Merge branch 'main' into lekoarts/eco-204-support-fastify-v5
LekoArts 02d9c45
use node20 in linting step
LekoArts e6d27b6
fix ci?
LekoArts 578d7b9
update attw
LekoArts 47b3fe1
attw
LekoArts 28763a6
revert
LekoArts d928938
ignore rule in attw
LekoArts 61a1cd5
typo fix
LekoArts 6d97de1
Merge branch 'main' into lekoarts/eco-204-support-fastify-v5
LekoArts b185f12
downgrade attw, change ci
LekoArts e72dc93
engine strict
LekoArts a533add
Merge branch 'main' into lekoarts/eco-204-support-fastify-v5
LekoArts d574872
Merge branch 'main' into lekoarts/eco-204-support-fastify-v5
LekoArts d2c348c
remove deps from root pkg.json
LekoArts bf3208c
Merge branch 'main' into lekoarts/eco-204-support-fastify-v5
LekoArts File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| "@clerk/fastify": major | ||
| --- | ||
|
|
||
| Recently Fastify released its v5 and along with it came some breaking changes. Read their [migration guide](https://fastify.dev/docs/latest/Guides/Migration-Guide-V5/) to learn more. | ||
|
|
||
| In order to support Fastify v5 a new major version of `@clerk/fastify` is required as Fastify's Node.js requirement is now `>=20`. Previously `@clerk/fastify` allowed `>=18.17.0`. | ||
|
|
||
| `@clerk/fastify@2.0.0` only supports Fastify v5 or later, if you want/need to continue using Fastify v4, please stick with your current version. The `@clerk/fastify@2.0.0` upgrade itself doesn't have any required code changes as only internal dependencies and requirements were updated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,4 @@ | ||
| CLERK_API_KEY= | ||
| CLERK_PUBLISHABLE_KEY= | ||
| CLERK_SECRET_KEY= | ||
| PUBLIC_CLERK_SIGN_IN_URL=/sign-in | ||
| FRONTEND_API_URL= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,26 @@ | ||
| ## Setup development | ||
| # playground-fastify | ||
|
|
||
| Execute in root folder: | ||
| Use this example app to test `@clerk/fastify`. | ||
|
|
||
| ```bash | ||
| npm i | ||
| npm run build && npm run yalc:all | ||
| ``` | ||
| ## Usage | ||
|
|
||
| Execute in current folder: | ||
| 1. Install dependencies | ||
|
|
||
| ```bash | ||
| touch .env # set PUBLISHABLE_KEY and SECRET_KEY from Clerk Dashboard API keys | ||
| npm i | ||
| rm -rf node_modules/@clerk | ||
| yalc add @clerk/fastify @clerk/backend @clerk/types --pure | ||
| ```shell | ||
| npm install | ||
| ``` | ||
|
|
||
| ## Getting Started | ||
| 1. Use [`@clerk/dev-cli`](https://github.com/clerk/javascript/tree/main/packages/dev-cli) to build all repository packages and install the local version into this playground. | ||
|
|
||
| First, run the development server: | ||
| 1. Start the server: | ||
|
|
||
| ```bash | ||
| ```shell | ||
| npm run start | ||
| ``` | ||
|
|
||
| Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. | ||
|
|
||
| ## Reload changes from packages/\* package | ||
| You can visit these routes: | ||
|
|
||
| Apply change in packages/\* project folder and run `npm run build`. Then restart Fastify server by killing the current and executing `npm start` and the change should be visible. | ||
| - `/` | ||
| - `/sign-in` | ||
| - `/me` (requires sign-in) | ||
| - `/private` (requires sign-in) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| import * as dotenv from 'dotenv'; | ||
| dotenv.config(); | ||
| dotenv.config({ path: ['.env.local', '.env.production', '.env'] }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,15 @@ | ||
| import type { FastifyInstance } from 'fastify'; | ||
|
|
||
| export const publicRoutes = async (fastify: FastifyInstance, _opts: any) => { | ||
| fastify.get('/public', async (_req, _reply) => { | ||
| fastify.get('/', async (_req, _reply) => { | ||
| return { hello: 'world' }; | ||
| }); | ||
|
|
||
| fastify.get('/home', async (_req, reply) => { | ||
| return reply.view('/src/templates/home.ejs', { | ||
| publishableKey: process.env.CLERK_PUBLISHABLE_KEY, | ||
| domain: process.env.CLERK_DOMAIN, | ||
| isSatellite: process.env.CLERK_IS_SATELLITE, | ||
| signInUrl: process.env.CLERK_SIGN_IN_URL, | ||
| fastify.get('/sign-in', async (_req, reply) => { | ||
| return reply.viewAsync('/src/templates/sign-in.ejs', { | ||
| CLERK_PUBLISHABLE_KEY: process.env.CLERK_PUBLISHABLE_KEY, | ||
| PUBLIC_CLERK_SIGN_IN_URL: process.env.PUBLIC_CLERK_SIGN_IN_URL, | ||
| FRONTEND_API_URL: process.env.FRONTEND_API_URL, | ||
| }); | ||
| }); | ||
| }; |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <script | ||
| async | ||
| crossorigin="anonymous" | ||
| data-clerk-publishable-key="<%= CLERK_PUBLISHABLE_KEY %>" | ||
| src="<%= FRONTEND_API_URL %>/npm/@clerk/clerk-js@latest/dist/clerk.browser.js" | ||
| type="text/javascript" | ||
| onLoad="startClerk()" | ||
| ></script> | ||
| </head> | ||
| <body> | ||
| <script> | ||
| window.startClerk = async () => { | ||
| await Clerk.load({ | ||
| signInUrl: "<%= PUBLIC_CLERK_SIGN_IN_URL %>", | ||
| }); | ||
| Clerk.openSignIn(); | ||
| } | ||
| </script> | ||
| </body> | ||
| </html> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
should we retain yalc usage here for the playground?
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.
I removed it because when you use
clerk-dev-cliorseccoit gets in the way. If we want to dogfood the dev CLI we need to remove yalc ;)