WINDSURF RULES BACKEND / API Express

Node.js Express API Rules

REST APIs with Express — middleware, validation, error handling, and structure.

Node.js Express REST API TypeScript
Tool
Windsurf
Asset type
Rules
Category
Backend / API
Framework
Express
Recommended path
.devin/rules/nodejs-express.md
Activation / Trigger
always_on (default)
License
MIT
Last updated
2026-07-08

How to use this asset

  1. Click Copy Rule above to copy the full rule text.
  2. Save as Markdown under .devin/rules/*.md (preferred) or .windsurf/rules/*.md, or paste via Cascade → Customizations → Rules.
  3. Windsurf reads workspace rules from .devin/rules/ on each Cascade session.

Compatible tools

Designed for Windsurf. Also works with: Claude Code.

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.