diff --git a/README.md b/README.md index e066a575..3e3bfec3 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,6 @@ The API recognizes the following properties under the top-level `api` key in you |`host`|*yes*||specifies the url under which the http service is to run| |`textAnalyzer`|*no*|*addressit*|can be either `libpostal` or `addressit` however will soon be **deprecated** and only `libpostal` will be supported going forward| |`indexName`|*no*|*pelias*|name of the Elasticsearch index to be used when building queries| -|`legacyUrl`|*no*||the url to redirect to in case the user does not specify a version such as `v1` |`relativeScores`|*no*|true|if set to true, confidence scores will be normalized, realistically at this point setting this to false is not tested or desirable |`accessLog`|*no*||name of the format to use for access logs; may be any one of the [predefined values](https://github.com/expressjs/morgan#predefined-formats) in the `morgan` package. Defaults to `"common"`; if set to `false`, or an otherwise falsy value, disables access-logging entirely.| |`services`|*no*||service definitions for [point-in-polygon](https://github.com/pelias/pip-service) and [placholder](https://github.com/pelias/placeholder) services. If missing (which is not recommended), the point-in-polygon and placeholder services will not be called.| @@ -65,7 +64,6 @@ Example configuration file would look something like this: "api": { "host": "localhost:3100/v1/", "indexName": "foobar", - "legacyUrl": "pelias.mapzen.com", "relativeScores": true, "textAnalyzer": "libpostal", "services": { diff --git a/app.js b/app.js index 2034e96b..342f00eb 100644 --- a/app.js +++ b/app.js @@ -16,9 +16,6 @@ app.use( require('./middleware/jsonp') ); /** ----------------------- routes ----------------------- **/ -var legacy = require('./routes/legacy'); -legacy.addRoutes(app, peliasConfig.api); - var v1 = require('./routes/v1'); v1.addRoutes(app, peliasConfig); diff --git a/package.json b/package.json index 9e06b581..d61eacc9 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,6 @@ "elasticsearch": "^12.0.1", "elasticsearch-exceptions": "0.0.4", "express": "^4.8.8", - "express-http-proxy": "^0.11.0", "extend": "^3.0.1", "geojson": "^0.4.0", "@mapbox/geojson-extent": "^0.3.1", diff --git a/routes/legacy.js b/routes/legacy.js deleted file mode 100644 index 1de4986d..00000000 --- a/routes/legacy.js +++ /dev/null @@ -1,34 +0,0 @@ -var proxy = require('express-http-proxy'); - -function addRoutes(app, peliasConfig) { - var sendToLegacy; - - if (!peliasConfig.hasOwnProperty('legacyUrl')) { - sendToLegacy = function redirectToV1(req, res, next) { - res.redirect(301, '/v1'); - }; - } - else { - sendToLegacy = proxy(peliasConfig.legacyUrl); - } - - // api root - app.get( '/', sendToLegacy ); - - // place API - app.get( '/place', sendToLegacy); - - // suggest APIs - app.get( '/suggest', sendToLegacy ); - app.get( '/suggest/nearby', sendToLegacy ); - app.get( '/suggest/coarse',sendToLegacy ); - - // search APIs - app.get( '/search', sendToLegacy); - app.get( '/search/coarse', sendToLegacy); - - // reverse API - app.get( '/reverse', sendToLegacy ); -} - -module.exports.addRoutes = addRoutes; diff --git a/schema.js b/schema.js index df544677..ca69ccfb 100644 --- a/schema.js +++ b/schema.js @@ -12,14 +12,12 @@ const Joi = require('joi'); // optional: // * api.accessLog (string) // * api.relativeScores (boolean) -// * api.legacyUrl (string) // * api.localization (flipNumberAndStreetCountries is array of 3 character strings) module.exports = Joi.object().keys({ api: Joi.object().keys({ version: Joi.string(), indexName: Joi.string(), host: Joi.string(), - legacyUrl: Joi.string(), accessLog: Joi.string(), relativeScores: Joi.boolean(), requestRetries: Joi.number().integer().min(0), diff --git a/test/unit/schema.js b/test/unit/schema.js index d48c7392..c3cf25de 100644 --- a/test/unit/schema.js +++ b/test/unit/schema.js @@ -12,7 +12,6 @@ module.exports.tests.completely_valid = (test, common) => { version: 'version value', indexName: 'index name value', host: 'host value', - legacyUrl: 'legacyUrl value', accessLog: 'accessLog value', relativeScores: true, localization: { @@ -160,29 +159,6 @@ module.exports.tests.api_validation = (test, common) => { }); - test('non-string api.legacyUrl should throw error', (t) => { - [null, 17, {}, [], true].forEach((value) => { - var config = { - api: { - version: 'version value', - indexName: 'index name value', - host: 'host value', - legacyUrl: value - }, - esclient: {} - }; - - const result = Joi.validate(config, schema); - - t.equals(result.error.details.length, 1); - t.equals(result.error.details[0].message, '"legacyUrl" must be a string'); - - }); - - t.end(); - - }); - test('non-string api.accessLog should throw error', (t) => { [null, 17, {}, [], true].forEach((value) => { var config = {