feat: add calendar widget (#663)
* feat: add calendar widget * feat: add artifacts to gitignore
This commit is contained in:
20
packages/api/src/router/widgets/calendar.ts
Normal file
20
packages/api/src/router/widgets/calendar.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import type { CalendarEvent } from "@homarr/integrations/types";
|
||||
import { createItemWithIntegrationChannel } from "@homarr/redis";
|
||||
|
||||
import { createManyIntegrationOfOneItemMiddleware } from "../../middlewares/integration";
|
||||
import { createTRPCRouter, publicProcedure } from "../../trpc";
|
||||
|
||||
export const calendarRouter = createTRPCRouter({
|
||||
findAllEvents: publicProcedure
|
||||
.unstable_concat(createManyIntegrationOfOneItemMiddleware("sonarr", "radarr", "readarr", "lidarr"))
|
||||
.query(async ({ ctx }) => {
|
||||
return await Promise.all(
|
||||
ctx.integrations.flatMap(async (integration) => {
|
||||
for (const item of integration.items) {
|
||||
const cache = createItemWithIntegrationChannel<CalendarEvent[]>(item.itemId, integration.id);
|
||||
return await cache.getAsync();
|
||||
}
|
||||
}),
|
||||
);
|
||||
}),
|
||||
});
|
||||
@@ -1,5 +1,6 @@
|
||||
import { createTRPCRouter } from "../../trpc";
|
||||
import { appRouter } from "./app";
|
||||
import { calendarRouter } from "./calendar";
|
||||
import { dnsHoleRouter } from "./dns-hole";
|
||||
import { notebookRouter } from "./notebook";
|
||||
import { smartHomeRouter } from "./smart-home";
|
||||
@@ -11,4 +12,5 @@ export const widgetRouter = createTRPCRouter({
|
||||
app: appRouter,
|
||||
dnsHole: dnsHoleRouter,
|
||||
smartHome: smartHomeRouter,
|
||||
calendar: calendarRouter,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user