@nwire/http-express
v0.7.1
Published
Nwire — Express interop adapters. toExpress(httpInterface) mounts a Nwire HTTP interface as Express middleware (use existing Express app + Nwire routes side-by-side). fromExpress(middleware) lets you use any Express middleware inside a Nwire interface (he
Readme
@nwire/http-express
Express interop — drop Nwire routes into Express apps; use Express middleware inside Nwire interfaces.
What it is
About 50 LOC of real adapter code. toExpress(api) compiles a Nwire HTTP interface into Express middleware you mount under any path; fromExpress(mw) bridges any Express middleware (helmet, morgan, passport.authenticate) into Nwire's .use(...) chain. The migration story for teams that can't rewrite.
Install
pnpm add @nwire/http @nwire/http-expressexpress is a peer dep — bring whatever version you already have (4 or 5).
Within nwire-app
For developers using this package as part of the Nwire stack. Mount Nwire-app-backed interfaces into an Express host so an existing service can adopt Nwire incrementally — the Nwire side still gets plugin lifecycle, envelope propagation, and OpenAPI.
import express from "express";
import { createApp } from "@nwire/forge";
import { http } from "@nwire/http";
import { toExpress } from "@nwire/http-express";
const app = createApp("learnflow").module(stations);
const api = http("api").wire(stationRoutes);
const host = express();
host.use("/api", toExpress(api, { app }));
host.listen(3000);API
toExpress(httpInterface, options?)— Nwire HTTP interface → Express request handler.fromExpress(middleware)— Express middleware → Nwire.use(...)step.
