aboutsummaryrefslogtreecommitdiffstats
path: root/apps/workers/trpc.ts
diff options
context:
space:
mode:
Diffstat (limited to 'apps/workers/trpc.ts')
-rw-r--r--apps/workers/trpc.ts34
1 files changed, 3 insertions, 31 deletions
diff --git a/apps/workers/trpc.ts b/apps/workers/trpc.ts
index c5f880ad..28cd2d0b 100644
--- a/apps/workers/trpc.ts
+++ b/apps/workers/trpc.ts
@@ -1,36 +1,8 @@
-import { eq } from "drizzle-orm";
-
-import { db } from "@karakeep/db";
-import { users } from "@karakeep/db/schema";
-import { AuthedContext, createCallerFactory } from "@karakeep/trpc";
+import { createCallerFactory } from "@karakeep/trpc";
+import { buildImpersonatingAuthedContext as buildAuthedContext } from "@karakeep/trpc/lib/impersonate";
import { appRouter } from "@karakeep/trpc/routers/_app";
-/**
- * This is only safe to use in the context of a worker.
- */
-export async function buildImpersonatingAuthedContext(
- userId: string,
-): Promise<AuthedContext> {
- const user = await db.query.users.findFirst({
- where: eq(users.id, userId),
- });
- if (!user) {
- throw new Error("User not found");
- }
-
- return {
- user: {
- id: user.id,
- name: user.name,
- email: user.email,
- role: user.role,
- },
- db,
- req: {
- ip: null,
- },
- };
-}
+export const buildImpersonatingAuthedContext = buildAuthedContext;
/**
* This is only safe to use in the context of a worker.