feat: add weather widget (#286)
* feat: add nestjs replacement, remove nestjs * feat: add weather widget * fix: lock issue * fix: format issue * fix: deepsource issues * fix: change timezone to auto
This commit is contained in:
18
packages/api/src/router/location.ts
Normal file
18
packages/api/src/router/location.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
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 fetch(
|
||||
`https://geocoding-api.open-meteo.com/v1/search?name=${input.query}`,
|
||||
);
|
||||
return (await res.json()) as z.infer<
|
||||
typeof validation.location.searchCity.output
|
||||
>;
|
||||
}),
|
||||
});
|
||||
Reference in New Issue
Block a user