mirror of
https://github.com/kennethnym/aris.git
synced 2026-03-20 17:11:17 +00:00
- Add @trpc/server, @hono/trpc-server, zod dependencies - Create tRPC context with BetterAuth session - Create router with publicProcedure and protectedProcedure - Mount tRPC at /trpc/* via Hono adapter Co-authored-by: Ona <no-reply@ona.com>
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>>
|