Skip to content

Conversation

@max-ostapenko
Copy link
Contributor

@max-ostapenko max-ostapenko commented Dec 7, 2025

This pull request removes all in-memory backend caching and related endpoints from the API, simplifying the codebase and documentation. It also updates the Node.js version requirement and improves static file serving tests for better coverage and robustness.

Key changes:

1. Removal of In-Memory Caching and Cache Endpoints

  • All backend in-memory caching logic and related helper functions (query result cache, latest date cache, cache key generation, cache stats, and cache reset) have been removed from controllerHelpers.js, reportController.js, categoriesController.js, and technologiesController.js. This includes the deletion of /v1/cache-stats and /v1/cache-reset endpoints and their documentation.

2. Documentation Updates

  • The README.md has been updated to remove all references to backend caching, cache-related endpoints, and to clarify that static data is still served with cache headers. The Node.js version requirement is updated from 18+ to 22+.

3. Static File Serving and Testing Improvements

  • The test suite for the /v1/static/* endpoint has been significantly expanded to cover valid/invalid file requests, MIME type detection, CORS handling, ETag/conditional requests, error scenarios, and directory traversal protection. This ensures robust validation and correct behavior for static file proxying.

4. Response Header Adjustments

  • Some response headers (such as CORS and cache-control) have been removed or adjusted in cdnController.js to align with the new caching strategy.

@max-ostapenko max-ostapenko changed the title Development Caching moved to CDN Dec 7, 2025
@max-ostapenko max-ostapenko marked this pull request as ready for review December 7, 2025 01:50
Copilot AI review requested due to automatic review settings December 7, 2025 01:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request removes all in-memory backend caching infrastructure from the API, delegating caching responsibility to the CDN layer. The changes simplify the codebase by eliminating cache management complexity while maintaining appropriate cache-control headers for CDN utilization. Additionally, the PR updates the Node.js version requirement to 22+ and significantly expands test coverage for the static file serving endpoint.

Key changes:

  • Removed all in-memory caching logic, cache helper functions, and cache management endpoints (/v1/cache-stats and /v1/cache-reset)
  • Updated Node.js version requirement from 18+ to 22+ in both README and package.json
  • Expanded static file serving tests to cover MIME type detection, CORS handling, ETag/conditional requests, error scenarios, and directory traversal protection

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/utils/controllerHelpers.js Removed cache data structures (queryResultCache, latestDateCache), cache helper functions (getCachedQueryResult, setCachedQueryResult, getCacheStats, resetCache), and simplified executeQuery function signature by removing customCacheKeyData parameter
src/controllers/reportController.js Removed cache-related imports and inline caching logic from query execution flow
src/controllers/categoriesController.js Removed customCacheKeyData parameter from executeQuery call
src/controllers/technologiesController.js Removed customCacheKeyData parameter from executeQuery call
src/index.js Removed cache management endpoint routes (/v1/cache-stats and /v1/cache-reset)
src/controllers/cdnController.js Removed redundant response headers (Cache-Control, CORS) as they are now set globally in index.js
test-api.sh Removed cache endpoint tests
src/tests/routes.test.js Replaced cache management tests with comprehensive static file serving tests covering valid requests, directory traversal protection, 404 handling, conditional requests, error scenarios, and MIME type detection
README.md Updated Node.js version requirement from 18+ to 22+, removed all cache-related endpoint documentation while preserving reference to cache headers for static data

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

max-ostapenko and others added 3 commits December 7, 2025 02:54
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@max-ostapenko max-ostapenko merged commit cbb7306 into main Dec 7, 2025
5 checks passed
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.

2 participants