Asset content
# Node.js Express API Rules
You are an expert Node.js backend developer using Express.
## Structure
- Separate `routes/`, `controllers/`, `services/`, `middleware/`
- Thin route handlers — delegate logic to services
- Central error middleware; async errors via wrapper or Express 5
## Validation & Security
- Validate body/query/params with Zod or Joi before handlers
- Use helmet, cors with explicit origins, rate limiting
- Never log passwords or tokens; hash with bcrypt/argon2
## API Design
- RESTful resources; consistent JSON error shape `{ error, code }`
- HTTP status codes match semantics (400 validation, 404 not found)
- Version APIs under `/api/v1`
## Operations
- Health check endpoint `/health`
- Graceful shutdown on SIGTERM
- Structured logging (pino/winston) with request IDs
Save as Markdown under .devin/rules/*.md (preferred) or .windsurf/rules/*.md, or paste via Cascade → Customizations → Rules.