NodeHttpServer overview
Added in v1.0.0
Table of contents
constructors
make
Signature
export declare const make: (
evaluate: LazyArg<Http.Server<typeof Http.IncomingMessage, typeof Http.ServerResponse>>,
options: Net.ListenOptions
) => Effect.Effect<Server.HttpServer, ServeError, Scope.Scope>
Added in v1.0.0
makeHandler
Signature
export declare const makeHandler: {
<R, E>(
httpApp: App.Default<E, R>
): Effect.Effect<
(nodeRequest: Http.IncomingMessage, nodeResponse: Http.ServerResponse) => void,
never,
Exclude<R, ServerRequest.HttpServerRequest | Scope.Scope>
>
<R, E, App extends App.Default<any, any>>(
httpApp: App.Default<E, R>,
middleware: Middleware.HttpMiddleware.Applied<App, E, R>
): Effect.Effect<
(nodeRequest: Http.IncomingMessage, nodeResponse: Http.ServerResponse) => void,
never,
Exclude<Effect.Effect.Context<App>, ServerRequest.HttpServerRequest | Scope.Scope>
>
}
Added in v1.0.0
layers
layer
Signature
export 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>
Added in v1.0.0
layerConfig
Signature
export 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
>
Added in v1.0.0
layerServer
Signature
export declare const layerServer: (
evaluate: LazyArg<Http.Server>,
options: Net.ListenOptions
) => Layer.Layer<Server.HttpServer, ServeError>
Added in v1.0.0
layerTest
Layer starting a server on a random port and producing an HttpClient
with prepended url of the running http server.
Signature
export declare const layerTest: Layer.Layer<any, ServeError>
Example
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))
Added in v1.0.0