Skip to the content

Capsid menu

app/lib/backup/age.server.ts

13 lines and 1 functions in DrDustinEdwards/dustinedwards-info, at commit 1590ba4 on 2026-10-24. This file on GitHub.

Functions

The functions of age.server.ts
FunctionLinesComplexityCoveredCRAPMutation
backupAge8 to 143No data: no coverage report in this mapNo data: no coverage report in this mapNo data: no mutants in this code

Imports

It imports no other module of this repo. Imported by app/routes/api.health.ts.

Source

import { backupHealth } from "@dustinedwards/d1-dump";

/**
 * The newest complete D1 dump's time and age, for the public health body. Never throws, and drops
 * backupHealth's warning text: an unreadable bucket reads as nulls, which is the answer a caller
 * needs, and the cause is logged by name instead of going on the wire.
 */
export async function backupAge(env: Pick<Env, "BACKUPS">): Promise<{ last_ok: string | null; age_hours: number | null }> {
  const health = await backupHealth(env.BACKUPS);
  if (health.warning && health.last_ok === null) {
    console.error(JSON.stringify({ alert: "backup-age-unreadable", warning: health.warning }));
  }
  return { last_ok: health.last_ok, age_hours: health.age_hours };
}