Skip to content

Open-source status page, incident response and uptime monitoring

1.2 KB
Raw Blame
import type { Monitor, Notification } from "@openstatus/db/src/schema";

import { sendAlert, sendDegraded, sendRecovery } from "./index";

const monitor: Monitor = {
  id: 1,
  name: "OpenStatus Docs",
  url: "https://www.openstatus.dev/docs",
  periodicity: "10m",
  jobType: "http",
  active: true,
  public: true,
  createdAt: null,
  updatedAt: null,
  regions: ["ams", "fra"],
  description: "Monitor Description",
  headers: [],
  body: "",
  workspaceId: 1,
  timeout: 45000,
  degradedAfter: null,
  assertions: null,
  status: "active",
  method: "GET",
  deletedAt: null,
  otelEndpoint: null,
  otelHeaders: [],
  followRedirects: false,
  retry: 3,
  externalName: null,
  grpcService: null,
  grpcTls: null,
};

const notification: Notification = {
  id: 1,
  name: "Email",
  data: '{ "email": "[email protected]" }',
  createdAt: null,
  updatedAt: null,
  workspaceId: 1,
  provider: "email",
};

const cronTimestamp = Date.now();

if (process.env.NODE_ENV === "development") {
  await sendDegraded({
    monitor,
    notification,
    cronTimestamp,
  });

  await sendAlert({
    monitor,
    notification,
    statusCode: 500,
    cronTimestamp,
  });

  await sendRecovery({
    monitor,
    notification,
    cronTimestamp,
  });
}