mirror of
https://github.com/cedoor/zuauth.git
synced 2026-01-10 05:07:55 -05:00
15 lines
756 B
TypeScript
15 lines
756 B
TypeScript
import { ironOptions } from "@/config/iron"
|
|
import { withIronSessionApiRoute, withIronSessionSsr } from "iron-session/next"
|
|
import { GetServerSidePropsContext, GetServerSidePropsResult, NextApiHandler } from "next"
|
|
|
|
export function withSessionRoute(handler: NextApiHandler) {
|
|
return withIronSessionApiRoute(handler, ironOptions)
|
|
}
|
|
|
|
// Theses types are compatible with InferGetStaticPropsType https://nextjs.org/docs/basic-features/data-fetching#typescript-use-getstaticprops
|
|
export function withSessionSsr<P extends { [key: string]: unknown } = { [key: string]: unknown }>(
|
|
handler: (context: GetServerSidePropsContext) => GetServerSidePropsResult<P> | Promise<GetServerSidePropsResult<P>>
|
|
) {
|
|
return withIronSessionSsr(handler, ironOptions)
|
|
}
|