Files
remanso-jetstream/scripts/list-all-webhooks.ts
Julien Calixte 355fc45316 refactor(scripts): switch webhooks:all to api fetch
Hits GET /admin/webhooks instead of opening the local SQLite directly,
so the task can be run from a developer laptop without ssh or file
access to the server. Drops the FFI/read/write task permissions in
favour of net/env.
2026-05-05 14:07:31 +02:00

53 lines
1.6 KiB
TypeScript

// Admin: list every webhook subscription via the Remanso API. Requires the
// authenticated DID to be in the server-side ADMIN_DIDS allowlist.
//
// deno task webhooks:all
//
// Inputs (env or flag, env preferred):
// ATPROTO_HANDLE / --handle e.g. alice.eurosky.social
// ATPROTO_APP_PASSWORD / --app-password app password (NOT your account password)
// REMANSO_API / --api default: https://api.remanso.space
const HELP = `
Usage:
deno task webhooks:all
Inputs (env or flag, env preferred):
ATPROTO_HANDLE / --handle your AT Protocol handle
ATPROTO_APP_PASSWORD / --app-password app password (NOT your account password)
REMANSO_API / --api default: https://api.remanso.space
`;
import { parseArgs, sessionFromFlagsOrEnv } from "./_atproto-session.ts";
const die = (msg: string): never => {
console.error(`error: ${msg}`);
console.error(HELP);
Deno.exit(1);
};
const main = async () => {
const flags = parseArgs(Deno.args);
if (flags.help === "true" || flags.h === "true") {
console.log(HELP);
Deno.exit(0);
}
const { session, api } = await sessionFromFlagsOrEnv(flags).catch(
(e: Error) => die(e.message),
);
const res = await fetch(`${api}/admin/webhooks`, {
headers: { "Authorization": `Bearer ${session.accessJwt}` },
});
if (!res.ok) {
console.error(`list-all failed (${res.status}): ${await res.text()}`);
Deno.exit(1);
}
const rows = await res.json();
console.log(JSON.stringify(rows, null, 2));
console.error(`[done] ${rows.length} subscription(s) at ${api}`);
};
await main();