aboutsummaryrefslogtreecommitdiffstats
path: root/packages/trpc/routers/lists.ts
diff options
context:
space:
mode:
authorMohamed Bassem <me@mbassem.com>2025-05-31 18:46:04 +0100
committerGitHub <noreply@github.com>2025-05-31 18:46:04 +0100
commit9695bba2e993b48ae333da622fa459dbaacb9349 (patch)
treec6bffbcdd73151671343f27012e82bea5a05ab6b /packages/trpc/routers/lists.ts
parentb218118b84291de4a9c1cd400dc58afab7054b78 (diff)
downloadkarakeep-9695bba2e993b48ae333da622fa459dbaacb9349.tar.zst
feat: Generate RSS feeds from lists (#1507)
* refactor: Move bookmark utils from shared-react to shared * Expose RSS feeds for lists * Add e2e tests * Slightly improve the look of the share dialog * allow specifying a limit in the rss endpoint
Diffstat (limited to 'packages/trpc/routers/lists.ts')
-rw-r--r--packages/trpc/routers/lists.ts43
1 files changed, 43 insertions, 0 deletions
diff --git a/packages/trpc/routers/lists.ts b/packages/trpc/routers/lists.ts
index 65cffd2d..bb949962 100644
--- a/packages/trpc/routers/lists.ts
+++ b/packages/trpc/routers/lists.ts
@@ -131,4 +131,47 @@ export const listsAppRouter = router({
const sizes = await Promise.all(lists.map((l) => l.getSize()));
return { stats: new Map(lists.map((l, i) => [l.list.id, sizes[i]])) };
}),
+
+ // Rss endpoints
+ regenRssToken: authedProcedure
+ .input(
+ z.object({
+ listId: z.string(),
+ }),
+ )
+ .output(
+ z.object({
+ token: z.string(),
+ }),
+ )
+ .mutation(async ({ input, ctx }) => {
+ const list = await List.fromId(ctx, input.listId);
+ const token = await list.regenRssToken();
+ return { token: token! };
+ }),
+ clearRssToken: authedProcedure
+ .input(
+ z.object({
+ listId: z.string(),
+ }),
+ )
+ .mutation(async ({ input, ctx }) => {
+ const list = await List.fromId(ctx, input.listId);
+ await list.clearRssToken();
+ }),
+ getRssToken: authedProcedure
+ .input(
+ z.object({
+ listId: z.string(),
+ }),
+ )
+ .output(
+ z.object({
+ token: z.string().nullable(),
+ }),
+ )
+ .query(async ({ input, ctx }) => {
+ const list = await List.fromId(ctx, input.listId);
+ return { token: await list.getRssToken() };
+ }),
});