Skip to content

fix(api): standardize response envelopes and resolve API test failures (#385) - #548

Open
Abdullahi-Code9 wants to merge 1 commit into
Core-Foundry:mainfrom
Abdullahi-Code9:feat/issue-385-standardize-api-response
Open

fix(api): standardize response envelopes and resolve API test failures (#385)#548
Abdullahi-Code9 wants to merge 1 commit into
Core-Foundry:mainfrom
Abdullahi-Code9:feat/issue-385-standardize-api-response

Conversation

@Abdullahi-Code9

Copy link
Copy Markdown
Contributor

Closes #385

Summary

This PR standardizes the API response formats across all endpoints to resolve payload wrapping inconsistencies and fix cascading test failures in the listener service (#385).

Key Changes

  1. API Envelope Standardization:

    • Updated GET /health in src/api/events-server.ts to return direct, unwrapped JSON objects required by health contract tests.
    • Refactored notifications-history and templates-api handlers to ensure consistent payload structures using sendJson / standardized response helpers.
  2. Database & Schema Fixes:

    • Removed duplicate column declarations (next_retry_at) from schema.sql CREATE TABLE statements and handled migration safety in database.ts.
    • Fixed SQL parameter count mismatches (11 params bound to 10 columns) in scheduled-notification-repository.ts.
    • Resolved old notification_templates schema conflicts.
  3. Compiler & Test Environment Fixes:

    • Fixed duplicate method implementation (setTtlMs) in src/store/event-registry.ts.
    • Added mock modules for @stellar/stellar-sdk and node-cache to ensure consistent unit test isolation.
    • Adjusted timer leak issues (.unref()) allowing Jest workers to exit cleanly.

Verification

All 78 tests across the 6 API test suites under src/api/ are now passing 100% green:

  • events-server.health.test.ts (12 tests)
  • events-server.test.ts
  • notifications-history.test.ts (9 tests)
  • templates-api.test.ts
  • rate-limiter.test.ts
  • execution-metrics-api.test.ts (5 tests)

Test Command Executed:
npm test -- src/api/

@drips-wave

drips-wave Bot commented Jul 27, 2026

Copy link
Copy Markdown

@Abdullahi-Code9 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

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.

Standardize API Response Format

1 participant