Skip to content

Zelavis

The Zelavis class is the main entry point. It holds configuration, lazily initializes the runtime on the first request, and exposes the request-handling methods used by framework adapters.

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 });
new Zelavis(options?: ZelavisOptions)
OptionTypeDescription
adapterZelavisAdapterRuntime adapter supplying host resources such as storage and KV. See Adapters.
rootPathstringURL prefix where Zelavis is mounted. Defaults to /zelavis.
apiZelavisApiOptionsOptions for the internal API router.
servicesZelavisServiceRegistryOptionsStatic service entries and registry store.
onErrorZelavisServerErrorHandlerGlobal error handler called on unhandled runtime errors.
OptionTypeDescription
prefixstringPath prefix for API routes under rootPath.
versionstringAPI version string included in route paths.
zv.fetch(request: Request, context?: ZelavisServerExecutionContext): Promise<Response>

Handles an incoming request and returns a standard Response. This is the method called by framework route handlers and fetch-style self-hosted runtimes.

// React Router resource route
export async function loader({ request }: LoaderFunctionArgs) {
return zv.fetch(request);
}
export async function action({ request }: ActionFunctionArgs) {
return zv.fetch(request);
}
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 (non-fetch-API) request object. Used by adapters that wrap non-standard request shapes before passing them to the 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.

zv.platform: ZelavisPlatformContext

Read-only accessor for the resolved platform context, available after the first call to runtime(). Contains the resources and metadata provided by the adapter.