Browse Source

fix: Merge pull request #962 from pelias/root_route

Add default route redirecting to /v1
pull/965/head v3.27.19
Julian Simioni 7 years ago committed by GitHub
parent
commit
b18cc6bf82
  1. 5
      app.js
  2. 12
      routes/default.js

5
app.js

@ -1,4 +1,3 @@
var app = require('express')();
var peliasConfig = require( 'pelias-config' ).generate(require('./schema'));
@ -16,6 +15,10 @@ app.use( require('./middleware/jsonp') );
/** ----------------------- routes ----------------------- **/
var defaultRoutes = require('./routes/default');
defaultRoutes.addRoutes(app);
var v1 = require('./routes/v1');
v1.addRoutes(app, peliasConfig);

12
routes/default.js

@ -0,0 +1,12 @@
// set up routes that are outside any particular API version
function addRoutes(app) {
function redirectToV1(req, res, next) {
res.redirect(301, '/v1');
}
// default root URL traffic to V1 root
// which has a link to the readme and other helpful info
app.get('/', redirectToV1);
}
module.exports.addRoutes = addRoutes;
Loading…
Cancel
Save