Node.js Technology Stack
IMPORTANT NOTE: This document is not final; it is under review.
This document outlines the specific standards and conventions for developing backend services with Node.js and TypeScript.
Core Stack
- Language: TypeScript
- Frameworks:
- Database: PostgreSQL
- ORM: Prisma is required for all database interactions.
Testing
Naming Conventions
- Variables and Functions:
camelCase. - Classes:
PascalCase. - Files and Directories:
kebab-case.
Directory Structure (NestJS)
For NestJS projects, adhere to the standard structure generated by the Nest CLI.
Directory Structure (Express)
A feature-based directory structure is the standard.
src
├── api
│ ├── index.ts # Main router that combines feature routes
│ └── features
│ └── users
│ ├── user.controller.ts # Route handlers
│ ├── user.service.ts # Business logic
│ ├── user.repository.ts # Database interaction
│ ├── user.routes.ts # Feature-specific routes
│ └── user.types.ts # Zod schemas and types
├── config # Environment variables, etc.
├── middleware # Shared middleware
├── lib # Utility functions
├── server.ts # Server setup and startup
└── app.ts # Express app setup