Files
web/server/context.ts

28 lines
575 B
TypeScript

import { auth } from "@/auth"
type CreateContextOptions = {
auth: typeof auth
}
/** Use this helper for:
* - testing, where we dont have to Mock Next.js' req/res
* - trpc's `createSSGHelpers` where we don't have req/res
**/
export function createContextInner(opts: CreateContextOptions) {
return {
auth: opts.auth,
}
}
/**
* This is the actual context you'll use in your router
* @link https://trpc.io/docs/context
**/
export function createContext() {
return createContextInner({
auth,
})
}
export type Context = ReturnType<typeof createContext>