Skip to content

Commit

Permalink
fix: Merge pull request pelias#962 from pelias/root_route
Browse files Browse the repository at this point in the history
Add default route redirecting to /v1
  • Loading branch information
orangejulius authored Aug 30, 2017
2 parents fe2eb57 + fb9b76e commit b18cc6b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

var app = require('express')();

var peliasConfig = require( 'pelias-config' ).generate(require('./schema'));
Expand All @@ -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);

Expand Down
12 changes: 12 additions & 0 deletions routes/default.js
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit b18cc6b

Please sign in to comment.