An Express-style router for Node.js with full TypeScript safety, including inferred route params from path strings (e.g., '/user/:id' gives req.params.id: string) and typed request/response bodies via generic parameters. Current stable version is 6.1.6. Key differentiators: no view engine, no global state, dual ESM/CJS exports, built-in error handling, and safe defaults (1 MB JSON limit, strict content-type checks). Released actively with regular updates; ships its own TypeScript types.
npm install router-middlewareVerified import paths — ran on the pinned version, not inferred.
Creates a typed HTTP server with route param inference and typed request/response bodies.
Use `const app = require('router-middleware').default;` instead of `const app = require('router-middleware');`Replace `req.param('id')` with `req.params.id`Add `app.use(app.jsonParser());` before routes that expect JSON body
Use `res.json({...})` instead of `res.send({...})`Migrate to `app.onError(handler)` when upgrading to v7
Change to const app = require('router-middleware').default;Replace res.send(obj) with res.json(obj)
Ensure `const app = createApp();` is called and `app.use(app.jsonParser());` is added
Add generic type like app.get<'/path/:id'>('/path/:id', handler) to infer paramsNo dependency data recorded yet.