Compare commits
2 Commits
4316b69a43
...
7a39529e2c
| Author | SHA1 | Date | |
|---|---|---|---|
| 7a39529e2c | |||
| 83294ec6f4 |
6
geo.mjs
6
geo.mjs
@@ -1,4 +1,4 @@
|
||||
export async function resolvePlace(query, context) {
|
||||
export async function resolvePlace(query, context, options = {}) {
|
||||
if (!query) {
|
||||
return null;
|
||||
}
|
||||
@@ -6,7 +6,7 @@ export async function resolvePlace(query, context) {
|
||||
const cacheKey = `place-${context.slugify(query)}`;
|
||||
const cachedPlace = await context.redis.hGetAll(cacheKey);
|
||||
|
||||
if (context.argv.placeCache !== false && await context.redis.exists(cacheKey)) {
|
||||
if (options.useCache !== false && await context.redis.exists(cacheKey)) {
|
||||
await context.redis.expire(cacheKey, 3600 * 24 * 30);
|
||||
|
||||
context.logger.debug(`Using cached place '${cacheKey}' for query '${query}': ${JSON.stringify(cachedPlace)}`);
|
||||
@@ -32,7 +32,7 @@ export async function resolvePlace(query, context) {
|
||||
// https://operations.osmfoundation.org/policies/nominatim/
|
||||
const res = await context.unprint.get(`https://nominatim.openstreetmap.org/search?q=${encodeURI(query)}&format=json&accept-language=en&addressdetails=1`, {
|
||||
headers: {
|
||||
'User-Agent': context.config.location.userAgent,
|
||||
'User-Agent': options.userAgent,
|
||||
},
|
||||
interval: 1000,
|
||||
concurrency: 1,
|
||||
|
||||
Reference in New Issue
Block a user