context.ts (430B)
1 // import { prisma } from 'server/utils/prisma'; 2 3 import type * as trpcNext from '@trpc/server/adapters/next'; 4 5 // create context based of incoming request 6 // set as optional here so it can also be re-used for `getStaticProps()` 7 export const createContext = async ( 8 opts?: trpcNext.CreateNextContextOptions, 9 ) => { 10 return { 11 req: opts?.req, 12 // prisma, 13 }; 14 }; 15 export type Context = Awaited<ReturnType<typeof createContext>>;