// Operator convenience: force-refresh the in-memory Center admin cache // without waiting for the 1-day TTL. Used after `center user set-admin` // to make new admin visible immediately to triage delivery. // // Usage (inside the deployed container): // docker exec fabric-backend-guild node dist/cli/admin-refresh.js // // Prints the (possibly null) result as JSON. Exit 0 always — a "no // admin" outcome is a valid state, not an error. import 'reflect-metadata'; import { NestFactory } from '@nestjs/core'; import { AppModule } from '../app.module.js'; import { AdminCacheService } from '../common/admin-cache.service.js'; async function main() { const app = await NestFactory.createApplicationContext(AppModule, { logger: ['error', 'warn'] }); try { const cache = app.get(AdminCacheService); const before = cache.snapshot(); const after = await cache.get(true); process.stdout.write( JSON.stringify({ ok: true, before, after, changed: JSON.stringify(before) !== JSON.stringify(after), }) + '\n', ); } finally { await app.close(); } } void main().catch((error: unknown) => { const message = error instanceof Error ? error.message : 'unknown error'; process.stderr.write(JSON.stringify({ ok: false, error: message }) + '\n'); process.exit(1); });