* refactor: move zod import from validation package to zod * refactor: move missing zod imports
26 lines
1.1 KiB
TypeScript
26 lines
1.1 KiB
TypeScript
import { z } from "zod";
|
|
|
|
import { getIntegrationKindsByCategory } from "@homarr/definitions";
|
|
import { radarrReleaseTypes } from "@homarr/integrations/types";
|
|
import { calendarMonthRequestHandler } from "@homarr/request-handler/calendar";
|
|
|
|
import { createManyIntegrationMiddleware } from "../../middlewares/integration";
|
|
import { createTRPCRouter, publicProcedure } from "../../trpc";
|
|
|
|
export const calendarRouter = createTRPCRouter({
|
|
findAllEvents: publicProcedure
|
|
.input(z.object({ year: z.number(), month: z.number(), releaseType: z.array(z.enum(radarrReleaseTypes)) }))
|
|
.unstable_concat(createManyIntegrationMiddleware("query", ...getIntegrationKindsByCategory("calendar")))
|
|
.query(async ({ ctx, input }) => {
|
|
const results = await Promise.all(
|
|
ctx.integrations.map(async (integration) => {
|
|
const innerHandler = calendarMonthRequestHandler.handler(integration, input);
|
|
const { data } = await innerHandler.getCachedOrUpdatedDataAsync({ forceUpdate: false });
|
|
|
|
return data;
|
|
}),
|
|
);
|
|
return results.flat();
|
|
}),
|
|
});
|