(opts: CreateNextContextOptions)
| 11 | const Sentry = ensureDefaultExport(SentryModule); |
| 12 | |
| 13 | export const createOpenApiContext = (opts: CreateNextContextOptions) => { |
| 14 | const { req } = opts; |
| 15 | |
| 16 | const authenticatedSystemKey = req.headers.authorization?.split(" ")[1] as string | null; |
| 17 | |
| 18 | if (!authenticatedSystemKey) { |
| 19 | throw new TRPCError({ code: "UNAUTHORIZED", message: "Missing System Key" }); |
| 20 | } |
| 21 | |
| 22 | if (authenticatedSystemKey !== env.AUTHENTICATED_SYSTEM_KEY) { |
| 23 | throw new TRPCError({ code: "UNAUTHORIZED", message: "Invalid System Key" }); |
| 24 | } |
| 25 | |
| 26 | return {}; |
| 27 | }; |
| 28 | |
| 29 | export type TRPCContext = Awaited<ReturnType<typeof createOpenApiContext>>; |
| 30 |
nothing calls this directly
no outgoing calls
no test coverage detected