Skip to content

Instantly share code, notes, and snippets.

@superkhau
Last active August 21, 2017 07:51
Show Gist options
  • Save superkhau/8ba255690d44e09bb036 to your computer and use it in GitHub Desktop.
Save superkhau/8ba255690d44e09bb036 to your computer and use it in GitHub Desktop.
LoopBack - API versioning

Create config.local.js with the following:

var p = require('../package.json');
var version = p.version.split('.').shift();

module.exports = {
  restApiRoot: '/api' + (version > 0 ? '/v' + version : ''),
  host: process.env.HOST || 'localhost',
  port: process.env.PORT || 3000
};

API path's will look like /api/v1 using the app's major version. If the app's major version is 0, then the path is simply /api.

@shrimaliakash
Copy link

shrimaliakash commented Aug 21, 2017

How can access api versioning in that way in postman??

@shrimaliakash
Copy link

app.all('/api/:version/:controller*?'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment