cpns / packages /api /src /context.ts
pramudya-yb
Rename project from Labas to Pram
2b62b0c
Raw
History Blame Contribute Delete
506 Bytes
import { auth } from "@pram/auth";
import type { Context as HonoContext } from "hono";
import { getClientIp } from "./lib/client-ip";
export type CreateContextOptions = {
context: HonoContext;
};
export async function createContext({ context }: CreateContextOptions) {
const session = await auth.api.getSession({
headers: context.req.raw.headers,
});
return {
auth: null,
session,
ip: getClientIp(context),
};
}
export type Context = Awaited<ReturnType<typeof createContext>>;