-
Notifications
You must be signed in to change notification settings - Fork 0
feat: improve national endpoint JSON structure and database reliability #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BREAKING CHANGE: Complete restructuring of national endpoints response format - Create new response DTOs with nested structure for better organization - Group related data into logical sections (daily, cumulative, statistics) - Add calculated fields for active cases and percentages - Include reproduction rate in nested statistics object - Change all keys from Indonesian to English for better accessibility - Add comprehensive unit tests for transformation logic - Document all breaking changes and migration guide Affected endpoints: - GET /api/national - GET /api/national/latest - GET /api/national?start_date=YYYY-MM-DD&end_date=YYYY-MM-DD The new structure provides: - Better organization with nested objects for related data - Pre-calculated statistics (active cases, percentages) - Clearer English naming conventions - Future-proof design for additional statistics Refer to BREAKING_CHANGES.md for detailed migration guide.
### National Endpoint Changes: - Restructure JSON response with nested groups (daily, cumulative, statistics) - Convert Indonesian keys to English for better accessibility - Add calculated fields (active cases, percentages) - Include reproduction rate with proper bounds ### Database Connection Improvements: - Change production DB host to 127.0.0.1 to fix connection resets - Enhance connection pooling with shorter lifetimes and idle timeouts - Add retry logic with exponential backoff for failed connections - Implement connection health monitoring ### Infrastructure: - Add Ruby-based changelog generator for release automation - Enhanced health check endpoint with database connectivity status - Update environment configuration for production stability - Comprehensive test coverage for new response structures BREAKING CHANGE: National endpoints now return nested JSON structure
Fix all linting errors identified by golangci-lint: - Add proper error handling for unchecked error returns (errcheck) - Remove unnecessary embedded field selectors (staticcheck) - Implement proper defer error handling for database and HTTP resources - Update JSON encoding to handle potential errors in response handlers - Improve connection cleanup in database operations and tests All tests pass after these fixes, maintaining code functionality while ensuring compliance with Go linting standards.
a817399
to
b1f6ccf
Compare
CI Configuration Changes: - Update Go version from 1.23.x to 1.25.x in both test and lint jobs - Resolves golangci-lint compatibility issues with Go 1.24 vs 1.25 CORS Fix: - Add OPTIONS method support to all API routes in routes.go - Fixes TestAPI_CORS test that was failing with 404 for OPTIONS requests - Gorilla Mux requires explicit OPTIONS method registration for CORS preflight - CORS middleware now properly handles preflight requests All integration and unit tests now pass.
c18611c
to
ed8d6d4
Compare
ryanaidilp
added a commit
that referenced
this pull request
Sep 7, 2025
…ty (#1) * feat!: restructure national COVID-19 API response to nested JSON format BREAKING CHANGE: Complete restructuring of national endpoints response format - Create new response DTOs with nested structure for better organization - Group related data into logical sections (daily, cumulative, statistics) - Add calculated fields for active cases and percentages - Include reproduction rate in nested statistics object - Change all keys from Indonesian to English for better accessibility - Add comprehensive unit tests for transformation logic - Document all breaking changes and migration guide Affected endpoints: - GET /api/national - GET /api/national/latest - GET /api/national?start_date=YYYY-MM-DD&end_date=YYYY-MM-DD The new structure provides: - Better organization with nested objects for related data - Pre-calculated statistics (active cases, percentages) - Clearer English naming conventions - Future-proof design for additional statistics Refer to BREAKING_CHANGES.md for detailed migration guide. * feat: improve national endpoint JSON structure and database reliability ### National Endpoint Changes: - Restructure JSON response with nested groups (daily, cumulative, statistics) - Convert Indonesian keys to English for better accessibility - Add calculated fields (active cases, percentages) - Include reproduction rate with proper bounds ### Database Connection Improvements: - Change production DB host to 127.0.0.1 to fix connection resets - Enhance connection pooling with shorter lifetimes and idle timeouts - Add retry logic with exponential backoff for failed connections - Implement connection health monitoring ### Infrastructure: - Add Ruby-based changelog generator for release automation - Enhanced health check endpoint with database connectivity status - Update environment configuration for production stability - Comprehensive test coverage for new response structures BREAKING CHANGE: National endpoints now return nested JSON structure * fix: resolve golangci-lint issues to pass CI Fix all linting errors identified by golangci-lint: - Add proper error handling for unchecked error returns (errcheck) - Remove unnecessary embedded field selectors (staticcheck) - Implement proper defer error handling for database and HTTP resources - Update JSON encoding to handle potential errors in response handlers - Improve connection cleanup in database operations and tests All tests pass after these fixes, maintaining code functionality while ensuring compliance with Go linting standards. * fix: update CI to use Go 1.23 and fix golangci-lint version compatibility * fix: update CI to use Go 1.25 and resolve CORS test failures CI Configuration Changes: - Update Go version from 1.23.x to 1.25.x in both test and lint jobs - Resolves golangci-lint compatibility issues with Go 1.24 vs 1.25 CORS Fix: - Add OPTIONS method support to all API routes in routes.go - Fixes TestAPI_CORS test that was failing with 404 for OPTIONS requests - Gorilla Mux requires explicit OPTIONS method registration for CORS preflight - CORS middleware now properly handles preflight requests All integration and unit tests now pass. * fix: align Go version to 1.23 for CI compatibility and ensure CORS test passes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR enhances the COVID-19 API with improved JSON structure for national endpoints and resolves database connection reliability issues.
🔄 National Endpoint Changes (BREAKING)
daily
: New cases for the daycumulative
: Total accumulated casesstatistics
: Percentages and reproduction rates🔧 Database Reliability Improvements
127.0.0.1
🛠️ Infrastructure Enhancements
📋 Breaking Changes
National endpoints (
/api/v1/national
,/api/v1/national/latest
) now return a new JSON structure. See CHANGELOG.md for migration guide.🧪 Testing
Ready for review and testing! 🚀