effect-http-node is a crucial adapter package within the `effect-ts` ecosystem, providing the Node.js-specific implementation for serving declarative HTTP APIs built with `effect-http`. It leverages the `@effect/platform-node` package to bridge `effect-http`'s server abstractions with Node.js's native HTTP server capabilities, enabling developers to run highly type-safe, functional, and concurrently managed web services. The current stable version is 0.27.0. This package, along with `effect-http` and core `effect` libraries, follows a rapid release cadence, often undergoing minor version bumps to align with updates in its peer dependencies, reflecting the active development of the `effect-ts` project. Its key differentiator lies in enabling the `effect-ts` programming model—emphasizing structured concurrency, resource management, and robust error handling—directly within Node.js for HTTP services, providing a strong alternative to traditional imperative frameworks. It does not introduce new HTTP API paradigms but rather provides the runtime environment for `effect-http`'s existing ones.
npm install effect-http-nodeVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates defining a simple `effect-http` API, implementing its handlers, and serving it using `effect-http-node` within a Node.js runtime. It includes a GET and a POST endpoint.
Begin migrating your HTTP API definitions and server implementations to use the `@effect/platform` and `@effect/platform-node` modules directly for server creation and routing. `effect-http` will only receive Effect updates and critical patches.
Always keep `effect`, `@effect/platform`, `@effect/platform-node`, and `effect-http` (and `effect-http-node`) at compatible versions, ideally by updating them simultaneously or frequently checking the `effect-http` changelog for specific dependency requirements. Use a lockfile (pnpm-lock.yaml, yarn.lock, package-lock.json) to ensure consistent dependency resolution.
Refer to the official Effect documentation, especially sections on error handling, schema, and basic Effect patterns. Ensure your TypeScript configuration is strict, and gradually introduce Effect concepts.
Change the `port` in `NodeServer.make` to an available port, or terminate the process currently using the port.
Ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json`) and use `import { NodeServer } from 'effect-http-node';` syntax. Avoid `require()` for Effect-TS modules.Ensure you've created an `EffectHttp.Router` instance by calling `Router.make(api).pipe(Router.handle(...))` before passing it to `NodeServer.make`.