forked from stevermeister/windsurfrules-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode-express.windsurfrules
91 lines (77 loc) · 2.41 KB
/
node-express.windsurfrules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Node.js/Express Project - Project Guidelines
## Project Overview
...Your project short description...
Built with Node.js and Express.js, following REST API best practices and clean architecture principles.
## Development Guidelines
### Architecture
- Follow Clean Architecture principles
- Use layered architecture:
- Controllers (`src/controllers`)
- Services (`src/services`)
- Repositories (`src/repositories`)
- Models (`src/models`)
- Routes (`src/routes`)
- Middleware (`src/middleware`)
- Implement proper error handling middleware
- Use dependency injection pattern
### Coding Standards
- Use TypeScript for all files
- Implement proper type definitions for all functions and variables
- Follow SOLID principles
- Implement proper validation using Joi or Zod
- Use async/await instead of callbacks
- Implement proper logging (Winston/Pino)
- Follow REST API naming conventions
- Implement proper API versioning
### Code Quality Tools
- Pre-commit hooks:
- ESLint with TypeScript support
- Prettier for code formatting
- TypeScript compilation check
- Test execution
- Additional checks:
- Security vulnerabilities scan
- Dependency updates check
- Code complexity analysis
- Dead code detection
### Development Environment
#### Node Requirements
- Node.js version: 20.x
- Package manager: npm/yarn
- TypeScript 5.x
#### Testing Requirements
- Jest for unit testing
- Supertest for API testing
- Test files must be named `*.test.ts` or `*.spec.ts`
- Coverage threshold: 85%
- Integration tests for database operations
#### Dependencies
Core dependencies:
- Express 4.x
- TypeScript 5.x
- Prisma/TypeORM for database
- JWT for authentication
- Winston/Pino for logging
- Express-validator for validation
#### Production Requirements
- Use PM2 for process management
- Implement rate limiting
- Set up proper security headers
- Configure CORS properly
- Use compression middleware
- Implement proper caching strategy
- Set up monitoring (New Relic/DataDog)
### Required Environment Variables
All environment variables should be defined in `.env` file:
- Database connection strings
- JWT secrets
- API keys
- Service endpoints
- Logging configuration
Reference `.env.example` for required variables.
### Database Guidelines
- Use migrations for schema changes
- Implement proper indexing strategy
- Use transactions where necessary
- Implement proper connection pooling
- Follow naming conventions for tables and columns