diff --git a/src/backend/debug.ts b/src/backend/debug.ts new file mode 100644 index 0000000..98f8fb0 --- /dev/null +++ b/src/backend/debug.ts @@ -0,0 +1,15 @@ +import { BackendSettings } from "../types/config"; +import { Notification } from "../types/notification"; +import { Backend } from "./base"; + +type Config = BackendSettings; + +export class Debug extends Backend { + public name = "debug"; + + protected requiredFields = [] as const; + + protected notify(config: Config, notification: Notification): void { + console.log(JSON.stringify(notification, undefined, 2)); + } +} \ No newline at end of file diff --git a/src/backend/index.ts b/src/backend/index.ts index c51959d..4dd3d42 100644 --- a/src/backend/index.ts +++ b/src/backend/index.ts @@ -2,8 +2,10 @@ import dayjs from "dayjs"; import { NotificationDatabase } from "../types/notification"; import { Config } from "../types/config"; import { NtfySH } from "./ntfy"; +import { Debug } from "./debug"; const backends = [ + new Debug(), new NtfySH() ]; @@ -16,8 +18,8 @@ export async function remind(config: Config, db: NotificationDatabase) { const notifications = db[now] ?? []; for (const notification of notifications) { - for (const backend of backends) { - console.info(`Dispatching a notification: [${notification.text}]`) + console.info(`Dispatching a notification: [${notification.text}]`) + for (const backend of backends) { backend.remind(config, notification); await snooze(1500); }