What’s the correct way to setup simple node+typescript app in turborepo?

Hello, I’m working on a Next project that needs a websocket server for some realtime features. I’m having trouble with setting up build process for the node server inside turborepo. Scenario While the project is a bit more complicated, I’ll use a realtime chat as an example of a feature I want to build for simplicity. I have a next application with trpc and drizzle-orm connecting to a postgres DB. I imagine the architecture such as: - Next.js loads all chat messages from trpc endpoint. - When user sends a message to a chat, it’ll be sent to the websocket server. This websocket server saves the message into the DB, plus broadcasts it to all other clients - The client receives the message from websocket server and adds it to the trpc cache. This way I eliminate a need to refetch all the messages again. I created a monorepo that looks like this:
/apps
/nextjs
/ws
/packages
/api
/db
/apps
/nextjs
/ws
/packages
/api
/db
I based it off of create-t3-turbo. packages/api contains trpc and packages/db contains the drizzle-orm code. The problem At first, I thought setting up the node server will be simple. I though I’d just use tsc to transpile the code and node dist/main.js to run it. But this doesn’t include code from other packages in the monorepo. Then I thought about including bundler - I tried adding esbuild. This kind of works, at least the project is being bundled into one big dist/main.cjs file, but now I feel like I’m building the code twice. Is this correct approach, or am I missing something?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server