aboutsummaryrefslogtreecommitdiffstats
path: root/routes/locations.ts
diff options
context:
space:
mode:
Diffstat (limited to 'routes/locations.ts')
-rw-r--r--routes/locations.ts20
1 files changed, 10 insertions, 10 deletions
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 });
}
},
};