mirror of
https://github.com/bckelley/cgm-remote-monitor.git
synced 2026-08-24 03:14:12 -05:00
Fixes two bugs in the entries API that caused test failures: 1. POST endpoints now return JSON arrays consistently - Created format_post_response() middleware for POST requests - Replaces format_entries() which is designed for GET with content negotiation - Previously, POST requests without Accept header defaulted to text/plain handler - This caused responses to fail or return empty objects instead of JSON arrays - Now matches behavior of treatments and devicestatus APIs 2. Fixed callback never being called for empty array posts - Added empty array check in lib/server/entries.js create() function - Previously, empty array caused forEach loop to never execute - Completion callback was inside forEach, so never triggered for empty input - This caused 15 second timeouts on POST requests with empty arrays All 26 tests in api.shape-handling.test.js now pass. Files changed: - lib/api/entries/index.js: Added format_post_response, updated POST routes - lib/server/entries.js: Added empty array handling in create()