diff --git a/types/config.ts b/types/config.ts index e469f4f..4ae7aa6 100644 --- a/types/config.ts +++ b/types/config.ts @@ -46,7 +46,7 @@ export type MonitorTarget = { } export type WorkerConfig = { - kvWriteCooldownMinutes: number + kvWriteCooldownMinutes?: number passwordProtection?: string monitors: MonitorTarget[] notification?: Notification diff --git a/uptime.config.full.ts b/uptime.config.full.ts index 6c87255..682d358 100644 --- a/uptime.config.full.ts +++ b/uptime.config.full.ts @@ -27,7 +27,7 @@ const pageConfig: PageConfig = { } const workerConfig: WorkerConfig = { - // Write KV at most every 3 minutes unless the status changed + // [Optional] Write KV at most every N minutes unless the status changed, default to 3 kvWriteCooldownMinutes: 3, // Enable HTTP Basic auth for status page & API by uncommenting the line below, format `:` // passwordProtection: 'username:password', diff --git a/uptime.config.ts b/uptime.config.ts index 8c38bcc..85d7701 100644 --- a/uptime.config.ts +++ b/uptime.config.ts @@ -17,8 +17,6 @@ const pageConfig: PageConfig = { } const workerConfig: WorkerConfig = { - // Write KV at most every 3 minutes unless the status changed - kvWriteCooldownMinutes: 3, // Define all your monitors here monitors: [ // Example HTTP Monitor diff --git a/worker/src/index.ts b/worker/src/index.ts index ebadc72..9e2d741 100644 --- a/worker/src/index.ts +++ b/worker/src/index.ts @@ -331,7 +331,7 @@ const Worker = { // Allow for a cooldown period before writing to KV if ( statusChanged || - currentTimeSecond - state.lastUpdate >= workerConfig.kvWriteCooldownMinutes * 60 - 10 // Allow for 10 seconds of clock drift + currentTimeSecond - state.lastUpdate >= (workerConfig.kvWriteCooldownMinutes ?? 3) * 60 - 10 // Allow for 10 seconds of clock drift ) { console.log('Updating state...') state.lastUpdate = currentTimeSecond