JamesReviewsMusic
JRM-13Extract env and db out of the entry point
Description
backend/src/index.ts currently does everything: validates env vars, creates the Drizzle instance, exports both, builds the Express app, and starts the server. Every model imports db from it, so the whole backend is one big circular import that only works because of CommonJS load order. It also means there's a second, separate pg Pool in backend/db.ts (used by the test controller and tests) purely because the real one is stuck in the entry point.
- Move env validation to src/config/env.ts
- Move the Drizzle client to src/db/client.ts
- index.ts just assembles the app and starts the server, exports nothing that isn't the app itself
- Delete backend/db.ts and point the test controller + tests at the one client
- No import anywhere should reference @/index except the server bootstrap
Sub-tickets
0No sub-tickets yet.
Links
No links.
Comments
0No comments yet.