Name: api-versioning Version: 2.0.0 License: MIT
Express API Versioning is an Express.js middleware that dynamically loads different API versions based on the version number specified in the request URL. It helps maintain multiple API versions cleanly without breaking existing clients.
Full Guide to Build an API Versioning & Deprecation Manager in NodeJs.
- Supports URL-based API versioning (e.g., /v1/users, /v2/users)
- Seamless switching between API versions
- Works with Express 4.x
- Lightweight and easy to integrate
Install using npm:
npm install api-versioning
Peer Dependency:
- express (4.x)
Example Express setup:
const express = require('express'); const versioning = require('api-versioning');
const app = express();
app.use(versioning({ apiPath: './api', defaultVersion: 'v1' }));
app.listen(3000, () => { console.log('Server running on port 3000'); });
api/ ├── v1/ │ └── users.js └── v2/ └── users.js
- npm test : Run test cases using Mocha
- npm run build : Build the project using Babel
- npm run coveralls : Generate coverage report
Tests are written using Mocha, Chai, and Supertest.
Run tests: npm test
This project uses Babel for transpiling modern JavaScript features.
Build Output:
- Source: src/
- Compiled: build/
express, api, versioning, express api versioning, expressjs