Application Structure (server.js
)
The main Express application is defined in src/server.js
. Here’s how it works:
Middleware
- Helmet: Secures HTTP headers.
- Morgan: Logs HTTP requests.
- JSON Parser: Parses incoming JSON requests.
- Correlation ID: Adds a unique
X-Correlation-ID
to each request for traceability.
Routes
-
/api/v1/statementify/health
Returns a simple health status. -
/api/v1/statementify/status
Returns the current uptime of the service. -
/api/v1/statementify/items
Returns a list of items. Requires a Bearer token in theAuthorization
header. Responds with 401 if missing or invalid. -
/api/v1/statementify/docs/raw
Returns the raw OpenAPI YAML spec. -
/api/v1/statementify/docs
Serves Swagger UI for interactive API documentation.
Security
The /items
endpoint is protected by a simple Bearer token check. In production, you should replace this with proper JWT verification.
Export
The app is exported for use by the main server (src/index.js
) and for testing.
For more, see the README or OpenAPI Spec.