- Introduced backend patterns skill with guidelines on API design, database optimization, and server-side best practices. - Added coding standards skill outlining universal coding principles for TypeScript, NestJS, and Node.js development. - Implemented continuous learning skill to automatically extract reusable patterns from Cursor sessions. - Created NestJS best practices skill detailing architecture patterns, dependency injection, error handling, and security measures. - Included various rules and templates for NestJS best practices to ensure production-ready applications.
59 lines
1.1 KiB
Plaintext
59 lines
1.1 KiB
Plaintext
---
|
|
description: NestJS API response format, feature modules, and Drizzle repository pattern
|
|
globs: "**/*.ts"
|
|
alwaysApply: false
|
|
---
|
|
|
|
# Common Patterns
|
|
|
|
## API Response Format
|
|
|
|
```typescript
|
|
interface ApiResponse<T> {
|
|
success: boolean
|
|
data?: T
|
|
error?: string
|
|
meta?: {
|
|
total: number
|
|
page: number
|
|
limit: number
|
|
}
|
|
}
|
|
```
|
|
|
|
## Feature Module
|
|
|
|
```typescript
|
|
@Module({
|
|
imports: [],
|
|
controllers: [UsersController],
|
|
providers: [UsersService, UsersRepository],
|
|
exports: [UsersService],
|
|
})
|
|
export class UsersModule {}
|
|
```
|
|
|
|
## Repository Pattern (Drizzle)
|
|
|
|
```typescript
|
|
interface Repository<T> {
|
|
findAll(filters?: Filters): Promise<T[]>
|
|
findById(id: string): Promise<T | null>
|
|
create(data: CreateDto): Promise<T>
|
|
update(id: string, data: UpdateDto): Promise<T>
|
|
delete(id: string): Promise<void>
|
|
}
|
|
```
|
|
|
|
## Skeleton Projects
|
|
|
|
When implementing new functionality:
|
|
1. Search for battle-tested NestJS module patterns
|
|
2. Use parallel agents to evaluate options:
|
|
- Security assessment
|
|
- Extensibility analysis
|
|
- Relevance scoring
|
|
- Implementation planning
|
|
3. Clone best match as foundation
|
|
4. Iterate within proven structure
|