diff options
| author | Mohamed Bassem <me@mbassem.com> | 2025-07-12 22:48:29 +0000 |
|---|---|---|
| committer | Mohamed Bassem <me@mbassem.com> | 2025-07-12 22:48:29 +0000 |
| commit | 21076b83d82cee2794610360c1cb2cf222fa3973 (patch) | |
| tree | b3e8f1118e6cea99fbb7d4472f2716cef4acac6d | |
| parent | f4436e19992472436edba4ae3314254f3d25ce88 (diff) | |
| download | karakeep-21076b83d82cee2794610360c1cb2cf222fa3973.tar.zst | |
fix: Add ratelimiting to bookmark recrawl and summarization
| -rw-r--r-- | packages/trpc/routers/bookmarks.ts | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/packages/trpc/routers/bookmarks.ts b/packages/trpc/routers/bookmarks.ts index b6acadd6..9aa9ec1e 100644 --- a/packages/trpc/routers/bookmarks.ts +++ b/packages/trpc/routers/bookmarks.ts @@ -55,7 +55,7 @@ import { import { normalizeTagName } from "@karakeep/shared/utils/tag"; import type { AuthedContext, Context } from "../index"; -import { authedProcedure, router } from "../index"; +import { authedProcedure, createRateLimitMiddleware, router } from "../index"; import { mapDBAssetTypeToUserType } from "../lib/attachments"; import { getBookmarkIdsFromMatcher } from "../lib/search"; import { Bookmark } from "../models/bookmarks"; @@ -709,6 +709,13 @@ export const bookmarksAppRouter = router({ } }), recrawlBookmark: authedProcedure + .use( + createRateLimitMiddleware({ + name: "bookmarks.recrawlBookmark", + windowMs: 30 * 60 * 1000, + maxRequests: 200, + }), + ) .input( z.object({ bookmarkId: z.string(), @@ -1053,6 +1060,13 @@ export const bookmarksAppRouter = router({ }; }), summarizeBookmark: authedProcedure + .use( + createRateLimitMiddleware({ + name: "bookmarks.summarizeBookmark", + windowMs: 30 * 60 * 1000, + maxRequests: 100, + }), + ) .input( z.object({ bookmarkId: z.string(), |
