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.
TypeScript
12345678910111213141516171819202122232425262728293031323334353637383940414243import { createInsertSchema, createSelectSchema } from "drizzle-zod";import { z } from "zod";
import { apiKey } from "./api_key";import { apiKeyScopes, apiKeySettableScopes } from "./constants";
// Internal scope schema: includes '*' for the super-admin / dev-fallback// path. Auth middleware reads raw rows and needs the full enum.const internalScopesSchema = z .array(z.enum(apiKeyScopes)) .min(1) .default(["write"]);
// Public scope schema: drops '*' so it can never ride in on the wire.// Used by create-key input and any output schema that crosses a trust// boundary.export const publicScopesSchema = z .array(z.enum(apiKeySettableScopes)) .min(1) .default(["write"]);
export const insertApiKeySchema = createInsertSchema(apiKey, { name: z.string().min(1, "Name is required"), description: z.string().optional(), expiresAt: z.date().optional(), scopes: internalScopesSchema,});
export const selectApiKeySchema = createSelectSchema(apiKey, { scopes: internalScopesSchema,});
export const createApiKeySchema = z.object({ name: z.string().min(1, "Name is required"), description: z.string().optional(), expiresAt: z.date().optional(), scopes: publicScopesSchema,});
export type InsertApiKey = z.infer<typeof insertApiKeySchema>;export type ApiKey = z.infer<typeof selectApiKeySchema>;export type CreateApiKeyInput = z.infer<typeof createApiKeySchema>;