Skip to content

NodeHttpClient.ts

Node.js implementations of the Effect HttpClient.

This module supplies Node runtime backends for the platform-independent Effect HTTP client API. It re-exports the fetch-based Fetch, RequestInit, and layerFetch APIs, defines an Undici-backed client with dispatcher services and request options, and defines a lower-level node:http / node:https client with scoped HTTP agent layers.

Since v4.0.0



Service tag for the Undici Dispatcher used by the Undici-backed HTTP client.

Signature

declare class Dispatcher

Source

Since v4.0.0

Provides the Dispatcher service from Undici’s process-global dispatcher, without creating or owning a new agent.

Signature

declare const dispatcherLayerGlobal: Layer.Layer<Dispatcher, never, never>

Source

Since v4.0.0

Provides the Dispatcher service using a scoped Undici Agent.

Signature

declare const layerDispatcher: Layer.Layer<Dispatcher, never, never>

Source

Since v4.0.0

Acquires a new Undici Agent dispatcher and destroys it when the enclosing scope is finalized.

Signature

declare const makeDispatcher: Effect.Effect<Undici.Dispatcher, never, Scope.Scope>

Source

Since v4.0.0

Service tag for the paired Node http and https agents used by the node:http-backed HTTP client.

Signature

declare class HttpAgent

Source

Since v4.0.0

Provides the HttpAgent service using default scoped Node http and https agents.

Signature

declare const layerAgent: Layer.Layer<HttpAgent, never, never>

Source

Since v4.0.0

Provides the HttpAgent service using scoped Node http and https agents configured with the supplied options.

Signature

declare const layerAgentOptions: (options?: Https.AgentOptions | undefined) => Layer.Layer<HttpAgent>

Source

Since v4.0.0

Acquires Node http and https agents with the supplied options and destroys both agents when the enclosing scope is finalized.

Signature

declare const makeAgent: (options?: Https.AgentOptions) => Effect.Effect<HttpAgent["Service"], never, Scope.Scope>

Source

Since v4.0.0

Fiber reference containing default Undici request options applied to requests sent by makeUndici.

Signature

declare const UndiciOptions: Context.Reference<Partial<Undici.Dispatcher.RequestOptions<null>>>

Source

Since v4.0.0

Provides an Undici-backed HttpClient together with a scoped default Undici Agent dispatcher.

Signature

declare const layerUndici: Layer.Layer<Client.HttpClient, never, never>

Source

Since v4.0.0

Provides an Undici-backed HttpClient using the current Dispatcher service.

Signature

declare const layerUndiciNoDispatcher: Layer.Layer<Client.HttpClient, never, Dispatcher>

Source

Since v4.0.0

Creates an HttpClient that sends requests through the current Undici Dispatcher, converts Effect HTTP bodies to Undici bodies, and maps transport and decode failures to HttpClientError.

Signature

declare const makeUndici: Effect.Effect<Client.HttpClient, never, Dispatcher>

Source

Since v4.0.0

Provides a fetch-based HTTP client implementation for Node.js.

When to use

Use to access or override the fetch implementation used by the Node fetch-based HTTP client.

Signature

declare const Fetch: Context.Reference<{
(input: RequestInfo | URL, init?: RequestInit): Promise<Response>
(input: string | URL | Request, init?: RequestInit): Promise<Response>
}>

Source

Since v4.0.0

Provides request initialization options accepted by the fetch-based HTTP client.

When to use

Use to provide default fetch request options for Node HTTP requests.

Signature

declare const RequestInit: typeof RequestInit

Source

Since v4.0.0

Layer that provides the fetch-based HTTP client implementation.

Signature

declare const layerFetch: Layer.Layer<Client.HttpClient, never, never>

Source

Since v4.0.0

Provides a node:http-backed HttpClient together with default scoped Node http and https agents.

Signature

declare const layerNodeHttp: Layer.Layer<Client.HttpClient, never, never>

Source

Since v4.0.0

Provides a node:http-backed HttpClient using the current HttpAgent service.

Signature

declare const layerNodeHttpNoAgent: Layer.Layer<Client.HttpClient, never, HttpAgent>

Source

Since v4.0.0

Creates an HttpClient backed by Node http and https, using the current HttpAgent, streaming request bodies, and wrapping Node responses as HttpClientResponse values.

Signature

declare const makeNodeHttp: Effect.Effect<Client.HttpClient, never, HttpAgent>

Source

Since v4.0.0