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

Function requireWriteKey

app/src/server/api/external/v1Api/helpers.ts:6–24  ·  view source on GitHub ↗
(ctx: TRPCContext)

Source from the content-addressed store, hash-verified

4import { type TRPCContext } from "../openApiTrpc";
5
6export const requireWriteKey = async (ctx: TRPCContext) => {
7 if (!ctx.key)
8 throw new TRPCError({
9 code: "UNAUTHORIZED",
10 message: "You must provide an API key to call this operation",
11 });
12
13 if (ctx.key?.readOnly) {
14 const project = await prisma.project.findUniqueOrThrow({
15 where: { id: ctx.key.projectId },
16 select: { slug: true },
17 });
18
19 throw new TRPCError({
20 code: "UNAUTHORIZED",
21 message: `You are trying to call a write operation with a read-only API key. Please view your project settings at ${env.NEXT_PUBLIC_HOST}/p/${project.slug}/settings and choose the "Read/Write" key.`,
22 });
23 }
24};

Calls

no outgoing calls

Tested by

no test coverage detected