Registry / web-framework / effect-http-node

effect-http-node

JSON →
library0.27.0jsnpmunverified

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.

web-frameworkhttp-networking
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Used for creating a Node.js HTTP server instance from an `effect-http` application. The Effect ecosystem is primarily ESM-first.

import { NodeServer } from 'effect-http-node';

While `NodeRuntime` is from `@effect/platform-node`, it is essential for running `Effect` programs, including the server, in a Node.js environment. It's often imported as a namespace.

import * as NodePlatform from '@effect/platform-node'; // ... NodePlatform.NodeRuntime.runMain(program);

Although `Api` is from `effect-http`, it's fundamental for defining the API contract that `effect-http-node` then serves.

import { Api } from 'effect-http';

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.

import { pipe, Effect } from 'effect'; import { Api, Router } from 'effect-http'; import { NodeServer } from 'effect-http-node'; import * as NodePlatform from '@effect/platform-node'; import * as Logger from '@effect/data/Logger'; // 1. Define your API using effect-http const api = Api.make().pipe( Api.get('hello', '/hello', { response: Api.string(), }), Api.post('echo', '/echo', { request: { body: Api.string(), }, response: Api.string(), }), ); // 2. Implement the API handlers const app = Router.make(api).pipe( Router.handle('hello', () => Effect.succeed('Hello from Effect-HTTP!')), Router.handle('echo', ({ body }) => Effect.succeed(`You said: ${body}`)), ); // 3. Create a Node.js server from the API and application const server = NodeServer.make(app, { port: 3000 }); // 4. Run the server using NodePlatform.NodeRuntime pipe( server.pipe( Effect.tap(() => Effect.logInfo('Server started on http://localhost:3000'), ), ), NodePlatform.NodeRuntime.runMain, );
Debug
Known footguns
breakingThe `effect-http` library, and by extension `effect-http-node`, is considered 'deprecated in favour of the @effect/platform' as of August 30, 2024. Users are advised to migrate to `@effect/platform` for future-proof HTTP server development within the Effect ecosystem.
gotchaDue to the rapid development and interconnectedness of the Effect-TS ecosystem, frequent minor version updates across `effect`, `@effect/platform`, `@effect/platform-node`, and `effect-http` are common. Mismatched peer dependencies can lead to runtime errors or subtle type-system inconsistencies.
gotchaThe Effect ecosystem is designed for TypeScript and leverages advanced type features. Incorrect type inference or usage can lead to complex type errors. While powerful, this can be a learning curve for developers new to Effect.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
14 hits · last 30 days
gptbot
4
ahrefsbot
4
amazonbot
4
script
1
googlebot
1
Resources