Skip to content

feat: cache warm audit - #896

Open
Derekwalter999 wants to merge 1 commit into
Predictify-org:mainfrom
Derekwalter999:task/audit-cachewarm
Open

feat: cache warm audit#896
Derekwalter999 wants to merge 1 commit into
Predictify-org:mainfrom
Derekwalter999:task/audit-cachewarm

Conversation

@Derekwalter999

Copy link
Copy Markdown

Description

This PR addresses backend issue #385 for the GrantFox FWC26 campaign (buffer2 #2). It implements an automated cache warm-up sequence for the /api/audit endpoint during application startup, which effectively mitigates cold-cache latency spikes for initial requests.

Changes Made

  • src/services/auditCacheWarm.ts: Added the warmAuditCache() service function. It utilizes the native Node fetch API to make an internal background request to /api/audit?limit=10 with a timeout mechanism.
  • src/index.ts: Wired the cache warm-up logic into the server lifecycle, executing it immediately after the Express app binds and begins listening.
  • src/__tests__/services/auditCacheWarm.test.ts: Added a comprehensive test suite to validate success paths, non-200 responses, and network-level fetch errors.

Compliance & Acceptance Criteria

  • Implementation matches description: The /api/audit endpoint is now actively warmed up on startup.
  • Test Coverage: Exceeds the 90% minimum requirement for changed lines, with tests fully covering the new cache warm service.
  • Structured Logging: Includes correlation IDs (uuidv4()) and adheres to the standardized Pino logging structure for tracking warm-up lifecycles.
  • Documentation: Added clear inline TSDoc comments for the new service to explain its purpose and behavior.
  • Error Boundaries: Request failures are gracefully caught, logged, and isolated so they do not crash the server startup process.

Closes #385

Implements cache-warm for /api/audit on startup to avoid cold-cache spikes.
Fixes buffer2 Predictify-org#2.
@drips-wave

drips-wave Bot commented Jul 31, 2026

Copy link
Copy Markdown

@Derekwalter999 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.

Add cache-warm for /api/audit on startup (buffer2 #2)

1 participant