aboutsummaryrefslogtreecommitdiffstats
path: root/packages/api/middlewares
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/api/middlewares
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/api/middlewares')
-rw-r--r--packages/api/middlewares/auth.ts17
1 files changed, 16 insertions, 1 deletions
diff --git a/packages/api/middlewares/auth.ts b/packages/api/middlewares/auth.ts
index 7f39a6f9..42bca6c8 100644
--- a/packages/api/middlewares/auth.ts
+++ b/packages/api/middlewares/auth.ts
@@ -1,11 +1,26 @@
import { createMiddleware } from "hono/factory";
import { HTTPException } from "hono/http-exception";
-import { AuthedContext, createCallerFactory } from "@karakeep/trpc";
+import { AuthedContext, Context, createCallerFactory } from "@karakeep/trpc";
import { appRouter } from "@karakeep/trpc/routers/_app";
const createCaller = createCallerFactory(appRouter);
+export const unauthedMiddleware = createMiddleware<{
+ Variables: {
+ ctx: Context;
+ api: ReturnType<typeof createCaller>;
+ };
+}>(async (c, next) => {
+ if (!c.var.ctx) {
+ throw new HTTPException(401, {
+ message: "Unauthorized",
+ });
+ }
+ c.set("api", createCaller(c.get("ctx")));
+ await next();
+});
+
export const authMiddleware = createMiddleware<{
Variables: {
ctx: AuthedContext;