Repository Guidelines
Project Structure & Module Organization
src/— application source. Entry:src/main.ts; root module:src/app.module.ts.- Features live under
src/modules/<feature>/with*.module.ts,*.controller.ts,*.service.ts,dto/*.dto.ts,entities/*.entity.ts. - Shared utilities in
src/common/(filters, guards, interceptors, pipes). test/— unit tests*.spec.ts, end‑to‑end tests*.e2e-spec.ts.- Config:
nest-cli.json,tsconfig*.json. Build output:dist/.
Build, Test, and Development Commands
npm run start:dev— start in watch mode (hot reload).npm run build— compile TypeScript todist/.npm run start:prod— run the compiled app fromdist/.npm run test/test:watch/test:cov/test:e2e— Jest suites.npm run lint/npm run format— ESLint and Prettier. Note: Use your package manager alias (npm|pnpm|yarn).
Coding Style & Naming Conventions
- TypeScript, ESLint + Prettier; 2‑space indent; single quotes; semicolons; trailing commas where practical.
- Classes/Modules/Controllers/Services in PascalCase; variables/functions in camelCase.
- File names in kebab-case with Nest suffixes:
user.controller.ts,user.service.ts,user.module.ts; DTOs*.dto.ts; entities*.entity.ts.
Testing Guidelines
- Prefer unit tests per provider; mock external dependencies.
- Use
@nestjs/testingTestingModuleto compose units. - Place fixtures under
test/or__mocks__/when helpful. - Keep
npm run test:covgreen before opening PRs.
Commit & Pull Request Guidelines
- Conventional Commits:
feat:,fix:,chore:,refactor:,test:,docs:. Example:feat(user): add password reset via token. - One logical change per PR. Include description, steps to verify, and
Closes #123when applicable. - Add screenshots/logs for behavioral changes and update docs and
.env.exampleif config changes.
Security & Configuration Tips
- Never commit secrets; keep them in
.envand updateenv.examplefor new keys. - Prefer
ConfigModuleand validate env withJoi. - Enable CORS and Helmet; validate DTOs with
class-validator/class-transformer.