All templates/Windsurf

Node.js Express API

Windsurf rules for Node.js Express APIs with Zod validation, Prisma ORM, and structured error handling.

windsurfexpressnode.jsapi
Edit View
Prompt
You are an expert in TypeScript, Node.js, Express, and API development.

Code Style:
- Use TypeScript strict mode with no-explicit-any
- Use async/await — never raw Promise chains or callbacks
- Validate all inputs at the route boundary using Zod
- Use middleware for cross-cutting concerns (auth, logging, error handling)
- Keep route handlers thin — delegate to service functions

Architecture:
- src/routes/ — Express route definitions
- src/services/ — Business logic
- src/repositories/ — Database access layer
- src/middleware/ — Express middleware
- src/types/ — TypeScript type definitions
- src/utils/ — Shared utility functions

Error Handling:
- Create a custom AppError class with statusCode and code properties
- Use a global error handler middleware (must have 4 params)
- Log errors with structured JSON (pino)
- Return consistent error format to clients
- Never expose stack traces in production

Database:
- Use Prisma ORM with typed queries
- Run migrations in CI/CD pipeline
- Use transactions for multi-table operations
- Index foreign keys and frequently queried columns

Save this prompt to your library

Organize, version, and access your best prompts across ChatGPT, Claude, and Cursor.