File size: 506 Bytes
2b62b0c
cfc59e4
83e82db
cfc59e4
 
 
 
 
 
 
 
 
 
 
 
83e82db
cfc59e4
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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>>;