apiVersion: capsule.dev/v0.1
kind: Capsule
name: ext-http-request-logger
version: 0.1.0
type: subsystem
purpose:
summary: 'Provides a flexible HTTP request logging middleware for Node.js applications,
supporting various predefined and custom logging formats, and a mechanism for
defining custom tokens to extract request/response data. This capsule encapsulates
the core functionality of the `morgan` library.
'
owns:
- The core `morgan` middleware logic.
- Predefined logging formats (e.g., 'combined', 'dev').
- Mechanism for defining custom tokens.
- Project metadata, dependencies, and official documentation.
does_not_own:
- Development-specific configurations (e.g., linting, testing setup).
- Continuous integration workflows.
interfaces:
provides:
- kind: library
name: morgan
description: A Node.js HTTP request logger middleware function and related utilities
(e.g., `morgan.compile`, `morgan.format`, `morgan.token`).
requires:
- kind: library
name: basic-auth
description: Utility for parsing basic HTTP authentication headers.
- kind: library
name: debug
description: Tiny Node.js debugging utility.
- kind: library
name: depd
description: Deprecate a function or module.
- kind: library
name: on-finished
description: Execute a callback when a HTTP request/response finishes, closes,
or errors.
- kind: library
name: on-headers
description: Execute a listener when a response is about to write headers.
agent:
summary_for_ai: 'This capsule contains the core logic for the `morgan` HTTP request
logger. It exposes the main `morgan` middleware function, along with `compile`,
`format`, and `token` utilities for customizing logging behavior. An agent working
on this should focus on adding new logging formats, custom tokens, improving performance,
or fixing bugs related to log generation and middleware integration. Ensure changes
maintain compatibility with existing Express.js applications.
'
avoid:
- Modifying the `package.json` `devDependencies` or `scripts` directly, as these
are managed by the `ext-http-request-logger-dev` capsule.
- Introducing project-specific configurations that are not generalizable to an HTTP
logger.
verification:
invariants:
- The `morgan` function must always return a valid Express-style middleware.
- Predefined formats must produce consistent log outputs.
- Custom tokens must be correctly registered and resolvable within format strings.
x-reuse:
notes: 'The `package.json` includes `devDependencies` and `scripts` that are specific
to the original project''s development and testing setup. Consumers lifting this
capsule should adapt these sections or integrate them into their existing build
systems. The `repository` and `funding` fields are specific to the original project
and should be updated to reflect the new project''s details.
'
x-reconstruct:
install: install.json