diff --git a/package.json b/package.json index 26c77aa..c1eed09 100644 --- a/package.json +++ b/package.json @@ -26,8 +26,7 @@ "postgres-array": "^3.0.2" }, "peerDependencies": { - "@prisma/client": "^5.9.1", - "express": "^4.18.2" + "@prisma/client": "^5.9.1" }, "devDependencies": { "@types/express": "^4.17.21", diff --git a/src/index.ts b/src/index.ts index 78573dc..9803447 100644 --- a/src/index.ts +++ b/src/index.ts @@ -59,6 +59,7 @@ export const withPgAdapter = (originalPrisma: PrismaClientType return prisma as PrismaClientType } +// Next.js export const setContext = (callback: (req: Request) => any) => { return (req: Request, _res: Response, next: NextFunction) => { const context = callback(req); @@ -69,6 +70,7 @@ export const setContext = (callback: (req: Request) => any) => { }; }; +// Apollo Server export const BemiApolloServerPlugin = (callback: (requestContext: any) => any) => { return { async requestDidStart(requestContext: any) { @@ -77,3 +79,8 @@ export const BemiApolloServerPlugin = (callback: (requestContext: any) => any) = }, } } + +// Other +export const bemiContext = (context: any) => { + ASYNC_LOCAL_STORAGE.enterWith(context); +}