feat: add rss widget (#760)

Co-authored-by: SeDemal <demal.sebastien@bluewin.ch>
This commit is contained in:
Manuel
2024-07-27 18:11:29 +02:00
committed by GitHub
parent 4380aa9b3e
commit 15d9327d46
23 changed files with 528 additions and 11 deletions

View File

@@ -0,0 +1,29 @@
import { TRPCError } from "@trpc/server";
import { and, eq } from "@homarr/db";
import { items } from "@homarr/db/schema/sqlite";
import type { WidgetKind } from "@homarr/definitions";
import { z } from "@homarr/validation";
import { publicProcedure } from "../trpc";
export const createOneItemMiddleware = (kind: WidgetKind) => {
return publicProcedure.input(z.object({ itemId: z.string() })).use(async ({ input, ctx, next }) => {
const item = await ctx.db.query.items.findFirst({
where: and(eq(items.id, input.itemId), eq(items.kind, kind)),
});
if (!item) {
throw new TRPCError({
code: "NOT_FOUND",
message: `Item with id ${input.itemId} not found`,
});
}
return next({
ctx: {
item,
},
});
});
};