Skip to main content
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

ParameterTypeDefaultDescription
options.facilitatorsFacilitatorClient | FacilitatorClient[]Payment verification service(s)
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

PropertyTypeDescription
routesMap<string, RouteEntry>Registered routes, keyed by "METHOD /path"
paymentPaymentGateway | undefinedPayment gateway (present when facilitators provided)

Methods

route(method, path, handler, options?)

Register a route with an optional x402 payment requirement:
ParameterTypeDescription
methodHttpMethodHTTP method (GET, POST, etc.)
pathstringRoute path
handlerRouteHandler(request: Request) => Response | Promise<Response>
options.paymentAcceptsX402Optional 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