mirror of
https://github.com/kennethnym/aris.git
synced 2026-03-21 17:41:18 +00:00
15 lines
417 B
TypeScript
15 lines
417 B
TypeScript
|
|
import type { FetchCreateContextFnOptions } from "@trpc/server/adapters/fetch"
|
||
|
|
|
||
|
|
import { auth } from "../auth/index.ts"
|
||
|
|
|
||
|
|
export async function createContext(opts: FetchCreateContextFnOptions) {
|
||
|
|
const session = await auth.api.getSession({ headers: opts.req.headers })
|
||
|
|
|
||
|
|
return {
|
||
|
|
user: session?.user ?? null,
|
||
|
|
session: session?.session ?? null,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
export type Context = Awaited<ReturnType<typeof createContext>>
|