geolocation api rate-limit: split cache instance, one for each provider
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
const cache = require('memory-cache')
|
||||
const providerCache = new cache.Cache()
|
||||
|
||||
module.exports = {
|
||||
const nominatim = {
|
||||
commonName: 'Nominatim',
|
||||
DEFAULT_ENDPOINT: 'https://nominatim.openstreetmap.org/search',
|
||||
endpoint: (req, res) => {
|
||||
return res.locals.settings.geocoding_provider || this.DEFAULT_ENDPOINT
|
||||
return res.locals.settings.geocoding_provider || nominatim.DEFAULT_ENDPOINT
|
||||
},
|
||||
cache: providerCache,
|
||||
|
||||
getParams (req, res) {
|
||||
const countrycodes = res.locals.settings.geocoding_countrycodes || []
|
||||
@@ -20,4 +23,6 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = nominatim
|
||||
@@ -1,10 +1,13 @@
|
||||
const cache = require('memory-cache')
|
||||
const providerCache = new cache.Cache()
|
||||
|
||||
module.exports = {
|
||||
const photon = {
|
||||
commonName: 'Photon',
|
||||
DEFAULT_ENDPOINT: 'https://photon.komoot.io/api/',
|
||||
endpoint: (req, res) => {
|
||||
return res.locals.settings.geocoding_provider || this.DEFAULT_ENDPOINT
|
||||
return res.locals.settings.geocoding_provider || photon.DEFAULT_ENDPOINT
|
||||
},
|
||||
cache: providerCache,
|
||||
|
||||
getParams (req, res) {
|
||||
const details = req.params.place_details
|
||||
@@ -15,4 +18,6 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = photon
|
||||
Reference in New Issue
Block a user