lecheminvert.tech/server/api/geocode.get.ts

11 lines
333 B
TypeScript
Raw Normal View History

import { z } from 'zod'
import type { Place } from '#shared/types'
const QuerySchema = z.object({ q: z.string().min(3).max(200) })
export default defineEventHandler(async (event): Promise<Place[]> => {
const parsed = QuerySchema.safeParse(getQuery(event))
if (!parsed.success) return []
return searchPlaces(parsed.data.q)
})