* feat: add nestjs replacement, remove nestjs * feat: add weather widget * fix: lock issue * fix: format issue * fix: deepsource issues * fix: change timezone to auto
16 lines
611 B
TypeScript
16 lines
611 B
TypeScript
import { validation } from "@homarr/validation";
|
|
|
|
import { createTRPCRouter, publicProcedure } from "../../trpc";
|
|
|
|
export const weatherRouter = createTRPCRouter({
|
|
atLocation: publicProcedure
|
|
.input(validation.widget.weather.atLocationInput)
|
|
.output(validation.widget.weather.atLocationOutput)
|
|
.query(async ({ input }) => {
|
|
const res = await fetch(
|
|
`https://api.open-meteo.com/v1/forecast?latitude=${input.latitude}&longitude=${input.longitude}&daily=weathercode,temperature_2m_max,temperature_2m_min¤t_weather=true&timezone=auto`,
|
|
);
|
|
return res.json();
|
|
}),
|
|
});
|