Skip to the content

Capsid menu

app/lib/webmention/queue.ts

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

Functions

The functions of queue.ts
FunctionLinesComplexityCoveredCRAPMutation
readVerifyMessage11 to 189No 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/webmention.ts, workers/app.ts, workers/webmention-verify.ts.

Source

/**
 * The one message the webmention route sends and the queue consumer reads. The queue name is here so
 * `queue()` routes a batch by it; the binding and its consumer settings are in wrangler.jsonc.
 */

export const WEBMENTION_VERIFY_QUEUE = "dustinedwards-webmention-verify";

export type WebmentionVerifyMessage = { id: number; source: string; target: string };

/** Null for anything else: a message is acked and dropped rather than retried on a shape it will never change. */
export function readVerifyMessage(body: unknown): WebmentionVerifyMessage | null {
  if (typeof body !== "object" || body === null) return null;
  const { id, source, target } = body as Record<string, unknown>;
  if (typeof id !== "number" || !Number.isInteger(id)) return null;
  if (typeof source !== "string" || source.length === 0) return null;
  if (typeof target !== "string" || target.length === 0) return null;
  return { id, source, target };
}