mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2026-06-14 22:17:25 +08:00
feat: scaffold monorepo
This commit is contained in:
15
apps/portal/src/server/common/get-server-auth-session.ts
Normal file
15
apps/portal/src/server/common/get-server-auth-session.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
// Wrapper for unstable_getServerSession https://next-auth.js.org/configuration/nextjs
|
||||
|
||||
import type { GetServerSidePropsContext } from 'next';
|
||||
// eslint-disable-next-line camelcase
|
||||
import { unstable_getServerSession } from 'next-auth';
|
||||
|
||||
import { authOptions as nextAuthOptions } from '~/pages/api/auth/[...nextauth]';
|
||||
|
||||
// Next API route example - /pages/api/restricted.ts
|
||||
export const getServerAuthSession = async (ctx: {
|
||||
req: GetServerSidePropsContext['req'];
|
||||
res: GetServerSidePropsContext['res'];
|
||||
}) => {
|
||||
return await unstable_getServerSession(ctx.req, ctx.res, nextAuthOptions);
|
||||
};
|
||||
Reference in New Issue
Block a user