Openstatus www.openstatus.dev
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 70 lines 1.3 kB view raw
1import type { Monitor, Notification } from "@openstatus/db/src/schema"; 2import { 3 sendAlert, 4 sendDegraded, 5 sendRecovery, 6 sendTestSlackMessage, 7} from "./index"; 8 9const monitor: Monitor = { 10 id: 1, 11 name: "OpenStatus Docs", 12 url: "https://docs.openstatus.dev", 13 periodicity: "10m", 14 jobType: "http", 15 active: true, 16 public: true, 17 createdAt: null, 18 updatedAt: null, 19 regions: ["ams", "fra"], 20 description: "Monitor Description", 21 headers: [], 22 body: "", 23 workspaceId: 1, 24 timeout: 45000, 25 degradedAfter: null, 26 assertions: null, 27 status: "active", 28 method: "GET", 29 deletedAt: null, 30 otelEndpoint: null, 31 otelHeaders: [], 32 retry: 3, 33 followRedirects: false, 34 externalName: null, 35}; 36 37const notification: Notification = { 38 id: 1, 39 name: "Slack", 40 data: `{ "slack": "${process.env.SLACK_WEBHOOK}" }`, 41 createdAt: null, 42 updatedAt: null, 43 workspaceId: 1, 44 provider: "slack", 45}; 46 47const cronTimestamp = Date.now(); 48 49if (process.env.NODE_ENV === "development") { 50 await sendDegraded({ 51 monitor, 52 notification, 53 cronTimestamp, 54 }); 55 56 await sendAlert({ 57 monitor, 58 notification, 59 statusCode: 500, 60 cronTimestamp, 61 }); 62 63 await sendRecovery({ 64 monitor, 65 notification, 66 cronTimestamp, 67 }); 68 69 await sendTestSlackMessage(`${process.env.SLACK_WEBHOOK}`); 70}