14 lines
393 B
TypeScript
14 lines
393 B
TypeScript
import type { APIRoute } from "astro";
|
|
import { getDb } from "./db";
|
|
|
|
type CityRow = { city: string };
|
|
|
|
export const GET: APIRoute = async () => {
|
|
const db = getDb();
|
|
const rows = db.prepare("SELECT DISTINCT city FROM ranges ORDER BY city").all() as CityRow[];
|
|
|
|
return new Response(JSON.stringify(rows.map((x) => x.city)), {
|
|
headers: { "Content-Type": "application/json" },
|
|
});
|
|
};
|