2.7 KiB
Repository Guidelines
Project Structure & Module Organization
Core application code lives in src/. Domain modules are split by business area: auth/, users/, tasks/, patients/, and organization/. Keep controllers, services, and DTOs inside their module directories (for example, src/tasks/dto/).
Shared infrastructure is in src/common/ (global response/exception handling, constants) plus src/prisma.module.ts and src/prisma.service.ts. Database schema and migrations are under prisma/, and generated Prisma artifacts are in src/generated/prisma/. API behavior notes are documented in docs/*.md.
Build, Test, and Development Commands
Use pnpm for all local workflows:
pnpm install: install dependencies.pnpm start:dev: run NestJS in watch mode.pnpm build: compile TypeScript todist/.pnpm start:prod: run compiled output fromdist/main.pnpm format: apply Prettier tosrc/**/*.ts(andtest/**/*.tswhen present).pnpm prisma generate: regenerate Prisma client after schema changes.pnpm prisma migrate dev: create/apply local migrations.
Coding Style & Naming Conventions
This repo uses TypeScript + NestJS with ES module imports (use .js suffix in local imports). Formatting is Prettier-driven (singleQuote: true, trailingComma: all); keep 2-space indentation and avoid manual style drift.
Use PascalCase for classes (TaskService), camelCase for methods/variables, and kebab-case for filenames (publish-task.dto.ts). Place DTOs under dto/ and keep validation decorators/messages close to fields.
Testing Guidelines
There are currently no committed test scripts or spec files. For new features, add automated tests using @nestjs/testing and supertest (already in dev dependencies), with names like *.spec.ts.
Minimum expectation for new endpoints: one success path and one authorization/validation failure path. Include test run instructions in the PR when introducing test tooling.
Commit & Pull Request Guidelines
Recent history uses short, single-line subjects (for example: 配置数据库生成用户模块, 测试, init). Keep commits focused and descriptive, one logical change per commit.
For PRs, include:
- What changed and why.
- Related issue/task link.
- API or schema impact (
prisma/schema.prisma, migrations, env vars). - Verification steps (for example,
pnpm build, key endpoint checks in/api/docs).
Security & Configuration Tips
Start from .env.example; never commit real secrets. Rotate AUTH_TOKEN_SECRET and bootstrap keys per environment, and treat DATABASE_URL as sensitive.
使用nest cli,不要直接改配置文件,最后发给我安装命令,让我执行,中文注释和文档