effect-http is a high-level, declarative, and type-safe HTTP API layer built specifically for the `effect-ts` ecosystem. It leverages `Effect`'s powerful functional programming primitives, including Effects, Layers, and Schemas, to provide a robust framework for defining both HTTP servers and clients. Currently at version 0.87.0, the library maintains a rapid release cadence, often issuing minor version updates to align with ongoing developments and breaking changes within its core peer dependency, `effect`. This close coupling ensures full compatibility and leverages the latest features of `effect-ts`, but also means users should expect frequent dependency updates. Its primary differentiation lies in its deep integration with the `Effect` paradigm, offering end-to-end type safety from API definition to implementation and client consumption, while remaining platform-agnostic at its core (`effect-http` package) with specific adapters like `effect-http-node` for server execution. It promotes a functional and declarative style for building robust, concurrent, and error-handled web services.
npm install effect-httpVerified import paths — ran on the pinned version, not inferred.
This quickstart defines a simple REST API with GET and POST endpoints, implements them using `effect-http/Router`, starts a Node.js server with `effect-http-node`, and then uses `effect-http/Client` to interact with the running API programmatically.
Pin `effect-http` and `effect` dependencies to specific versions, or review release notes for both `effect-http` and `effect` when upgrading to manage breaking changes. Use `npm install effect-http@latest effect@latest` cautiously.
For Node.js server environments, install `effect-http-node` (`npm install effect-http-node`) and use its server utilities (e.g., `NodeHttpServer.server`).
Consult the `effect-ts` migration guides for upgrading to `effect` v3. Ensure all `effect` ecosystem libraries, including `effect-http`, are compatible with your target `effect` version. `effect-http` versions >=0.80.0 are generally aligned with `effect` v3.
Ensure every operation defined in `Api.api()` has a corresponding handler attached to the `Router.make(api)` instance using `Router.handle('operationName', handlerFunction)`.Verify that all necessary dependencies (Layers) are provided to your `Effect` program. Use `Effect.provide()` or `Layer.merge()`/`Layer.provide()` correctly to ensure services are available in the desired scope. Inspect the specific line number for the `undefined` value.
Review the `Schema` definition for the affected operation in your `Api`. Ensure that the data being sent or received by the client/server matches the structure and types specified by the `Schema`.