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
| Parameter | Type | Default | Description |
|---|---|---|---|
options.facilitators | FacilitatorClient | FacilitatorClient[] | — | Payment verification service(s) |
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
| Property | Type | Description |
|---|---|---|
routes | Map<string, RouteEntry> | Registered routes, keyed by "METHOD /path" |
payment | PaymentGateway | undefined | Payment gateway (present when facilitators provided) |
Methods
route(method, path, handler, options?)
Register a route with an optional x402 payment requirement:
| Parameter | Type | Description |
|---|---|---|
method | HttpMethod | HTTP method (GET, POST, etc.) |
path | string | Route path |
handler | RouteHandler | (request: Request) => Response | Promise<Response> |
options.payment | AcceptsX402 | Optional payment configuration |
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