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.
1.8 kB ยท 50 lines
TypeScript
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051import { Events } from "@openstatus/analytics";import { notifyMaintenance } from "@openstatus/services/maintenance";import { notifyStatusReport } from "@openstatus/services/status-report";import { z } from "zod";
import { toServiceCtx, toTRPCError } from "../service-adapter";import { createTRPCRouter, protectedProcedure } from "../trpc";
// Subscriber dispatch fans out across every channel (email + webhook), so it// must run on the lambda runtime: the email channel (Resend + react-email// render) can't run on Edge and would silently drop emails while webhooks// still go out. Kept off the statusReport/maintenance routers, which are// Edge-served โ see the `lambdas` list in the dashboard tRPC client.export const subscriberNotificationRouter = createTRPCRouter({ statusReport: protectedProcedure .meta({ track: Events.NotifyReport }) .input(z.object({ id: z.number() })) .mutation(async ({ ctx, input }) => { if (!ctx.workspace.limits["status-subscribers"]) { return { success: false }; } try { await notifyStatusReport({ ctx: toServiceCtx(ctx), input: { statusReportUpdateId: input.id }, }); return { success: true }; } catch (err) { toTRPCError(err); } }),
maintenance: protectedProcedure .meta({ track: Events.NotifyMaintenance }) .input(z.object({ id: z.number() })) .mutation(async ({ ctx, input }) => { if (!ctx.workspace.limits["status-subscribers"]) { return { success: false }; } try { await notifyMaintenance({ ctx: toServiceCtx(ctx), input: { maintenanceId: input.id }, }); return { success: true }; } catch (err) { toTRPCError(err); } }),});