CursorExpressAPI Design

Express.js Cursor Rules

Cursor rules for Express.js: middleware patterns, error handling, security, and production Node.js API best practices.

.cursorrules
- Use express-async-handler or asyncHandler wrapper for all async route handlers
- Centralize error handling with a global error middleware as the last app.use
- Add helmet for security headers and cors for CORS configuration
- Validate request bodies with zod or joi before processing
- Use express.Router() to organize routes by feature domain
- Never trust req.body without validation; validate types and shapes
- Use morgan for structured request logging in development
- Set rate limiting with express-rate-limit on all endpoints, stricter on auth

How to use with Cursor

Create a `.cursorrules` file in your project root and paste these rules. Cursor reads this automatically on every AI interaction.

#express#nodejs#api#cursor#coding-rules

Related Rules