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:
Meier Lukas
2024-04-13 11:34:55 +02:00
committed by GitHub
parent 7fb0decd5b
commit 80d2d485b8
19 changed files with 762 additions and 13 deletions

View File

@@ -0,0 +1,6 @@
import { createTRPCRouter } from "../../trpc";
import { weatherRouter } from "./weather";
export const widgetRouter = createTRPCRouter({
weather: weatherRouter,
});

View File

@@ -0,0 +1,15 @@
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&current_weather=true&timezone=auto`,
);
return res.json();
}),
});