New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

express-route-dateversioning

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-route-dateversioning

Express middleware for versioning routes according dates

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
2
Weekly downloads
 
Created
Source

express-route-dateversioning

Express middleware for versioning routes according dates.

Why to use?

Date versioning your API enables you to develop and release your API in individual pieces or microservices. Defining the API date version lets to defer any of the versions released after the date, keeping your API consistent over time without having to define rigid numeric versions.

Install

$ npm install express-route-dateversioning --save

Usage

Setting up the server

const express = require('express');
const version = require('express-route-dateversioning');

let app = express();

// Version root middleware
app.get('/', version({
  '2017-01-18': (req, res) => { res.send('new pong'); },
  '2016-10-01': (req, res) => { res.send('old ping'); },
}));

Doing a request to versioned API

Api version can be defined either with apiversion query parameter or custom header

const request = require('request');

request.get('http://api.com/thing/1?apiversion=2017-01-19');
const request = require('request');

request({
  method: 'get',
  uri: 'http://api.com/thing/1',
  headers: {
    'apiversion': '2017-01-19'
  }
});

Custom configuration

Default query param (apiversion) and header (apiversion) names are also configurable

Note! This should be done before any versioned routes are set

const version = require('express-route-dateversioning');
version.config({
  queryparam: 'custom-apiversion',
  header: 'custom-apiversion'
});

FAQs

Package last updated on 25 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc