express-versioned-route
v1.0.0-next.1
Published
Simple express.js 4.x extension, to add support for versioned routes.
Downloads
4
Maintainers
Readme
Express-Versioned-Route
Simple express.js 4.x extension, to add support for versioned routes.
Highlights
- Versioning the same route
- Loading time validation
- Custom middlewares for each version
- ~~Built-in soft deprecation policy~~ (to be added soon)
- Case insensitive name matching
- Minimal overhead ( less than 0.15ms/request )
- Dynamic routing based on client headers
- Client can choose the version using
accept-version
header
Install
npm install express-versioned-route
Usage
const searchVersionDef = versionsDef({
versions: {
simpleSearch: ['2020-Q1', searchMW1, searchMW2, searchHandlerV1],
dynamicSearch: [dynamicSearchMW1, dynamicSearchMW2, searchHandlerV2],
superSearch: [searchHandlerV3],
deepSearch: [searchHandlerV4],
},
Android: [
[400, 'simpleSearch'],
[450, 'dynamicSearch'],
[500, 'superSearch'],
],
iOS: [
[400, 'simpleSearch'],
[460, 'dynamicSearch'],
],
});
app.get('/search', mw1, mw2, searchVersionDef);