add support heartbeat to couchdb-changes-stream

This commit is contained in:
2024-11-29 12:38:08 +02:00
parent a393a195d0
commit 9cc03623d9
27 changed files with 8998 additions and 8531 deletions
@@ -3,10 +3,10 @@ import { serverSettingsDb } from "./dbs";
import { ServerSettingsDocument } from "@hereconnect/types";
function isType<N extends ServerSettingsDocument["name"]>(
doc: ServerSettingsDocument,
doc: ServerSettingsDocument | null | undefined,
name: N,
): doc is ServerSettingsDocument & { name: N } {
return doc.name === name;
return !!(doc && doc.name === name);
}
export const setupVapidDetails = async () => {
@@ -53,9 +53,10 @@ export const setupVapidDetails = async () => {
);
changes.on("change", (change) => {
if (!("doc" in change)) {
if (!change.doc) {
return;
}
if (isType(change.doc, "message_delivery_method_web_push_vapid")) {
console.log("update vapid details");
webpush.setVapidDetails(