diff --git a/api/src/gasbuddy.ts b/api/src/gasbuddy.ts index 573d3c7..81ecbe7 100644 --- a/api/src/gasbuddy.ts +++ b/api/src/gasbuddy.ts @@ -94,7 +94,7 @@ let lastFetchTime = 0; async function throttle(): Promise { const elapsed = Date.now() - lastFetchTime; - if (elapsed < 500) await Bun.sleep(500 - elapsed); + if (elapsed < 2000) await Bun.sleep(2000 - elapsed); lastFetchTime = Date.now(); } diff --git a/api/src/handlers/stations.ts b/api/src/handlers/stations.ts index 971e8e1..ff709b8 100644 --- a/api/src/handlers/stations.ts +++ b/api/src/handlers/stations.ts @@ -9,7 +9,7 @@ import { import { fetchStationsByLocation } from "../gasbuddy.ts"; import { latLngToCell } from "../geo.ts"; -const NEARBY_TTL_MS = 30 * 60 * 1000; // 30 minutes +const NEARBY_TTL_MS = 2 * 60 * 60 * 1000; // 2 hours const MAX_BBOX_AREA = 0.5; export async function handleNearby(req: Request): Promise { @@ -77,11 +77,8 @@ export async function handleBbox(req: Request): Promise { } const area = (maxLat - minLat) * (maxLng - minLng); - if (area <= 0 || area > MAX_BBOX_AREA) { - return err( - "Bbox area must be positive and ≤ 0.5 deg²", - 400, - ); + if (area <= 0) { + return err("Invalid bbox", 400); } const stations = queryStationsInBbox(minLat, minLng, maxLat, maxLng);