Implement Debug backend which prints the notification to stdout

This commit is contained in:
2025-02-25 15:52:37 +01:00
parent c86fb95d90
commit 0b3fda4beb
2 changed files with 19 additions and 2 deletions

15
src/backend/debug.ts Normal file
View File

@@ -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<Config> {
public name = "debug";
protected requiredFields = [] as const;
protected notify(config: Config, notification: Notification): void {
console.log(JSON.stringify(notification, undefined, 2));
}
}

View File

@@ -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) {
console.info(`Dispatching a notification: [${notification.text}]`)
for (const backend of backends) {
console.info(`Dispatching a notification: [${notification.text}]`)
backend.remind(config, notification);
await snooze(1500);
}