Repository navigation
v1.0.3 — Router mergeParams
Router mergeParams Option
Child routers can now inherit parent route parameters — matching Express's express.Router({ mergeParams: true }) behavior.
Features
new Router({ mergeParams: true })— enables parent param inheritance in child routers- Parameterized prefix matching — mount sub-routers on paths like
/users/:userIdwith regex-based matching - Child params override parent params on name conflicts (Express-compatible behavior)
- Deep nesting support — grandparent → parent → child param chains work when each router opts in
group()transparency — params pass through group boundaries automatically- Selective blocking — intermediate routers without
mergeParamscorrectly block ancestor params - Zero overhead — no performance impact on existing non-parameterized routes
Example
import bunway, { Router } from 'bunway';
const app = bunway();
const userPosts = new Router({ mergeParams: true });
userPosts.get('/', (req, res) => {
res.json({ userId: req.params.userId }); // inherited from parent
});
app.use('/users/:userId/posts', userPosts);
// GET /users/123/posts → { "userId": "123" }Tests
- 12 new integration tests covering all mergeParams scenarios
- 696 total tests passing across the suite
Contributor
Full Changelog: v1.0.2...v1.0.3