All Projects → Prasanna-sr → express-routes-versioning

Prasanna-sr / express-routes-versioning

Licence: MIT license
Node.js module provides versioning for expressjs routes/api

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to express-routes-versioning

owlos
DIY Open Source OS for building IoT ecosystems
Stars: ✭ 43 (-24.56%)
Mutual labels:  restful-api
SimpleGlip
A simple Glip client with RESTful API
Stars: ✭ 20 (-64.91%)
Mutual labels:  restful-api
spring-interview-questions
500+ Spring-Boot Interview Questions
Stars: ✭ 269 (+371.93%)
Mutual labels:  restful-api
Library
Online Library Management. User can search, check in, checkout book. System adds fines automatically if the book is not checked in by due date
Stars: ✭ 27 (-52.63%)
Mutual labels:  restful-api
babyfoot
Simple CQRS/ES Node+Express+TypeScript REST API
Stars: ✭ 14 (-75.44%)
Mutual labels:  restful-api
aegisnet
Lightweight express, koa, and http middleware for efficient API endpoint monitoring
Stars: ✭ 13 (-77.19%)
Mutual labels:  express-middleware
versionaire
Provides an immutable, thread-safe, and semantic version type.
Stars: ✭ 71 (+24.56%)
Mutual labels:  versioning
questionnaire online
springboot+mybatis在线问卷系统
Stars: ✭ 147 (+157.89%)
Mutual labels:  restful-api
CourseCake
By serving course 📚 data that is more "edible" 🍰 for developers, we hope CourseCake offers a smooth approach to build useful tools for students.
Stars: ✭ 21 (-63.16%)
Mutual labels:  restful-api
rocket-rest-api-with-jwt
A Rusty Rocket fuelled with Diesel and secured by JWT
Stars: ✭ 62 (+8.77%)
Mutual labels:  restful-api
wgrest
WireGuard REST API
Stars: ✭ 92 (+61.4%)
Mutual labels:  restful-api
FullStack-Angular-SpringBoot
Customer Relationship Managment [Full-stack Web Development using Angular & SpringBoot (RestFull API)]
Stars: ✭ 48 (-15.79%)
Mutual labels:  restful-api
akaash-rest-api
Akaash: A restful API template built with PHP driven by flight micro-framework
Stars: ✭ 17 (-70.18%)
Mutual labels:  restful-api
kite-server
“上应小风筝”小程序 API 代码和文档, 基于 Rust 语言的 poem 框架编写.
Stars: ✭ 19 (-66.67%)
Mutual labels:  restful-api
peerai-api
Peerism's Peer.ai API built with Truffle, Node.js, Express.js, Solidity, and Ethereum TestRPC
Stars: ✭ 18 (-68.42%)
Mutual labels:  express-middleware
gin-api-boilerplate
A Go RESTful API server with gin and docker
Stars: ✭ 16 (-71.93%)
Mutual labels:  restful-api
node-crudapi-ts
CRUD boilerplate for create Node Restful API's with Express Framework and Sequelize ORM written in Typescript.
Stars: ✭ 41 (-28.07%)
Mutual labels:  restful-api
roundup
un-official mirror of http://hg.code.sf.net/p/roundup/code -- used for CI. Please visit https://issues.roundup-tracker.org for finding starter issues or log new issues.
Stars: ✭ 20 (-64.91%)
Mutual labels:  restful-api
bodymen
Body parser middleware for MongoDB, Express and Nodejs (MEN)
Stars: ✭ 49 (-14.04%)
Mutual labels:  express-middleware
shadowsocks-restful-api
Secure, reliable, standard restful api for managing shadowsocks-libev
Stars: ✭ 72 (+26.32%)
Mutual labels:  restful-api

Express routes versioning

Build Status Coverage Status npm version

Simple node.js module provides versioning for expressjs routes/api.

Install

npm install express-routes-versioning

Usage

Follows semver versioning format. Supports '^, ~' symbols for matching version numbers.

    var app = require('express')();
    var routesVersioning = require('express-routes-versioning')();
    app.listen(3000);

    app.get('/test', routesVersioning({
       "1.0.0": respondV1,
       "~2.2.1": respondV2
    }));

    // curl -s -H 'accept-version: 1.0.0' localhost:3000/test
    // version 1.0.0 or 1.0 or 1 !
    function respondV1(req, res, next) {
       res.status(200).send('ok v1');
    }

    //curl -s -H 'accept-version: 2.2.0' localhost:3000/test
    //Anything from 2.2.0 to 2.2.9
    function respondV2(req, res, next) {
       res.status(200).send('ok v2');
    }

Supporting '^,~' on server might appear as an anti-pattern considering how npm versioning works, where client controls the version. Here server controls the version (or it may not), and client fully trust the server. Typically the client and server belong to the same organization in these cases.

API

routesVersioning(Options, NoMatchFoundCallback)

Options - object, containing version in semver format (supports ^,~ symbols) as key and function callback (connect middleware format) to invoke when the request matches the version as value. Note: Versions are expected to be mutually exclusive, as order of execution of the version couldn't be determined.

NoMatchFoundCallback (optional)- called if request version doesn't match the version provided in the options. If this callback is not provided latest version callback is called.

How version is determined for each request ?

Default behaviour is to use accept-version headers from the client.

This can be overridden by using a middleware and providing version in req.version property.

How versions are matched ?

semver versioning format is used to match version if versions are provided in semver format, supports ^,~ symbols on the server, else direct mapping is used (for versions like 1, 1.1)

Examples

Examples are available here

Test

npm test

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].