aboutsummaryrefslogtreecommitdiffstats
path: root/apps/workers/trpc.ts
blob: 28cd2d0b98b534b44d7205ecd2f280fade97c993 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { createCallerFactory } from "@karakeep/trpc";
import { buildImpersonatingAuthedContext as buildAuthedContext } from "@karakeep/trpc/lib/impersonate";
import { appRouter } from "@karakeep/trpc/routers/_app";

export const buildImpersonatingAuthedContext = buildAuthedContext;

/**
 * This is only safe to use in the context of a worker.
 */
export async function buildImpersonatingTRPCClient(userId: string) {
  const createCaller = createCallerFactory(appRouter);

  return createCaller(await buildImpersonatingAuthedContext(userId));
}