Implement Debug backend which prints the notification to stdout
This commit is contained in:
15
src/backend/debug.ts
Normal file
15
src/backend/debug.ts
Normal 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));
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user