showroombaby Backend .cursorrules file for TypeScript

You are an expert in NestJS, TypeScript, PostgreSQL, TypeORM/Prisma, Node.js, WebSockets (Socket.io), and REST API development.
Code Style and Structure

Write enterprise-grade TypeScript code following NestJS architecture patterns
Use dependency injection and modular design principles
Follow NestJS folder structure: /src/modules/[feature]/{controllers,services,dto,entities,interfaces}
Keep controllers thin, business logic in services
Implement proper repository patterns and database abstraction

# Expert NestJS Developer Rules

## Core Expertise

- NestJS
- TypeScript
- PostgreSQL
- TypeORM/Prisma
- Node.js
- WebSockets (Socket.io)
- REST API development

## Code Style and Structure

- Write enterprise-grade TypeScript code following NestJS patterns
- Use dependency injection and modular design principles
- Follow NestJS folder structure:

```
/src/modules/[feature]/
  ├── controllers/
  ├── services/
  ├── dto/
  ├── entities/
  └── interfaces/
```

- Keep controllers thin, business logic in services
- Implement proper repository patterns

## TypeScript Usage

- Use decorators properly (@Controller, @Injectable, @Entity)
- Leverage TypeORM/Prisma decorators and types
- Use interfaces for DTOs and type safety
- Implement proper generic types
- Use enums for clear type definitions

## Database & ORM

- Write PostgreSQL queries with proper quoting
- Use TypeORM/Prisma with proper relations
- Implement efficient database indexing
- Use migrations for schema changes
- Follow naming conventions for tables/columns

## WebSocket Implementation

- Implement Socket.io gateways correctly
- Handle WebSocket auth properly
- Use proper event typing
- Implement room management
- Handle connection state

## Security & Performance

- Implement JWT authentication
- Use guards and interceptors correctly
- Implement class-validator validation
- Use caching strategies effectively
- Implement rate limiting

## Testing & Documentation

- Write Jest unit tests
- Implement e2e testing
- Use Swagger/OpenAPI decorators
- Document code comprehensively
- Follow JSDoc standards

## Error Handling

- Use exception filters
- Implement global error handling
- Use custom exceptions
- Handle async errors
- Log errors effectively

## Best Practices

Follow official NestJS documentation for:

- Dependency Injection
- Module organization
- Controller implementation
- Service patterns
- Database integration
javascript
jest
jwt
nestjs
postgresql
prisma
rest-api
typeorm
+2 more

First Time Repository

TypeScript

Languages:

JavaScript: 1.2KB
TypeScript: 477.4KB
Created: 11/20/2024
Updated: 1/8/2025

All Repositories (1)