1010 * Rate-limit keying is based on the authenticated stellar address populated by
1111 * `requireAuth`, so quota is tracked independently per user, not per IP.
1212 *
13+ * All routes are wrapped by `accessLog` which:
14+ * - Resolves a correlation ID via the priority chain (header → req.id → UUID)
15+ * - Echoes it back in the `X-Correlation-Id` response header
16+ * - Emits a structured `webhooks_access_log` entry on every response finish.
17+ *
1318 * Endpoints:
1419 * GET / — list webhook subscriptions
1520 * POST / — create a new webhook subscription
2429import { Router } from "express" ;
2530import { logger } from "../config/logger" ;
2631import { getRequestId } from "../lib/requestContext" ;
32+ import { accessLog } from "../middleware/accessLog" ;
2733import { webhookCors } from "../middleware/cors" ;
2834import { requireAdmin } from "../middleware/requireAdmin" ;
2935import { webhooksRateLimiter } from "../middleware/rateLimit" ;
@@ -38,6 +44,11 @@ import { webhooksRateLimiter } from "../middleware/rateLimit";
3844
3945export const webhooksRouter = Router ( ) ;
4046
47+ // Structured access log — resolves correlation ID, echoes it back, and
48+ // emits a webhooks_access_log entry on every response finish.
49+ // Mounted first so the correlation ID is available to all downstream handlers.
50+ webhooksRouter . use ( accessLog ) ;
51+
4152// Enforce CORS allowlist before admin auth so unapproved origins are
4253// rejected early without leaking auth challenge details.
4354webhooksRouter . use ( webhookCors ( ) ) ;
0 commit comments