Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. ๐ซ Status page with uptime monitoring & API monitoring as code ๐ซ openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
774 B ยท 22 lines
TypeScript
1234567891011121314151617181920212223export type Credential = { token: string; source: "x-openstatus-key" | "bearer";};
export const MISSING_CREDENTIALS_MESSAGE = "Missing credentials: send an 'x-openstatus-key' header or 'Authorization: Bearer <token>'";
/** `x-openstatus-key` wins over `Authorization: Bearer`; both surfaces share this order. */export function extractCredential(headers: { get(name: string): string | null | undefined;}): Credential | null { const key = headers.get("x-openstatus-key"); if (key) return { token: key, source: "x-openstatus-key" };
const authorization = headers.get("authorization"); if (authorization) { const match = /^Bearer\s+(\S+)\s*$/i.exec(authorization); if (match?.[1]) return { token: match[1], source: "bearer" }; } return null;}