MCPcopy Create free account
hub / github.com/OpenPipe/OpenPipe / createOpenApiContext

Function createOpenApiContext

app/src/server/api/external/openApiTrpc.ts:44–65  ·  view source on GitHub ↗
(opts: CreateNextContextOptions)

Source from the content-addressed store, hash-verified

42};
43
44export const createOpenApiContext = async (opts: CreateNextContextOptions) => {
45 const { req, res } = opts;
46
47 const apiKey = req.headers.authorization?.split(" ")[1] as string | null;
48
49 if (!apiKey) {
50 throw new TRPCError({ code: "UNAUTHORIZED" });
51 }
52 const key = await prisma.apiKey.findFirst({
53 where: { apiKey },
54 include: { project: true },
55 });
56 if (!key) {
57 throw new TRPCError({ code: "UNAUTHORIZED" });
58 }
59
60 return createInnerTRPCContext({
61 key,
62 headers: req.headers,
63 res,
64 });
65};
66
67export type TRPCContext = Awaited<ReturnType<typeof createOpenApiContext>>;
68

Callers

nothing calls this directly

Calls 1

createInnerTRPCContextFunction · 0.70

Tested by

no test coverage detected