0

Beginner here trying out t3 stack app with trpc-openapi. Prisma provider is using mongodb. I can connect to MongoDB but when I make the call http://localhost:3000/api/all from http://localhost:3000/api-docs I get error

{
  "message": "Cannot read properties of undefined (reading 'prisma')",
  "code": "INTERNAL_SERVER_ERROR"
}

Source for the app is at https://github.com/firefoxNX/cosmic_monk.

I don't see any other error in the server console.

oguz ismail
  • 1
  • 16
  • 47
  • 69
Vineet Bhatia
  • 2,469
  • 4
  • 30
  • 28

1 Answers1

0

I was not passing the context which holds the prisma client in multiple places where createOpenApiNextHandler was being used.

import {createTRPCContext} from "../../server/api/trpc";
...
return createOpenApiNextHandler({router: appRouter, createContext: createTRPCContext})(req, res);
Vineet Bhatia
  • 2,469
  • 4
  • 30
  • 28