Backend Infrastructure Setup
Context
Initial setup of the @trust-vote/backend package within the monorepo, focusing on modern Node.js 24 standards and high-performance execution.
Decisions & Technical Choices
- Framework: NestJS with Fastify adapter for superior throughput compared to Express.
- Runtime: Switched from
ts-nodetotsxto handle Pure ESM (ES Modules) compatibility issues with Node 24. - Architecture: Implemented Top-level await in
main.tsfor a cleaner entry point. - TypeScript Configuration:
- Set
moduleResolutiontoBundlerto allow clean imports (without.jsextensions) while maintaining ESM integrity. - Set
targettoES2022to support modern JS features.
- Set
Challenges Overcome
- ERR_MODULE_NOT_FOUND: Resolved by moving to
tsxand adjustingtsconfig.jsonto useBundlerresolution, avoiding the need for forced.jsextensions in TypeScript source files. - Top-level await: Configured
package.jsonwith"type": "module"to allow asynchronous bootstrapping of the NestJS application.
Current Status
- Backend is active and running at
http://localhost:3000. - NestJS successfully initialized with the Fastify engine.