AixyzApp is a framework-agnostic server that manages route registration, middleware chaining, and optional x402 payment gating via a PaymentGateway. It uses web-standard Request/Response — no Express dependency.
Constructor
When
facilitators is provided, a PaymentGateway is created and x402 payment verification is enabled for routes that declare a payment option.
After constructing, register plugins with await server.withPlugin(...), then call await server.initialize() to finalize payment routes.
Properties
Methods
route(method, path, handler, options?)
Register a route with an optional x402 payment requirement:
fetch(request)
Dispatch a web-standard Request through payment verification, middleware chain, and route handler:
use(middleware)
Append a middleware to the chain. Middlewares run in registration order before the route handler:
withPlugin(plugin)
Register a plugin. Creates a scoped RegisterContext that auto-tracks routes in plugin.registeredRoutes, calls plugin.register(ctx), and returns this for chaining:
initialize()
Initialize payment gateway and plugins. Passes an InitializeContext with read access to all routes, registered plugins, and payment gateway. Must be called after all plugins are registered:
Example
app/server.ts