Skip to content

feat: add correlation-id propagation on /api/logs handlers - #1034

Merged
greatest0fallt1me merged 3 commits into
CalloraOrg:mainfrom
Faree-code:fix/issue-917-correlation-logs
Jul 29, 2026
Merged

feat: add correlation-id propagation on /api/logs handlers#1034
greatest0fallt1me merged 3 commits into
CalloraOrg:mainfrom
Faree-code:fix/issue-917-correlation-logs

Conversation

@Faree-code

Copy link
Copy Markdown

Overview

This PR creates a new /api/logs router that applies correlationMiddleware to all routes, ensuring the X-Correlation-Id header is propagated through every log handler and any outbound calls they make. The router is mounted at /api/logs in the main Express app.

Related Issue

Closes #917

Changes

  • [ADD] src/routes/logs.ts

    • GET /api/logs — lists audit log entries for the authenticated developer (max 50), includes correlationId in response
    • GET /api/logs/:id — fetches a single log entry by ID, owned by the authenticated developer (cross-user access returns 404)
    • Both routes apply correlationMiddleware for X-Correlation-Id propagation and requireAuth for authentication
    • Dependency injection via LogsRouterDeps interface for testability
  • [MODIFY] src/app.ts

    • Imported createLogsRouter and mounted at /api/logs

Verification Results

npx jest --no-coverage src/middleware/correlation.test.ts
✅ 27/27 passed

npx tsc --noEmit
✅ No compilation errors
Acceptance Criteria Status
X-Correlation-Id propagated through /api/logs correlationMiddleware applied router-wide
GET /api/logs returns audit entries ✅ Backed by PgAuditLogRepository
GET /api/logs/:id returns single entry ✅ With ownership check (404 for cross-user)
Existing correlation tests still pass ✅ 27/27 passing
TypeScript compilation ✅ No errors

Create a new /api/logs router that applies correlationMiddleware to all
routes, ensuring X-Correlation-Id is propagated through log handlers and
outbound calls. Includes GET /api/logs and GET /api/logs/:id endpoints
backed by the PgAuditLogRepository.

Closes CalloraOrg#917
@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@Faree-code Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@greatest0fallt1me

Copy link
Copy Markdown
Contributor

Merged into main via admin resolver (-X theirs).

@greatest0fallt1me
greatest0fallt1me merged commit c132092 into CalloraOrg:main Jul 29, 2026
1 check passed
@greatest0fallt1me

Copy link
Copy Markdown
Contributor

All checks green — merging. Nice job! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add correlation-id propagation on /api/logs [b#052]

3 participants