gitflarePublicPartly agent-ready50
cf-d1-queues-pulse
Event analytics on Cloudflare D1 and Queues: ingestion API, batched consumer, rollups, live dashboard, load generator, dead-letter view.
- LicenseApache-2.0
- LanguageTypeScript
- Last landed
8a65841Oct 20, 2026
Build the full D1 + Queues pulse app: dashboard, load generator, dead letters, percentiles, docs
8a65841import {esc} from "./lib.js";export const dlqShell=()=>`<h1>Dead letters</h1><div class="row"><button id="rall">Replay all</button><button id="purge" class="danger">Purge</button><span class="sub" id="dst" role="status" aria-live="polite"></span></div><div id="dl" style="margin-top:16px"><div class="sk"></div></div>`;export async function wireDlq(confirmFn){const $=i=>document.getElementById(i); const st=t=>{if($("dst"))$("dst").textContent=t;}; async function load(){try{const r=await fetch("/api/dlq");if(!r.ok)throw 0;const j=await r.json();const items=Array.isArray(j)?j:(j.items||j.deadLetters||[]); $("dl").innerHTML=items.length?`<div class="tablewrap" tabindex="0"><table><thead><tr><th>Error</th><th>Attempts</th><th>Body</th><th></th></tr></thead><tbody>${items.map(i=>`<tr><td>${esc(i.error)}</td><td>${esc(i.attempts)}</td><td><code>${esc(typeof i.body==="string"?i.body:JSON.stringify(i.body))}</code></td><td><button data-id="${esc(i.id)}">Replay</button></td></tr>`).join("")}</tbody></table></div>`:'<p class="msg">No dead letters. Poisoned events land here after 3 retries.</p>'; $("dl").querySelectorAll("button[data-id]").forEach(b=>b.onclick=()=>replay({id:b.dataset.id})); }catch{$("dl").innerHTML='<p class="msg err" role="alert">Could not load dead letters.</p>';}} async function replay(body){st("Replaying…");try{const r=await fetch("/api/dlq/replay",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(body)});st(r.ok?"Replayed.":"Replay failed.");}catch{st("Replay failed.");}load();} $("rall").onclick=()=>replay({}); $("purge").onclick=async()=>{if(!await confirmFn("Permanently delete all dead letters?"))return;try{const r=await fetch("/api/dlq",{method:"DELETE"});st(r.ok?"Purged.":"Purge failed.");}catch{st("Purge failed.");}load();}; load();}