From 7c27235400888d67e5276df3c82378b5e546e9d6 Mon Sep 17 00:00:00 2001 From: Will Freeman Date: Tue, 21 Apr 2026 11:49:46 -0600 Subject: [PATCH] zip code fix (#112) --- api/server.ts | 4 ++++ api/services/NominatimClient.ts | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/api/server.ts b/api/server.ts index f228856..d3082e7 100644 --- a/api/server.ts +++ b/api/server.ts @@ -81,6 +81,7 @@ const start = async () => { }, response: { 200: NominatimResultSchema, + 404: { type: 'object', properties: { error: { type: 'string' } } }, 500: { type: 'object', properties: { error: { type: 'string' } } }, }, }, @@ -88,6 +89,9 @@ const start = async () => { const { query } = request.query as { query: string }; reply.header('Cache-Control', 'public, max-age=86400, s-maxage=86400'); const result = await nominatim.geocodeSingleResult(query); + if (!result) { + return reply.status(404).send({ error: 'No results found' }); + } return result; }); diff --git a/api/services/NominatimClient.ts b/api/services/NominatimClient.ts index 529302b..255a3ae 100644 --- a/api/services/NominatimClient.ts +++ b/api/services/NominatimClient.ts @@ -17,9 +17,9 @@ export const NominatimResultSchema = Type.Object({ licence: Type.String(), lon: Type.String(), name: Type.String(), - osm_id: Type.Number(), - osm_type: Type.String(), - place_id: Type.Number(), + osm_id: Type.Optional(Type.Number()), + osm_type: Type.Optional(Type.String()), + place_id: Type.Optional(Type.Number()), place_rank: Type.Number(), type: Type.String(), });