anantbhandarkar/make-it-right/mir-backend-node-express
Claude Code and agent skill by anantbhandarkar/make-it-right
- community
Checking that the SKILL.md file is still in the repository.
Make It Right (Express module). Express 5 (now the npm default) + Express 4 maintenance-line reliability augmentation. Use alongside mir-backend and mir-backend-node when the target stack is Express — it carries the mechanical footguns that the framework-agnostic tiers deliberately omit: what Express 5 does and does not auto-catch for async handlers, the path-to-regexp route-syntax break that makes `app.get('*')` throw at boot, req.body being undefined rather than {}, the simple-vs-extended query parser change, middleware ordering as a hard contract, error-handler arity, the absence of built-in validation and what fills the gap, CORS/helmet/rate-limit being off by default, trust-proxy spoofing, and object-level authorization gaps that structural frameworks catch but Express doesn't. TRIGGER only when the Node backend stack is Express used directly — building, reviewing, or debugging an Express route, middleware, or error handler. Always loads TOGETHER WITH mir-backend (the gates) and mir-backend-node (V8 event-loop / process-model concerns: blocking, worker_threads, unhandled rejections, backpressure, timeouts, npm supply chain); this module only adds Express library mechanics. SKIP for Fastify, Hapi, or Koa (each has its own mir-backend-node-<framework> module), SKIP for NestJS even though NestJS runs on Express by default — that stack loads mir-backend-node-nestjs instead — and SKIP for non-Node runtimes.
Install
npx vskill@latest install anantbhandarkar/make-it-right/mir-backend-node-expressSKILL.md
The same SKILL.md was published earlier as anantbhandarkar/make-it-right/mir-backend-node-express.
/mir-backend-node-express · Make It Right (Express)
Bottom tier of the chain: mir-backend (generic gates) → mir-backend-node (V8/Node event-loop model) → this (Express library mechanics). Run the gates first; load the Node runtime tier for event-loop and process-model concerns; reach for this at Gate 5 (design mechanics), Gate 6 (implementation), and Gate 7 review. Runtime-level concerns (blocking the event loop, worker_threads, unhandled rejections, stream backpressure, timeouts, heap limits, npm supply chain) live in `mir-backend-node` — not here.
Stack assumed (npm registry, 13 Aug 2026): express@5.2.1 is the latest tag; the 4.x maintenance line is latest-4 = 4.22.2. Express 5 requires Node ≥ 18 by its own engines field, but target Node 22/24 per the runtime tier — Node 20 is EOL. Do not pin 5.2.0: it shipped an unintended breaking change to extended query parsing and was superseded by 5.2.1 the same day.
If you are writing new Express code, write Express 5. npm install express has resolved to 5.x since 5.1.0 took the latest tag on 2025-03-31. Most training data — and most AI output — is still Express 4, which is where the next four items come from.
The Express footguns AI walks into most
1. Express 5 auto-forwards rejected promises — Express 4 does not, and neither catches callbacks
Express 5 awaits the promise returned by a route handler or by any middleware, and forwards a rejection to the error-handling middleware. That "or any middleware" matters: async auth and validation middleware get the same treatment, which is the reason the asyncHandler wrapper and the express-async-errors shim are both unnecessary on 5:
Express 4 does not await the return value. The same code produces an unhandled rejection (which kills the process, see the Node tier) and the request hangs until the client times out. On 4.x, wrap or catch explicitly:
The part Express 5 does NOT fix, and the reason "we're on 5, we're fine" is wrong in review: only the returned promise is awaited. Everything else escapes the handler and lands at the process level — as two different failures that need two different handlers:
| What escapes | Where it lands | |
|---|---|---|
a promise you started but did not return or await | unhandledRejection → process exits (Node default) | |
a throw inside a setTimeout/setInterval or a plain callback | uncaughtException | |
an EventEmitter 'error' event with no listener | throws → uncaughtException | |
a stream error with no 'error' handler and no pipeline() | same |
Wiring only process.on('unhandledRejection') and calling it done leaves the bottom three unhandled. See the Node tier §3 and §7.
State the Express major in the design. If it is 4, every async handler needs a wrapper and the plan needs a migration note.
2. Express 5 changed the route syntax — app.get('*') throws at startup
Express 5 upgraded to path-to-regexp 8, which removed sub-expression regex patterns and requires wildcards to be named. AI writes Express 4 route strings constantly, and the failure is a boot-time TypeError about a missing parameter name, or a silent 404 — not a helpful message:
| Express 4 | Express 5 | Notes | |
|---|---|---|---|
app.get('*', h) | app.get('/*splat', h) | wildcard must be named | |
'/files/*' matching /files too | '/files/{*splat}' | braces make the group optional | |
'/:file.:ext?' | '/:file{.:ext}' | ? optional marker removed | |
'/:id(\\d+)' | validate req.params.id in the handler | inline regex removed for ReDoS reasons | |
req.params[0] for a wildcard | req.params.splat — an array of segments | shape change, not just a name change |
This applies everywhere a path string is accepted: app.use, router.use, and any path-based middleware mount.
3. Express 5 also changed three defaults that produce silent wrong behavior
| Change | Express 4 | Express 5 | The failure | |
|---|---|---|---|---|
req.body with no body parser | {} | `undefined` | req.body.email throws TypeError: Cannot read properties of undefined instead of being falsy | |
default query parser | extended | `simple` | ?filter[status]=open yields the string key 'filter[status]', not a nested object; filters silently stop working | |
res.status(n) | anything accepted | must be an integer 100–999 | res.status(err.code) with a driver error code now throws |
Also removed in 5: app.del() (use app.delete()), req.param(name), res.sendfile(), res.send(body, status) / res.json(obj, status) (use res.status(s).json(o)), res.redirect(url, status) (argument order is now (status, url)), and res.redirect('back'). npx codemod@latest @expressjs/v5-migration-recipe applies the mechanical ones.
4. Middleware order is the contract — get it wrong and nothing else matters
Express resolves middleware strictly in registration order. The order is not a style choice; it is the execution contract:
Common ordering defects AI introduces:
- Body parser after routes —
req.bodyisundefinedin the handler (and in Express 5 that is aTypeError, not an empty object). - Auth middleware missing from a router — a route added later slips in unauthenticated.
- Error handler not registered last — it never runs.
- Error handler with 3 args (
(req, res, next)) — Express identifies error handlers by arity; 3-arg handlers are treated as regular middleware and skipped for errors.
5. No built-in validation — without it, mass assignment and injection slip in
Express puts raw, unvalidated input on req.body / req.query / req.params. AI code that passes these straight to a database or service layer is vulnerable to:
- Mass assignment / overposting — a client sends
{ "isAdmin": true }alongside a legitimate payload; if you spreadreq.bodyinto an ORM object, you have just promoted them. - Type coercion surprises — query strings are always strings; passing
req.query.limitto a DB call that expects a number without parsing is a latent bug. Express 5'ssimplequery parser makes this worse, because nested keys arrive as flat strings.
Validate at the route boundary with zod (latest 4.4.3) or joi. Define a schema, parse, and use only the parsed output:
Catch ZodError in the error handler and return a 400 with field-level detail. Never pass req.body to an ORM model constructor without schema-gating it first. Express has no response-side equivalent of Fastify's response schema, so also choose the fields you send back explicitly — do not res.json(userRow).
6. Object-level authorization is easy to miss — no structure enforces it
Express has no built-in guard or controller structure. Authentication (who are you?) is easy to add as a single middleware. Authorization (may *this user* act on *this specific resource*?) is easy to forget because there is no framework hook that forces it at the route level:
Return 404 (not 403) when the resource does not belong to the requester — 403 confirms the resource exists. Enforce object-level authorization at every endpoint that loads an entity by a client-supplied ID, including PATCH/DELETE, not just GET.
Security
Express-specific mechanics. Runtime-level items (SSRF, command injection, prototype pollution, path traversal, npm supply chain, secrets in logs) live in mir-backend-node.
Current advisory class: path-to-regexp ReDoS, and it reaches you transitively
Express 5 pulls path-to-regexp through router@2.2.0, declared as ^8.0.0. Two ReDoS CVEs published 2026-03-27 affect 8.0.0 up to but not including 8.4.0, fixed in 8.4.0 (registry latest is 8.4.2):
| CVE | Trigger | |
|---|---|---|
| CVE-2026-4923 | multiple wildcards plus at least one parameter, where the second wildcard is not at the end — e.g. /*foo-*bar-:baz, /x/*a-:b/*c/y. /*foo-:bar is safe. | |
| CVE-2026-4926 | multiple sequential optional groups in brace syntax — e.g. {a}{b}{c}:z. Generated regex grows exponentially with group count. |
A caret range means a fresh install picks up the fix; a lockfile committed before March 2026 does not. Check with npm ls path-to-regexp, not by reading package.json. Then audit your own route strings for the two shapes above — the fix removes the pathological regex generation, but multi-wildcard routes are worth simplifying anyway. Express's own security-updates page still only documents 4.x entries, so do not treat "no Express advisory" as "no risk"; Express's exposure mostly arrives through path-to-regexp, send, serve-static, qs, cookie, and body-parser.
Nothing secure is on by default
Express ships with no security headers, no CORS policy, and no rate limiting. Registered versions verified on the registry today: helmet@8.3.0, cors@2.8.6, express-rate-limit@8.6.2.
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/mir-backend-node-express/SKILL.md
Popularity
- Repository stars
- 15
- 7-day trend score
- 14
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/anantbhandarkar/make-it-right/mir-backend-node-express)