You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[DC-1475] Upgrade JsonServer to Node.js 24 LTS to address Node.js 20 EOL and security vulnerabilities - #22
…server-local.js
chore: add Postman collection for DoSelect JSON Server with comprehensive CRUD tests and query patterns
refactor: restructure server code to use src/app.js for better organization and data handling
fix: improve data serving logic and health check endpoint in the new app structure
…le transport
- Added Winston as a logging library to standardize logging format.
- Introduced DailyFileTransport for log rotation and retention management.
- Enhanced app.js to log requests with unique request IDs and performance metrics.
- Updated server-local.js to handle uncaught exceptions and unhandled promise rejections.
- Modified README.md to include logging configuration details.
- Added logger.js to encapsulate logging logic and context management.
- Added `data-store.ts` for managing JSON files and serving them via json-server.
- Introduced `createDataStore` function to initialize the data store with file loading and request handling.
- Implemented caching for loaded files and created a router for handling read and write requests.
feat: extend Express types for middleware integration
- Created `express.d.ts` to define additional `res.locals` properties used by the application.
feat: add json-server type definitions
- Added `json-server.d.ts` to provide type definitions for json-server's router and middleware options.
feat: implement error handling utilities
- Introduced `errors.ts` with functions to safely extract error codes and HTTP status from thrown errors.
feat: create HTTP utility functions
- Added `http.ts` with helper functions for handling request paths and client addresses.
feat: add version utility
- Implemented `version.ts` to read and export the application version from `package.json`.
test: add comprehensive API tests
- Created `api.test.ts` to test the HTTP API against the data store, including reading, writing, and error handling.
test: set up environment for tests
- Added `env.ts` to configure the testing environment before loading application code.
test: implement server helper functions
- Created `helpers.ts` to manage server startup and request handling in tests.
test: add logger tests
- Implemented `logger.test.ts` to validate logging behavior and output format.
test: add server integration tests
- Created `server.test.ts` to test server startup, request handling, and shutdown logging.
build: add TypeScript configuration files
- Introduced `tsconfig.json` for type checking and `tsconfig.build.json` for production builds.
ci: configure Vitest for testing
- Added `vitest.config.ts` to set up testing environment and options for Vitest.
- Moved configuration from './config.ts' to './config/index.ts' for better organization.
- Updated logger imports throughout the application to reflect the new logging structure in './logging/logger.ts'.
- Introduced a new daily file transport for logging that rotates logs daily and compresses old logs.
- Enhanced the logger to follow the DoSelect logging standard, ensuring consistent log formatting.
- Updated middleware and route files to use the new logger path.
- Added tests to validate the new logging implementation and ensure compliance with the logging standard.
…A flows
- Introduced `config.test.ts` to validate configuration defaults and environment variable parsing.
- Added `data-store.test.ts` to test file serving, caching, and error handling in the data store.
- Enhanced `logger.test.ts` with tests for log levels, formatting, and context handling.
- Created `qa-flows.test.ts` to cover QA_GUIDE.md flows B-G against the real data folder.
- Implemented `utils.test.ts` for testing small helper functions related to HTTP utilities and error handling.
- Updated `README.md` to reflect new test files and their purposes.
Modernizes the sample REST API service for Node.js 24 LTS, replacing the legacy JavaScript server with TypeScript and adding security guards, structured logging, and automated checks.
Changes:
Updates runtime requirements, dependencies, development tooling, and data generators.
Serves deployed datasets from memory with direct routing, request guards, and graceful shutdown.
Adds API and logging tests, QA documentation, Postman coverage, and expanded sample notes.
File
Description
vitest.config.ts
Configures test discovery, isolation, and timeouts.
tsconfig.json
Enables strict TypeScript checking and native execution compatibility.
tsconfig.build.json
Configures optional JavaScript builds.
test/utils.test.ts
Tests HTTP, error, and timestamp helpers.
test/server.test.ts
Tests startup, shutdown, and server failures.
test/qa-flows.test.ts
Automates documented API acceptance flows.
test/logger.test.ts
Tests logging format, rotation, retention, and recovery.
test/helpers.ts
Supports local and remote API testing.
test/env.ts
Sets quiet test logging defaults.
test/data-store.test.ts
Tests caching, file selection, and isolated writes.
test/config.test.ts
Tests configuration defaults and validation.
test/api.test.ts
Tests routes, simulated writes, and request guards.
src/utils/version.ts
Reads the application version for startup logs.
src/utils/time.ts
Formats standard UTC log timestamps.
src/utils/http.ts
Adds request-path, address, and regex helpers.
src/utils/errors.ts
Extracts error codes and HTTP statuses.
src/types/json-server.d.ts
Defines types for json-server integration.
src/types/express.d.ts
Types request-local dataset metadata.
src/services/data-store.ts
Caches datasets and isolates simulated writes.
src/routes/health.ts
Provides root and health responses.
src/routes/data.ts
Routes current and legacy dataset URLs directly.
src/middlewares/request-guards.ts
Adds body-size, query, and JSONP guards.
src/middlewares/request-context.ts
Adds request IDs and access logging.
src/logging/logger.ts
Implements structured logging and contextual fields.
src/logging/daily-file-transport.ts
Adds daily log rotation and retention.
src/index.ts
Handles startup validation and graceful shutdown.
src/constants/logging.ts
Defines logging levels and rotation constants.
src/constants/lifecycle.ts
Bounds log flushing before exit.
src/constants/http.ts
Centralizes routes, limits, and HTTP timeouts.
src/config/index.ts
Loads and validates environment settings.
src/app.ts
Assembles middleware, routes, and JSON error handling.
server-local.js
Removes the legacy server entry point.
seed.js
Removes the legacy combined-data seeder.
README.md
Documents runtime, configuration, and development workflows.
QA_GUIDE.md
Defines verification flows and acceptance criteria.
- Added `parseBody` middleware to handle JSON and form bodies with size limits.
- Improved error handling for oversized request bodies, including chunked and gzip/deflate bodies.
- Updated `endpoint` function to return raw paths for unparseable URLs without throwing errors.
- Enhanced `DailyFileTransport` to manage gzip compression and recovery of log files more effectively.
- Added tests for new request handling features and logging behavior.
Reject retention values that produce an invalid archive cutoff
src/logging/daily-file-transport.ts:381
LOG_RETENTION_DAYS=999999999999 passes both positive-integer checks, but the cutoff becomes an Invalid Date. localDay() then returns 'NaN-NaN-NaN', and every normal archive date compares less than that string, causing even yesterday's logs to be deleted. Check that the computed cutoff is valid before comparing archive names, or reject unrepresentable retention values during configuration validation.
Capture request context before buffering Winston log entries
src/logging/logger.ts:165
When a slow file transport fills Winston's buffers, queued entries can be formatted later under another request's context, giving them the wrong request_id or nested context fields. Capture the context in write() before calling target.log(), merge explicit call fields over that snapshot, and stop reading the current context in the formatter. Add a backpressure test with enough entries to exceed the stream buffers.
if (pattern.test(file) && !this.#rotating.has(archive)) await this.compress(archive)
}
await this.deleteOldArchives()
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
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.
No description provided.