const makeHandler = (authSession: Session | null) =>
RpcServer.toWebHandler(AuthRpcGroup, {
layer: Layer.mergeAll(
AuthRpcLive.pipe(
Layer.provide(
Layer.provideMerge(UserSessionService.layer(authSession), MainLive),
),
),
RpcSerialization.layerJson,
HttpServer.layerContext,
),
memoMap: ServerRuntime.memoMap,
});
export const POST = async (request: NextRequest) => {
const handler = makeHandler(await getServerSession(authOptions));
return await handler.handler(request);
};
const makeHandler = (authSession: Session | null) =>
RpcServer.toWebHandler(AuthRpcGroup, {
layer: Layer.mergeAll(
AuthRpcLive.pipe(
Layer.provide(
Layer.provideMerge(UserSessionService.layer(authSession), MainLive),
),
),
RpcSerialization.layerJson,
HttpServer.layerContext,
),
memoMap: ServerRuntime.memoMap,
});
export const POST = async (request: NextRequest) => {
const handler = makeHandler(await getServerSession(authOptions));
return await handler.handler(request);
};