- app/api/route53/sync/route.ts: POST (requireAdmin, fire-and-forget) + GET (requireAuth, status/history) - app/api/route53/zones/route.ts: GET (requireAuth) list mirrored hosted zones - app/api/route53/zones/[zoneId]/records/route.ts: GET (requireAuth) list records with type/search filters - app/api/route53/zones/[zoneId]/records/[recordId]/history/route.ts: GET (requireAuth) append-only change ledger - None gated on integration_settings disable toggle (D-10 — route53 is not a PAX8-style exception) - /api/route53 confirmed absent from middleware.ts public-route list - tsc clean
52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
/**
|
|
* GET /api/route53/zones — list mirrored Route 53 hosted zones.
|
|
* requireAuth() gated.
|
|
*/
|
|
|
|
import { NextResponse } from 'next/server';
|
|
import { requireAuth } from '@/lib/auth-utils';
|
|
import postgresClient from '@/lib/services/postgres-client';
|
|
import type { Route53Zone } from '@/lib/types/route53';
|
|
|
|
interface ZoneRow {
|
|
id: string;
|
|
name: string;
|
|
comment: string | null;
|
|
private_zone: boolean;
|
|
record_count: number;
|
|
authoritative_name_servers: string[] | null;
|
|
synced_at: string;
|
|
}
|
|
|
|
export async function GET() {
|
|
const { error } = await requireAuth();
|
|
if (error) return error;
|
|
|
|
try {
|
|
const res = await postgresClient.query<ZoneRow>(
|
|
`SELECT id, name, comment, private_zone, record_count, authoritative_name_servers, synced_at
|
|
FROM route53_zones
|
|
WHERE is_deleted = false
|
|
ORDER BY name`
|
|
);
|
|
|
|
const zones: Route53Zone[] = res.rows.map((row) => ({
|
|
id: row.id,
|
|
name: row.name,
|
|
comment: row.comment,
|
|
privateZone: row.private_zone,
|
|
recordCount: row.record_count,
|
|
authoritativeNameServers: row.authoritative_name_servers,
|
|
syncedAt: row.synced_at,
|
|
isDeleted: false,
|
|
}));
|
|
|
|
return NextResponse.json({ items: zones });
|
|
} catch (err) {
|
|
console.error('[ROUTE53-ZONES] Failed to list zones:', err);
|
|
return NextResponse.json(
|
|
{ error: err instanceof Error ? err.message : 'Failed to fetch Route 53 zones' },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|