From a1632ae402d11fdd7ffc360de97c55e0b4fad677 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 28 Feb 2026 14:14:30 -0800 Subject: migrate to hono --- routes/locations.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'routes/locations.ts') diff --git a/routes/locations.ts b/routes/locations.ts index 23b0f3b4..6dd364ec 100644 --- a/routes/locations.ts +++ b/routes/locations.ts @@ -1,19 +1,19 @@ import { db, g } from "$lib/db"; export default { - async list(_, res) { + async list(c) { const locations = await g("locations"); - res.send({ locations }); + return c.json({ locations }); }, - async nearby(req, res) { - const lat = parseFloat(req.query.lat); - const lon = parseFloat(req.query.lon); - const radius = parseFloat(req.query.radius) || 50; - const count = parseInt(req.query.count) || 50; + async nearby(c) { + const lat = parseFloat(c.req.query("lat")); + const lon = parseFloat(c.req.query("lon")); + const radius = parseFloat(c.req.query("radius")) || 50; + const count = parseInt(c.req.query("count")) || 50; if (isNaN(lat) || isNaN(lon)) { - return res.status(400).send({ error: "lat and lon required" }); + return c.json({ error: "lat and lon required" }, 400); } try { @@ -34,11 +34,11 @@ export default { if (loc) locations.push(loc); } - res.send({ locations }); + return c.json({ locations }); } catch (e) { console.log("nearby search failed", e); const locations = await g("locations"); - res.send({ locations }); + return c.json({ locations }); } }, }; -- cgit v1.2.3