Zelavis
The Zelavis class is the main entry point. It holds configuration, lazily
initializes the runtime on the first request, and exposes the Web-standard
request-handling methods used by long-running hosts.
Zelavis API routes are the stable transport surface for platform capabilities. The dashboard should call the same capability endpoints that CLI commands, AI agents, scripts, plugins, and external admin tools can call.
import { Zelavis } from 'zelavis';
export const zv = new Zelavis({ adapter });Constructor
Section titled “Constructor”new Zelavis(options?: ZelavisOptions)ZelavisOptions
Section titled “ZelavisOptions”| Option | Type | Description |
|---|---|---|
adapter |
ZelavisAdapter |
Runtime adapter supplying host resources such as storage and KV. See Adapters. |
rootPath |
string |
URL prefix where Zelavis is mounted. Defaults to /zelavis. |
api |
ZelavisApiOptions |
Options for the internal API router. |
services |
ZelavisServiceRegistryOptions |
Static service entries and registry store. |
onError |
ZelavisServerErrorHandler |
Global error handler called on unhandled runtime errors. |
ZelavisApiOptions
Section titled “ZelavisApiOptions”| Option | Type | Description |
|---|---|---|
prefix |
string |
Path prefix for API routes under rootPath. |
version |
string |
API version string included in route paths. |
Methods
Section titled “Methods”zv.fetch(request: Request, context?: ZelavisServerExecutionContext): Promise<Response>Handles an incoming request and returns a standard Response. This is the
portable method used by fetch-style self-hosted runtimes.
// React Router resource routeexport async function loader({ request }: LoaderFunctionArgs) { return zv.fetch(request);}
export async function action({ request }: ActionFunctionArgs) { return zv.fetch(request);}dispatch
Section titled “dispatch”zv.dispatch(request: Request, context?: ZelavisServerExecutionContext): Promise<ZelavisDispatchResult>Lower-level alternative to fetch. Returns a structured result object instead of a Response, useful when you need to inspect the matched route or response metadata before sending.
zv.plain(request): Promise<ZelavisPlainResult>Handles a plain request object for tests and object-in/object-out embedding.
runtime
Section titled “runtime”zv.runtime(): Promise<ZelavisServerRuntime>Returns the initialized server runtime. The runtime is created lazily on the first call and cached for subsequent requests. Calling this manually is rarely needed — fetch and dispatch call it internally.
platform
Section titled “platform”zv.platform: ZelavisPlatformContextRead-only accessor for the resolved platform context, available after the first call to runtime(). Contains the resources and metadata provided by the adapter.