Skip to content

Add route-scoped middleware options for Terminus health and readiness endpoints #3288

Description

@ayden94

Context

All 182 evidence anchors were verified. Node engine mismatch and dependency-only major intent were excluded because they are covered by open issue #3169 (#3169). Broad open issue searches found no duplicate for this group.

Audit Purposes

Feature addition and operational endpoint configuration.

Findings or R&D Brief

Applications may need route-scoped middleware for generated /health and /ready endpoints, but TerminusModuleOptions currently exposes no such option. The book recommends restricting operational endpoints by deployment policy, and the official example already demonstrates endpoint middleware for metrics without an equivalent Terminus composition seam.

Evidence: book/beginner/ch18-health.md:98-99, book/beginner/ch18-health.md:274, packages/terminus/src/types.ts:52-58, packages/runtime/src/health/health.ts:31-37, examples/ops-metrics-terminus/src/ops/metrics-registry.ts:16-18, examples/ops-metrics-terminus/src/app.ts:11-13, examples/ops-metrics-terminus/src/app.test.ts:25-31.

Contract Impact

This is an additive public option. Existing endpoint behavior must remain unchanged when no middleware is configured.

Suggested Resolution

Add a class-based endpointMiddleware option to TerminusModuleOptions and apply it consistently to the normalized health and readiness routes, including custom paths. Preserve middleware DI and ordering semantics, then update the official example and EN/KO documentation.

Affected Packages

terminus, with a possible runtime health seam if composition requires it.

Affected Surfaces

Package API, runtime integration, tests, examples, docs, and book.

Why Now

Consumers currently need application-wide path checks or deployment-specific workarounds for a route-local operational concern.

Acceptance Criteria

  • Default behavior remains unchanged when no middleware is supplied.
  • Configured middleware applies to both /health and /ready.
  • Custom paths receive the same middleware behavior after normalization.
  • Middleware DI and execution order are covered by request-facing tests.
  • The official example demonstrates the option.
  • EN/KO package, docs, and book guidance remain synchronized.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions