Skip to content

Split framework-agnostic core from Express adapter #9

@mmurrs

Description

@mmurrs

Context

dual402 is currently packaged as an Express-first middleware. The source is now split into focused modules, but core payment behavior still assumes Express request/response objects and mppx/express.

Now that the public-release hardening and docs/release polish are done, the next architectural step is a framework-agnostic core with thin adapters.

Goal

Expose reusable core primitives for x402 + MPP charge/discovery behavior, then keep Express as the first adapter.

Proposed Shape

  • Move protocol-neutral logic into a core layer:
    • config validation and resolved config
    • payment requirement/challenge construction
    • x402 verify/settle orchestration
    • schema/discovery metadata construction
    • shared paid-route model
  • Keep Express-specific behavior in ./express:
    • Express middleware signatures
    • res.status(402) interception
    • request URL/base URL extraction
    • mppx/express integration
  • Preserve existing dual402 and dual402/express imports.
  • Add a deliberate dual402/core export only when the core API is ready.

Acceptance Criteria

  • Existing Express API remains backward compatible.
  • Existing tests still cover Express behavior.
  • Core code can be exercised without importing Express types.
  • Adapter boundary is documented in ARCHITECTURE.md.
  • README continues to present Express as the default path, with core/adapters framed as extension points.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions