1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
import { zValidator } from "@hono/zod-validator";
import { Hono } from "hono";
import { z } from "zod";
import serverConfig from "@karakeep/shared/config";
import { MAX_NUM_BOOKMARKS_PER_PAGE } from "@karakeep/shared/types/bookmarks";
import { List } from "@karakeep/trpc/models/lists";
import { unauthedMiddleware } from "../middlewares/auth";
import { toRSS } from "../utils/rss";
const app = new Hono().get(
"/lists/:listId",
zValidator(
"query",
z.object({
token: z.string().min(1),
limit: z.coerce
.number()
.min(1)
.max(MAX_NUM_BOOKMARKS_PER_PAGE)
.optional(),
}),
),
unauthedMiddleware,
async (c) => {
const listId = c.req.param("listId");
const searchParams = c.req.valid("query");
const token = searchParams.token;
const res = await List.getPublicListContents(c.var.ctx, listId, token, {
limit: searchParams.limit ?? 20,
order: "desc",
cursor: null,
});
const list = res.list;
const rssFeed = toRSS(
{
title: `Bookmarks from ${list.icon} ${list.name}`,
feedUrl: `${serverConfig.publicApiUrl}/v1/rss/lists/${listId}`,
siteUrl: `${serverConfig.publicUrl}/dashboard/lists/${listId}`,
description: list.description ?? undefined,
},
res.bookmarks,
);
c.header("Content-Type", "application/rss+xml");
return c.body(rssFeed);
},
);
export default app;
|