Next.js Discord

Discord Forum

Create Shared Utils Functions For Both API Router & Server.js

Unanswered
Dogue Brasileiro posted this in #help-forum
Open in Discord
Dogue BrasileiroOP
I have a server.js where I am initiating a Socket.IO client that gets called by the client side. And I have some API endpoints using app/api that utilizes Prisma for database related queries.

How do I allow my server.js to access Prisma while letting app/api access socket instance?

When I try to import prisma directly under my server.js file it returns {} object. When I try to access shared socket functions from server.js for my app/api routes it crashes everything.

How do I tackle this?

0 Replies