mirror of
https://github.com/ajnart/homarr.git
synced 2026-02-28 09:21:00 +01:00
* fix: fetch timeout for external requests to small * fix: format issue * fix: move clear timeout for fetch to finally
16 lines
635 B
TypeScript
16 lines
635 B
TypeScript
import { fetchWithTimeout } from "@homarr/common";
|
|
import type { z } from "@homarr/validation";
|
|
import { validation } from "@homarr/validation";
|
|
|
|
import { createTRPCRouter, publicProcedure } from "../trpc";
|
|
|
|
export const locationRouter = createTRPCRouter({
|
|
searchCity: publicProcedure
|
|
.input(validation.location.searchCity.input)
|
|
.output(validation.location.searchCity.output)
|
|
.query(async ({ input }) => {
|
|
const res = await fetchWithTimeout(`https://geocoding-api.open-meteo.com/v1/search?name=${input.query}`);
|
|
return (await res.json()) as z.infer<typeof validation.location.searchCity.output>;
|
|
}),
|
|
});
|