@nwire/endpoint
v0.7.1
Published
Nwire — production process lifecycle. Wraps any Node server (Express, Fastify, Koa, Nest, Nwire interfaces) with K8s-grade graceful shutdown, http-terminator drain, and lightship readiness/liveness probes. Standalone — no framework dependency beyond @nwir
Readme
@nwire/endpoint
Process lifecycle — graceful shutdown, K8s probes, signal handling for any Node server.
What it is
Wraps any Node server (Express, Fastify, Koa, Nest, Hono, raw http, or a Nwire interface) with the boring lifecycle every long-running process needs: http-terminator for draining keep-alive sockets, lightship for readiness/liveness probes on a dedicated port, signal handling, and ordered shutdown. The outermost layer of every Nwire entrypoint.
Install
pnpm add @nwire/endpointWithin nwire-app
For developers using this package as part of the Nwire stack. endpoint().use(app).mount(api).run() boots a Nwire App (plugins, providers, lifecycle events) and mounts one or more Nwire interfaces in the same managed process.
import { endpoint } from "@nwire/endpoint";
import { createApp } from "@nwire/forge";
import { http } from "@nwire/http";
const app = createApp("learnflow").module(stations);
const api = http("api").wire(stationRoutes);
await endpoint("api", { port: 3000 }).use(app).mount(api).run();API
endpoint(name, config).serve(target).run()— canonical builder; accepts foreign frameworks, Nwire apps, and Nwire interfaces.attachLifecycle({ server, shutdown, health })— escape hatch when you already have aServer.defineCheck(name, check)— declarative readiness probe; aggregated into/ready.RunningEndpoint/EndpointConfig/ShutdownConfig/HealthConfig/HealthCheck— config types.
