Browse Source

Fix missing legacyUrl behavior

pull/210/head
Diana Shkolnikov 9 years ago
parent
commit
2b9fbdfd10
  1. 1
      app.js
  2. 11
      routes/legacy.js
  3. 9
      routes/v1.js

1
app.js

@ -15,6 +15,7 @@ app.use( require('./middleware/cors') );
app.use( require('./middleware/jsonp') );
/** ----------------------- routes ----------------------- **/
var legacy = require('./routes/legacy');
legacy.addRoutes(app, peliasConfig);

11
routes/legacy.js

@ -1,11 +1,16 @@
var proxy = require('express-http-proxy');
function addRoutes(app, peliasConfig) {
var sendToLegacy;
if (!peliasConfig.hasOwnProperty('legacyUrl')) {
return;
sendToLegacy = function doNothing(req, res, next) {
next(new Error('Invalid path, no legacy proxy specified'));
};
}
else {
sendToLegacy = proxy(peliasConfig.legacyUrl);
}
var sendToLegacy = proxy(peliasConfig.legacyUrl);
// api root
app.get( '/', sendToLegacy );

9
routes/v1.js

@ -1,4 +1,5 @@
var reverseQuery = require('./query/reverse');
var Router = require('express').Router;
var reverseQuery = require('../query/reverse');
/** ----------------------- sanitisers ----------------------- **/
var sanitisers = {
@ -18,9 +19,9 @@ var controllers = {
/** ----------------------- controllers ----------------------- **/
var postProc = {
renamePlacenames: require('./middleware/renamePlacenames'),
geocodeJSON: require('./middleware/geocodeJSON'),
sendJSON: require('./middleware/sendJSON')
renamePlacenames: require('../middleware/renamePlacenames'),
geocodeJSON: require('../middleware/geocodeJSON'),
sendJSON: require('../middleware/sendJSON')
};
/**

Loading…
Cancel
Save