This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
---
|
||||
description: Architecture
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
Before generating code:
|
||||
|
||||
- Search for existing implementations.
|
||||
- Reuse existing services.
|
||||
- Reuse existing DTOs.
|
||||
- Follow naming conventions.
|
||||
- Match the project's coding style.
|
||||
- Never duplicate logic.
|
||||
- Prefer extending existing modules.
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
description: MikroORM
|
||||
globs:
|
||||
- "src/**/*.entity.ts"
|
||||
- "src/**/*.service.ts"
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
Use MikroORM best practices.
|
||||
|
||||
- Never write raw SQL unless necessary.
|
||||
- Prefer EntityRepository.
|
||||
- Use populate instead of manual joins.
|
||||
- Use wrap(entity).assign() for updates.
|
||||
- Use transactions when updating multiple entities.
|
||||
- Use Collection for OneToMany relations.
|
||||
- Use references when appropriate.
|
||||
- Avoid N+1 queries.
|
||||
- Always type repository injections.
|
||||
- Use indexes where needed.---
|
||||
alwaysApply: true
|
||||
---
|
||||
@@ -0,0 +1,25 @@
|
||||
---
|
||||
description: NestJS Backend Rules
|
||||
globs:
|
||||
- "src/**/*.ts"
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
You are an expert NestJS developer.
|
||||
|
||||
Rules:
|
||||
|
||||
- Use dependency injection.
|
||||
- Use constructor injection instead of manually creating services.
|
||||
- Follow the existing folder structure.
|
||||
- Keep controllers thin.
|
||||
- Business logic belongs in services.
|
||||
- DTOs must use class-validator.
|
||||
- Always create DTOs for request bodies.
|
||||
- Return typed responses.
|
||||
- Use async/await.
|
||||
- Never use any.
|
||||
- Prefer readonly where possible.
|
||||
- Use ConfigService instead of process.env directly.
|
||||
- Throw NestJS HttpExceptions.
|
||||
- Write clean, maintainable TypeScript.
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
description: Performance
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
Optimize for performance.
|
||||
|
||||
- Minimize database queries.
|
||||
- Batch database operations.
|
||||
- Avoid N+1.
|
||||
- Paginate large datasets.
|
||||
- Select only required columns.---
|
||||
alwaysApply: true
|
||||
---
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
description: PostgreSQL
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
Database rules:
|
||||
|
||||
- Prefer UUID primary keys.
|
||||
- Index foreign keys.
|
||||
- Avoid SELECT *.
|
||||
- Design queries to use indexes.
|
||||
- Use migrations instead of synchronize.
|
||||
- Never remove data unless explicitly requested.---
|
||||
alwaysApply: true
|
||||
---
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
description: TypeScript
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
Code quality:
|
||||
|
||||
- Never use any.
|
||||
- Prefer unknown over any.
|
||||
- Use interfaces for DTOs.
|
||||
- Use enums only when appropriate.
|
||||
- Use strict typing.
|
||||
- Add return types to exported functions.
|
||||
- Keep functions under 40 lines when possible.
|
||||
Reference in New Issue
Block a user