Skip to content

Open-source status page, incident response and uptime monitoring

1.1 KB
Raw Blame
import type { SubscriptionChannel } from "../types";
import {
  sendEmailNotifications,
  sendEmailVerification,
  validateEmailConfig,
} from "./email";
import { sendSlackNotifications, validateSlackConfig } from "./slack";
import {
  sendWebhookNotifications,
  sendWebhookVerification,
  validateWebhookConfig,
} from "./webhook";

export function getChannel(channelType: string): SubscriptionChannel | null {
  switch (channelType) {
    case "email": {
      return {
        id: "email",
        sendNotifications: sendEmailNotifications,
        sendVerification: sendEmailVerification,
        validateConfig: validateEmailConfig,
      };
    }
    case "webhook": {
      return {
        id: "webhook",
        sendNotifications: sendWebhookNotifications,
        sendVerification: sendWebhookVerification,
        validateConfig: validateWebhookConfig,
      };
    }
    case "slack": {
      return {
        id: "slack",
        sendNotifications: sendSlackNotifications,
        validateConfig: validateSlackConfig,
      };
    }
    default:
      return null;
  }
}