后端 Nestjs
- 作者仓库星标 14
- 作者仓库 rhm
NestJS Backend Development
When to Use This Skill
Use when developing backend code in a NestJS project with TypeScript.
Recommended Project Structure
src/
├── core/
│ ├── config/ # Configuration (env validation)
│ ├── database/ # Database connections, migrations
│ ├── guards/ # Auth guards
│ ├── interceptors/ # Request/response interceptors
│ ├── filters/ # Exception filters
│ └── decorators/ # Custom decorators
├── modules/
│ └── <domain>/
│ ├── application/ # Use cases / services
│ ├── domain/ # Entities, value objects, interfaces
│ ├── infrastructure/ # Repositories, external services
│ ├── presentation/ # Controllers, DTOs, validators
│ └── <domain>.module.ts
├── shared/
│ ├── utils/
│ ├── types/
│ └── constants/
└── main.ts
Conventions
- One use case per file in
application/ - DTOs with class-validator decorators in
presentation/ - Repository pattern for data access in
infrastructure/ - Module-scoped providers; export only what's needed
Testing
- Stack: Vitest (preferred) or Jest
- Unit test use cases with mocked dependencies
- Test file next to source:
*.spec.ts - All tests in English
- Naming: "should do X when Y"
Commands
pnpm dev # Development with hot reload
pnpm build # Production build
pnpm lint # ESLint
pnpm test # Run tests
pnpm test:cov # Coverage report
Error Handling
- Use NestJS built-in exceptions (BadRequestException, NotFoundException, etc.)
- Custom exceptions extend HttpException
- Global exception filter for unhandled errors
Database
- Use query builder or repository pattern
- Always use transactions for multi-table writes
- Add indexes for frequently queried columns
- Use database MCPs to inspect schema before writing queries
Pre-commit Checklist
- Build passes? (
pnpm build) - Lint passes? (
pnpm lint) - Tests pass? (
pnpm test) - DTOs have proper validation?
- Error cases handled?
- 流狐分类
- 工程开发
- 作者声明 Agent
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 作者 / 版本 / 许可
- @arvoreeducacao · 未声明 license
- 流狐 Token 估算
- 低消耗
- 流狐接入估算
- 即装即用
- 是否需要外部 API Key
- 未发现要求
- 检测到的系统要求
- 未声明
- 底层运行要求
- 未声明
- 检测到的文件与系统行为
-
- 只读
- 检测到的网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
作者没有在当前 SKILL.md 中定义固定输出样例。 Use when developing backend code in a NestJS project with TypeScript.
Recommended Project Structure
One use case per file in application/ DTOs with class-validator decorators in presentation/ Repository pattern for data access in infrastructure/
Stack: Vitest (preferred) or Jest Unit test use cases with mocked dependencies Test file next to source: .spec.ts
Commands
Use NestJS built-in exceptions (BadRequestException, NotFoundException, etc.) Custom exceptions extend HttpException Global exception filter for unhandled errors
# NestJS Backend Development
## When to Use This Skill
Use when developing backend code in a NestJS project with TypeScript.
## Recommended Project Structure
```
src/
├── core/
│ ├── config/ # Configuration (env validation)
│ ├── database/ # Database connections, migrations
│ ├── guards/ # Auth guards
│ ├── interceptors/ # Request/response interceptors
│ ├── filters/ # Exception filters
│ └── decorators/ # Custom decorators
├── modules/
│ └── <domain>/
│ ├── application/ # Use cases / services
│ ├── domain/ # Entities, value objects, interfaces
│ ├── infrastructure/ # Repositories, external services
│ ├── presentation/ # Controllers, DTOs, validators
│ └── <domain>.module.ts
├── shared/
│ ├── utils/
│ ├── types/
│ └── constants/
└── main.ts
```
## Conventions
- One use case per file in `application/`
- DTOs with class-validator decorators in `presentation/`
- Repository pattern for data access in `infrastructure/`
- Module-scoped providers; export only what's needed
## Testing
- Stack: Vitest (preferred) or Jest
- Unit test use cases with mocked dependencies
- Test file next to source: `*.spec.ts`
- All tests in English
- Naming: "should do X when Y"
## Commands
```bash
pnpm dev # Development with hot reload
pnpm build # Production build
pnpm lint # ESLint
pnpm test # Run tests
pnpm test:cov # Coverage report
```
## Error Handling
- Use NestJS built-in exceptions (BadRequestException, NotFoundException, etc.)
- Custom exceptions extend HttpException
- Global exception filter for unhandled errors
## Database
- Use query builder or repository pattern
… 作者原文负责流程事实;流狐只索引当前章节、要点、文件与命令。
章节 -> When to Use This Skill → Recommended Project Structure → Conventions → Testing → Commands → Error Handling
要点 -> Use when developing backend code in a NestJS project with TypeScript. · - Build passes?
文件/命令 -> application/ · presentation/ · infrastructure/ · .spec.ts · pnpm build · pnpm lint · pnpm test
内容 SHA-256 -> 7f5de08730d6
原文结构
适用与边界
原文中的明确线索
application/、presentation/、infrastructure/、.spec.ts、pnpm build、pnpm lint、pnpm test