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.
773 B ยท 27 lines
TypeScript
at apifix
12345678910111213141516171819202122232425262728import { type Workspace, workspacePlanHierarchy,} from "@openstatus/db/src/schema";import type { Context, Next } from "hono";
import type { Variables } from "@/types";
import { OpenStatusApiError } from "../errors";
/** * Checks if the workspace has a minimum required plan to access the endpoint */export function minPlanMiddleware({ plan }: { plan: Workspace["plan"] }) { return async (c: Context<{ Variables: Variables }, "/*">, next: Next) => { const workspace = c.get("workspace");
if (workspacePlanHierarchy[workspace.plan] < workspacePlanHierarchy[plan]) { throw new OpenStatusApiError({ code: "PAYMENT_REQUIRED", message: "You need to upgrade your plan to access this feature", }); }
await next(); };}