Express
Use the Express utility when Zelavis should live inside an existing Express application.
Basic usage
Section titled “Basic usage”import express from "express";import { Zelavis } from "zelavis";import { nodeAdapter } from "zelavis/adapters/node";import { expressMiddleware } from "zelavis/express";
const app = express();const zelavis = new Zelavis({ adapter: nodeAdapter(),});
app.use(express.json());app.use(expressMiddleware(zelavis));
app.listen(3000);expressMiddleware(zelavis: Zelavis): RequestHandlerTakes a Zelavis instance, returns an Express middleware that lazy-initializes the runtime on first request.
Good fit
Section titled “Good fit”- Existing Express apps
- Apps that already own middleware ordering
- Cases where Zelavis should share one process with custom routes
- Register any app-specific Express middleware before
expressMiddleware(zelavis)when those routes should see parsed request bodies or custom headers first. - Zelavis still serves the dashboard under its configured
rootPath, for example/zelavis. - The Express app can keep its own routes outside the Zelavis namespace.