geolocation api rate-limit: add per-provider prefix to cached response, refactor geocoding provider code
This commit is contained in:
23
server/services/geocoding/nominatim.js
Normal file
23
server/services/geocoding/nominatim.js
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
module.exports = {
|
||||
commonName: 'Nominatim',
|
||||
DEFAULT_ENDPOINT: 'https://nominatim.openstreetmap.org/search',
|
||||
endpoint: (req, res) => {
|
||||
return res.locals.settings.geocoding_provider || this.DEFAULT_ENDPOINT
|
||||
},
|
||||
|
||||
getParams (req, res) {
|
||||
const countrycodes = res.locals.settings.geocoding_countrycodes || []
|
||||
const details = req.params.place_details
|
||||
|
||||
return {
|
||||
countrycodes: countrycodes.join(','),
|
||||
q: details,
|
||||
limit: 3,
|
||||
format: 'json',
|
||||
addressdetails: 1,
|
||||
namedetails: 1,
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
18
server/services/geocoding/photon.js
Normal file
18
server/services/geocoding/photon.js
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
module.exports = {
|
||||
commonName: 'Photon',
|
||||
DEFAULT_ENDPOINT: 'https://photon.komoot.io/api/',
|
||||
endpoint: (req, res) => {
|
||||
return res.locals.settings.geocoding_provider || this.DEFAULT_ENDPOINT
|
||||
},
|
||||
|
||||
getParams (req, res) {
|
||||
const details = req.params.place_details
|
||||
|
||||
return {
|
||||
q: details,
|
||||
limit: 3,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user