Skip to content

NodeHttpPlatform

Node.js implementation of the Effect HTTP platform service.

This module connects the portable HttpPlatform file response helpers to Node runtime primitives. It serves local files through Node readable streams, supports byte ranges, converts Web File values to readable streams, and fills in content type and content length headers when needed.

2 exports Added in v4.0.0 Source

Constructors

make

Added in v4.0.0 Source

Creates the Node HttpPlatform, serving file responses from Node readable streams and adding MIME type and content-length headers when needed.

Signature

declare const make: Effect<
  {
    readonly fileResponse: (
      path: string,
      options?: WithContent & {
        readonly bytesToRead?: SizeInput;
        readonly chunkSize?: SizeInput;
        readonly offset?: SizeInput;
      },
    ) => Effect<HttpServerResponse, PlatformError>;
    readonly fileWebResponse: (
      file: FileLike,
      options?: WithContent & {
        readonly bytesToRead?: SizeInput;
        readonly chunkSize?: SizeInput;
        readonly offset?: SizeInput;
      },
    ) => Effect<HttpServerResponse>;
  },
  never,
  Generator | FileSystem
>;

Layers

layer

Added in v4.0.0 Source

Provides the Node HttpPlatform together with the filesystem and ETag services it needs for file responses.

Signature

declare const layer: Layer.Layer<Platform.HttpPlatform>;