NodeHttpServer
Constructors
Signature
declare const make: (
evaluate: LazyArg<Http.Server<typeof Http.IncomingMessage, typeof Http.ServerResponse>>,
options: Net.ListenOptions,
) => Effect.Effect<Server.HttpServer, ServeError, Scope.Scope>;makeHandler
Added in v1.0.0
Source
Signature
declare const makeHandler: {
<R, E>(
httpApp: Default<E, R>,
): Effect<(nodeRequest: IncomingMessage, nodeResponse: ServerResponse) => void, never, any>;
<R, E, App extends Default<any, any>>(
httpApp: Default<E, R>,
middleware: Applied<App, E, R>,
): Effect<(nodeRequest: IncomingMessage, nodeResponse: ServerResponse) => void, never, any>;
};Layers
Signature
declare const layer: (
evaluate: LazyArg<Http.Server<typeof Http.IncomingMessage, typeof Http.ServerResponse>>,
options: Net.ListenOptions,
) => Layer.Layer<
Platform.HttpPlatform | Etag.Generator | NodeContext.NodeContext | Server.HttpServer,
ServeError
>;layerConfig
Added in v1.0.0
Source
Signature
declare const layerConfig: (
evaluate: LazyArg<Http.Server<typeof Http.IncomingMessage, typeof Http.ServerResponse>>,
options: Config.Config.Wrap<Net.ListenOptions>,
) => Layer.Layer<
Platform.HttpPlatform | Etag.Generator | NodeContext.NodeContext | Server.HttpServer,
ConfigError.ConfigError | ServeError
>;layerContext
Added in v1.0.0
Source
Signature
declare const layerContext: Layer.Layer<
Platform.HttpPlatform | Etag.Generator | NodeContext.NodeContext
>;layerServer
Added in v1.0.0
Source
Signature
declare const layerServer: (
evaluate: LazyArg<Http.Server>,
options: Net.ListenOptions,
) => Layer.Layer<Server.HttpServer, ServeError>;Layer starting a server on a random port and producing an HttpClient with prepended url of the running http server.
Signature
declare const layerTest: Layer.Layer<
| HttpClient.HttpClient
| Server.HttpServer
| Platform.HttpPlatform
| Etag.Generator
| NodeContext.NodeContext,
ServeError
>;Example
import * as assert from "node:assert"
import { HttpClient, HttpRouter, HttpServer } from "@effect/platform"
import { NodeHttpServer } from "@effect/platform-node"
import { Effect } from "effect"
Effect.gen(function* () {
yield* HttpServer.serveEffect(HttpRouter.empty)
const response = yield* HttpClient.get("/")
assert.strictEqual(response.status, 404)
}).pipe(Effect.provide(NodeHttpServer.layerTest))
A Layer providing the
HttpPlatform,FileSystem,Etag.Generator, andPathservices.The
FileSystemservice is a no-op implementation, so this layer is only useful for platforms that have no file system.