Skip to content

Commit

Permalink
Add fixes for fastify types and fix example
Browse files Browse the repository at this point in the history
  • Loading branch information
deepjyoti30-st committed Oct 3, 2024
1 parent 3eaa7e3 commit 73353bf
Show file tree
Hide file tree
Showing 8 changed files with 6,333 additions and 30,709 deletions.
2 changes: 1 addition & 1 deletion examples/fastify/with-emailpassword/backend/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fastify.route({
},
// @ts-ignore
preHandler: verifySession(),
handler: async (req: SessionRequest, _) => {
handler: async (req: SessionRequest, _: any) => {
let session = req.session;
return {
sessionHandle: session!.getHandle(),
Expand Down
652 changes: 6 additions & 646 deletions examples/fastify/with-emailpassword/frontend/package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion examples/fastify/with-emailpassword/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"name": "supertokens-react",
"version": "0.1.0",
"private": true,
"dependencies": {},
"dependencies": {
"react-scripts": "^5.0.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
Expand Down
36,360 changes: 6,311 additions & 30,049 deletions examples/fastify/with-emailpassword/package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions examples/fastify/with-emailpassword/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@
"start:backend": "cd backend && npm run start",
"start:backend-live-demo-app": "cd backend && ./startLiveDemoApp.sh",
"start": "npm-run-all --parallel start:frontend start:backend",
"start-live-demo-app": "npx npm-run-all --parallel start:frontend-live-demo-app start:backend-live-demo-app"
"start-live-demo-app": "npx npm-run-all --parallel start:frontend-live-demo-app start:backend-live-demo-app",
"preinstall": "cd frontend && npm i"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@fastify/cors": "^7.0.0",
"@fastify/formbody": "^6.0.1",
"@fastify/cors": "^10.0.1",
"@fastify/formbody": "^8.0.1",
"axios": "^0.21.0",
"fastify": "^5.0.0",
"helmet": "^5.1.0",
"morgan": "^1.10.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.2.1",
"react-scripts": "5.0.1",
"supertokens-auth-react": "latest",
"supertokens-node": "file:../../../lib/build",
"typescript": "^4.8.2",
"typescript": "^5.6.2",
"web-vitals": "^2.1.4"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions lib/build/framework/fastify/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface FastifyReply {
getHeader(key: any): number | string | string[] | undefined;
type(contentType: string): FastifyReply;
}
export interface FastifyInstance {
addHook(name: string, hook: (req: FastifyRequest, reply: FastifyReply) => void): FastifyInstance;
export interface FastifyInstance<Instance = any, Request = any, Reply = any> {
addHook(name: string, hook: (req: Request, reply: Reply) => void): Instance;
}
export declare type FastifyPluginCallback = (instance: FastifyInstance, opts: any, done: (err?: Error) => void) => void;
export declare type FastifyPluginCallback = (instance: any, opts: any, done: (err?: Error) => void) => void;
2 changes: 1 addition & 1 deletion lib/ts/framework/fastify/framework.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export class FastifyResponse extends BaseResponse {
};
}

function plugin(fastify: FastifyInstance, _: any, done: Function) {
function plugin(fastify: FastifyInstance<any>, _: any, done: Function) {
fastify.addHook("preHandler", async (req: OriginalFastifyRequest, reply: FastifyReply) => {
let supertokens = SuperTokens.getInstanceOrThrowError();
let request = new FastifyRequest(req);
Expand Down
6 changes: 3 additions & 3 deletions lib/ts/framework/fastify/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export interface FastifyReply {
type(contentType: string): FastifyReply;
}

export interface FastifyInstance {
addHook(name: string, hook: (req: FastifyRequest, reply: FastifyReply) => void): FastifyInstance;
export interface FastifyInstance<Instance = any, Request = any, Reply = any> {
addHook(name: string, hook: (req: Request, reply: Reply) => void): Instance;
}

export type FastifyPluginCallback = (instance: FastifyInstance, opts: any, done: (err?: Error) => void) => void;
export type FastifyPluginCallback = (instance: any, opts: any, done: (err?: Error) => void) => void;

0 comments on commit 73353bf

Please sign in to comment.