---
description: Node.js backend conventions
globs: **/*.{js,ts,mjs}
alwaysApply: false
---

- Use ES modules (`import`/`export`); avoid CommonJS in new code.
- Prefer TypeScript for all new files.
- Use async/await over raw Promises and callbacks.
- Handle errors in async functions with try/catch at route boundaries.
- Use environment variables via a validated config module (e.g. zod or dotenv-safe).
- Never commit secrets; use `.env.example` for required variables.
- Use structured logging (pino or winston) in production.
- Validate all external inputs before processing.
