add support heartbeat to couchdb-changes-stream
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user