@inkly/express
v0.0.0
Published
Express embedding adapter for inkly (shares the host HTTP server's upgrade).
Readme
@inkly/express
Express adapter for inkly. It embeds inkly into the same Node http.Server that serves your Express routes, and claims only the configured WebSocket path.
Install
pnpm add @inkly/express @inkly/core @inkly/client expressQuickstart
import express from "express";
import { contract, inkly } from "@inkly/core";
import { serveExpress } from "@inkly/express";
const api = contract({ actions: {}, events: {} });
const ws = inkly(api);
const app = express();
app.get("/health", (_req, res) => res.json({ ok: true }));
serveExpress(app, ws, { port: 3000, path: "/ws" });HTTP routes and ws://host/ws share port 3000. Non-/ws upgrades are ignored so other handlers can coexist.
API
inklyExpress(server, inklyApp, options)attaches to an existing Node server.serveExpress(expressApp, inklyApp, options)createshttp.createServer(expressApp), attaches inkly, optionally listens, and returns{ server, handle, port, close() }.
Caveats
This adapter is Node-only and relies on @inkly/node's attachInkly for path filtering, subprotocol selection, and upgrade-time authorization.
