ericrisco/rsc-harness / skills/nodejs
nodejs
VerifiedUse when building or operating a plain Node.js / Express 5 backend service: project layout, async correctness, central error middleware, fail-fast config, graceful shutdown on SIGTERM. NOT DI modules/providers/guards (that is `nestjs`), NOT the type system or tsconfig (that is `typescript`), NOT REST contract design (that is `api-design`).
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 12.5 KB |
| evals/README.md | markdown | 732 B |
| evals/cases.yaml | config | 2.7 KB |
| references/express5-migration.md | markdown | 2.7 KB |
| references/graceful-shutdown.md | markdown | 3.0 KB |
| scripts/verify.shexecutable | script | 4.3 KB |
references/express5-migration.md
View on GitHub# Express 4 → 5 migration & middleware order
Express 5.2.x is current and requires Node.js 18+. Source: npm `express`, Express 5 migration guide (accessed 2026-06-02). Use this as the offloaded depth referenced from SKILL.md.
## Breaking changes that bite a backend
| Area | v4 | v5 | Action |
| --- | --- | --- | --- |
| Async errors | a rejected/thrown async handler hangs unless wrapped | auto-forwarded to the 4-arg error middleware | Delete `asyncHandler` wrappers; just `throw` / reject |
| `express.urlencoded` | `extended: true` default | `extended: false` default | Pass `{ extended: true }` explicitly if you relied on rich objects |
| `express.static` dotfiles | `"allow"` for some setups | `dotfiles: "ignore"` default | Set `{ dotfiles: "allow" }` only if you intend to serve `.well-known` etc. |
| Path matching | older path-to-regexp | newer path-to-regexp; some wildcard/optional syntaxes changed | Re-test `:param?`, `*`, and regex routes; name your wildcards |
| Removed/renamed | `res.json(status, obj)`, `app.del`, `req.param(name)` | removed | Use `res.status(s).json(obj)`, `app.delete`, `req.params`/`req.query`/`req.body` |
## Auto async error catch — what it actually guarantees
The framework's own router tests confirm: an `async` handler that rejects, or returns `Promise.reject(err)`, reaches the 4-arg error handler. A value-less `Promise.reject()` is surfaced as an `Error` with message `Rejected promise`. So in v5 you write:
```ts
// v5 — no wrapper
app.get("/users/:id", async (req, res) => {
const u = await findUser(req.params.id); // throw NotFound → error middleware
res.json(u);
});
```
```ts
// v4 legacy wrapper — ONLY if you are still on Express 4
const asyncHandler = (fn) => (req, res, next) =>
Promise.resolve(fn(req, res, next)).catch(next);
app.get("/users/:id", asyncHandler(async (req, res) => { /* ... */ }));
```
What auto-catch does NOT cover: a promise you never awaited or returned inside the handler (a floating promise). That still escapes to the process, not the error middleware. Await everything.
## Middleware order (still matters in v5)
Order of registration is order of execution. The error handler is selected by arity (4 args), not by name or position alone — but it only catches what is registered *before* it.
```text
app.use(express.json()) parsers, security headers
│
▼
app.use("/users", usersRouter) routes (may throw → forwarded down)
│
▼
app.use((req,res) => 404) fallthrough: nothing matched
│
▼
app.use((err,req,res,next) => ...) ERROR HANDLER — 4 args, registered LAST
```
A 4-arg function registered *before* the routes is skipped for normal requests and can never catch a route's throw. Put it last, exactly once.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |