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 { NotificationDatabase } from "../types/notification";
|
||||||
import { Config } from "../types/config";
|
import { Config } from "../types/config";
|
||||||
import { NtfySH } from "./ntfy";
|
import { NtfySH } from "./ntfy";
|
||||||
|
import { Debug } from "./debug";
|
||||||
|
|
||||||
const backends = [
|
const backends = [
|
||||||
|
new Debug(),
|
||||||
new NtfySH()
|
new NtfySH()
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -16,8 +18,8 @@ export async function remind(config: Config, db: NotificationDatabase) {
|
|||||||
const notifications = db[now] ?? [];
|
const notifications = db[now] ?? [];
|
||||||
|
|
||||||
for (const notification of notifications) {
|
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);
|
backend.remind(config, notification);
|
||||||
await snooze(1500);
|
await snooze(1500);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user