You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
738 B
30 lines
738 B
import { withIronSessionApiRoute, withIronSessionSsr } from "iron-session/next";
|
|
import {
|
|
GetServerSidePropsContext,
|
|
GetServerSidePropsResult,
|
|
NextApiHandler
|
|
} from "next";
|
|
|
|
import { User } from "@prisma/client";
|
|
|
|
import { sessionOptions } from "./config";
|
|
|
|
export const withIronSession = (handler: NextApiHandler) =>
|
|
withIronSessionApiRoute(handler, sessionOptions);
|
|
|
|
export function withSessionSsr<
|
|
P extends { [key: string]: unknown } = { [key: string]: unknown }
|
|
>(
|
|
handler: (
|
|
context: GetServerSidePropsContext
|
|
) => GetServerSidePropsResult<P> | Promise<GetServerSidePropsResult<P>>
|
|
) {
|
|
return withIronSessionSsr(handler, sessionOptions);
|
|
}
|
|
|
|
declare module "iron-session" {
|
|
interface IronSessionData {
|
|
user?: User;
|
|
}
|
|
}
|