skip Nominatim lookups when the server has none configured

Add GET /api/geocode/status ({configured}), like /api/overpass/status. The outline client and the last-resort place search ask it once per page and send no lookup a server without a Nominatim endpoint would refuse, so a default install no longer logs a 503 on its first named landmark or grounds ask. An older server or a failed probe leaves the capability unknown and lookups proceed as before.
This commit is contained in:
manjunath committed 2026-10-30 22:33:55 +05:30
1 parent 24228b145e
commit f32ab5446b
10 files changed
+157 -6

No files matched your search

+23
View File
@@ -30,3 +30,26 @@ test('place search follows the Photon setting', async () => {
const off = await hosts({ photon: null });
assert.ok(!off.some((host) => host.includes('photon')), off.join(','));
});
test('the last-resort route is skipped when the server reports Nominatim unconfigured', async () => {
const run = async (configured) => {
const asked = [];
const search = createDefaultPlaceSearch({
endpoints: { photon: null },
fetchImpl: async (url) => {
const path = new URL(String(url), 'http://local.test').pathname;
asked.push(path);
if (path === '/api/geocode/status')
return Response.json({ configured });
return Response.json({ status: 'ZERO_RESULTS', results: [] });
},
});
await search.geocode(`nowhere-nominatim-${configured}`);
return asked;
};
const off = await run(false);
assert.ok(off.includes('/api/geocode/status'));
assert.ok(!off.includes('/api/geocode'), off.join(','));
const on = await run(true);
assert.ok(on.includes('/api/geocode'), on.join(','));
});