@effect/platform-node 4.0.0-beta.66 → 4.0.0-beta.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/Mime.d.ts +3 -3
  2. package/dist/Mime.js +3 -3
  3. package/dist/NodeChildProcessSpawner.d.ts +1 -1
  4. package/dist/NodeChildProcessSpawner.js +1 -1
  5. package/dist/NodeClusterHttp.d.ts +44 -4
  6. package/dist/NodeClusterHttp.d.ts.map +1 -1
  7. package/dist/NodeClusterHttp.js +10 -3
  8. package/dist/NodeClusterHttp.js.map +1 -1
  9. package/dist/NodeClusterSocket.d.ts +46 -6
  10. package/dist/NodeClusterSocket.d.ts.map +1 -1
  11. package/dist/NodeClusterSocket.js +46 -6
  12. package/dist/NodeClusterSocket.js.map +1 -1
  13. package/dist/NodeFileSystem.d.ts +3 -1
  14. package/dist/NodeFileSystem.d.ts.map +1 -1
  15. package/dist/NodeFileSystem.js +21 -2
  16. package/dist/NodeFileSystem.js.map +1 -1
  17. package/dist/NodeHttpClient.d.ts +91 -19
  18. package/dist/NodeHttpClient.d.ts.map +1 -1
  19. package/dist/NodeHttpClient.js +91 -19
  20. package/dist/NodeHttpClient.js.map +1 -1
  21. package/dist/NodeHttpIncomingMessage.d.ts +21 -3
  22. package/dist/NodeHttpIncomingMessage.d.ts.map +1 -1
  23. package/dist/NodeHttpIncomingMessage.js +21 -3
  24. package/dist/NodeHttpIncomingMessage.js.map +1 -1
  25. package/dist/NodeHttpPlatform.d.ts +8 -2
  26. package/dist/NodeHttpPlatform.d.ts.map +1 -1
  27. package/dist/NodeHttpPlatform.js +30 -3
  28. package/dist/NodeHttpPlatform.js.map +1 -1
  29. package/dist/NodeHttpServer.d.ts +35 -8
  30. package/dist/NodeHttpServer.d.ts.map +1 -1
  31. package/dist/NodeHttpServer.js +65 -9
  32. package/dist/NodeHttpServer.js.map +1 -1
  33. package/dist/NodeHttpServerRequest.d.ts +29 -3
  34. package/dist/NodeHttpServerRequest.d.ts.map +1 -1
  35. package/dist/NodeHttpServerRequest.js +9 -2
  36. package/dist/NodeHttpServerRequest.js.map +1 -1
  37. package/dist/NodeMultipart.d.ts +31 -4
  38. package/dist/NodeMultipart.d.ts.map +1 -1
  39. package/dist/NodeMultipart.js +31 -4
  40. package/dist/NodeMultipart.js.map +1 -1
  41. package/dist/NodePath.d.ts +12 -3
  42. package/dist/NodePath.d.ts.map +1 -1
  43. package/dist/NodePath.js +27 -4
  44. package/dist/NodePath.js.map +1 -1
  45. package/dist/NodeRedis.d.ts +33 -4
  46. package/dist/NodeRedis.d.ts.map +1 -1
  47. package/dist/NodeRedis.js +33 -4
  48. package/dist/NodeRedis.js.map +1 -1
  49. package/dist/NodeRuntime.d.ts +3 -3
  50. package/dist/NodeRuntime.d.ts.map +1 -1
  51. package/dist/NodeRuntime.js +16 -2
  52. package/dist/NodeRuntime.js.map +1 -1
  53. package/dist/NodeServices.d.ts +26 -3
  54. package/dist/NodeServices.d.ts.map +1 -1
  55. package/dist/NodeServices.js +4 -1
  56. package/dist/NodeServices.js.map +1 -1
  57. package/dist/NodeSink.d.ts +2 -2
  58. package/dist/NodeSink.js +2 -2
  59. package/dist/NodeSocket.d.ts +14 -4
  60. package/dist/NodeSocket.d.ts.map +1 -1
  61. package/dist/NodeSocket.js +32 -5
  62. package/dist/NodeSocket.js.map +1 -1
  63. package/dist/NodeSocketServer.d.ts +2 -2
  64. package/dist/NodeSocketServer.js +2 -2
  65. package/dist/NodeStdio.d.ts +4 -1
  66. package/dist/NodeStdio.d.ts.map +1 -1
  67. package/dist/NodeStdio.js +21 -2
  68. package/dist/NodeStdio.js.map +1 -1
  69. package/dist/NodeStream.d.ts +2 -2
  70. package/dist/NodeStream.js +2 -2
  71. package/dist/NodeTerminal.d.ts +8 -2
  72. package/dist/NodeTerminal.d.ts.map +1 -1
  73. package/dist/NodeTerminal.js +19 -3
  74. package/dist/NodeTerminal.js.map +1 -1
  75. package/dist/NodeWorker.d.ts +9 -2
  76. package/dist/NodeWorker.d.ts.map +1 -1
  77. package/dist/NodeWorker.js +28 -3
  78. package/dist/NodeWorker.js.map +1 -1
  79. package/dist/NodeWorkerRunner.d.ts +5 -1
  80. package/dist/NodeWorkerRunner.d.ts.map +1 -1
  81. package/dist/NodeWorkerRunner.js +24 -2
  82. package/dist/NodeWorkerRunner.js.map +1 -1
  83. package/dist/Undici.d.ts +3 -3
  84. package/dist/Undici.js +3 -3
  85. package/dist/index.d.ts +25 -25
  86. package/dist/index.js +25 -25
  87. package/package.json +6 -6
  88. package/src/Mime.ts +3 -3
  89. package/src/NodeChildProcessSpawner.ts +1 -1
  90. package/src/NodeClusterHttp.ts +44 -4
  91. package/src/NodeClusterSocket.ts +46 -6
  92. package/src/NodeFileSystem.ts +21 -2
  93. package/src/NodeHttpClient.ts +91 -19
  94. package/src/NodeHttpIncomingMessage.ts +21 -3
  95. package/src/NodeHttpPlatform.ts +30 -3
  96. package/src/NodeHttpServer.ts +65 -9
  97. package/src/NodeHttpServerRequest.ts +29 -3
  98. package/src/NodeMultipart.ts +31 -4
  99. package/src/NodePath.ts +27 -4
  100. package/src/NodeRedis.ts +33 -4
  101. package/src/NodeRuntime.ts +18 -4
  102. package/src/NodeServices.ts +26 -3
  103. package/src/NodeSink.ts +2 -2
  104. package/src/NodeSocket.ts +32 -5
  105. package/src/NodeSocketServer.ts +2 -2
  106. package/src/NodeStdio.ts +21 -2
  107. package/src/NodeStream.ts +2 -2
  108. package/src/NodeTerminal.ts +19 -3
  109. package/src/NodeWorker.ts +28 -3
  110. package/src/NodeWorkerRunner.ts +24 -2
  111. package/src/Undici.ts +3 -3
  112. package/src/index.ts +25 -25
@@ -1,5 +1,38 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * The `NodeClusterHttp` module provides the Node.js HTTP and WebSocket
3
+ * transports for Effect Cluster runners. It wires `HttpRunner` to the Node HTTP
4
+ * server, supplies Undici and WebSocket client protocols, and builds a complete
5
+ * sharding layer with serialization, runner health, runner storage, and message
6
+ * storage.
7
+ *
8
+ * **Common tasks**
9
+ *
10
+ * - Run a Node process as a cluster runner over HTTP or WebSocket with
11
+ * {@link layer}
12
+ * - Connect a client-only process to an existing HTTP cluster without starting
13
+ * a runner server
14
+ * - Use SQL-backed storage for durable multi-process clusters, `local` storage
15
+ * for short-lived development, or `byo` storage when the deployment owns the
16
+ * persistence boundary
17
+ * - Check runner health with protocol pings or Kubernetes pod readiness through
18
+ * {@link layerK8sHttpClient}
19
+ *
20
+ * **Gotchas**
21
+ *
22
+ * - `runnerAddress` is the host and port advertised to other runners; set
23
+ * `runnerListenAddress` when the local bind address differs from the
24
+ * externally reachable address
25
+ * - The HTTP and WebSocket transports serve runner RPCs at the default
26
+ * `HttpRunner` route, so proxies and load balancers must preserve the path
27
+ * and allow WebSocket upgrades when `transport` is `"websocket"`
28
+ * - `clientOnly` does not start an HTTP server or receive shard assignments
29
+ * - SQL storage is the default; `local` storage is in-memory/noop and `byo`
30
+ * requires the surrounding application to provide both runner and message
31
+ * storage services
32
+ * - Ping health checks use the selected transport and serialization, so route,
33
+ * port, proxy, or codec mismatches can make a runner appear unhealthy
34
+ *
35
+ * @since 4.0.0
3
36
  */
4
37
  import type * as Config from "effect/Config"
5
38
  import * as Effect from "effect/Effect"
@@ -29,15 +62,19 @@ import * as NodeSocket from "./NodeSocket.ts"
29
62
 
30
63
  export {
31
64
  /**
32
- * @since 1.0.0
33
65
  * @category Re-exports
66
+ * @since 4.0.0
34
67
  */
35
68
  layerK8sHttpClient
36
69
  } from "./NodeClusterSocket.ts"
37
70
 
38
71
  /**
39
- * @since 1.0.0
72
+ * Builds the Node cluster HTTP/WebSocket sharding layer, configuring runner
73
+ * transport, RPC serialization, message storage, runner health checks, and
74
+ * optional client-only mode.
75
+ *
40
76
  * @category Layers
77
+ * @since 4.0.0
41
78
  */
42
79
  export const layer = <
43
80
  const ClientOnly extends boolean = false,
@@ -117,8 +154,11 @@ export const layer = <
117
154
  }
118
155
 
119
156
  /**
120
- * @since 1.0.0
157
+ * Provides the HTTP server and Node HTTP services used by cluster runners,
158
+ * listening on `ShardingConfig.runnerListenAddress` or `runnerAddress`.
159
+ *
121
160
  * @category Layers
161
+ * @since 4.0.0
122
162
  */
123
163
  export const layerHttpServer: Layer.Layer<
124
164
  | HttpPlatform
@@ -1,5 +1,34 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * The `NodeClusterSocket` module provides the Node.js socket transport for
3
+ * Effect Cluster runners. It wires `SocketRunner` to Node TCP sockets, supplies
4
+ * RPC client and server protocol layers, and builds a complete sharding layer
5
+ * with serialization, runner health, runner storage, and message storage.
6
+ *
7
+ * **Common tasks**
8
+ *
9
+ * - Run a Node process as a cluster runner over raw TCP sockets with
10
+ * {@link layer}
11
+ * - Connect a client-only process to an existing socket cluster without
12
+ * starting a runner server
13
+ * - Use SQL-backed storage for durable multi-process clusters, `local` storage
14
+ * for short-lived development, or `byo` storage when the deployment owns the
15
+ * persistence boundary
16
+ * - Check runner health with socket pings or Kubernetes pod readiness through
17
+ * {@link layerK8sHttpClient}
18
+ *
19
+ * **Gotchas**
20
+ *
21
+ * - `runnerAddress` is the host and port advertised to other runners; set
22
+ * `runnerListenAddress` when the local bind address differs from the
23
+ * externally reachable address
24
+ * - The socket transport is point-to-point RPC, not cluster gossip: runner
25
+ * membership, shard ownership, and persisted delivery are coordinated through
26
+ * `RunnerStorage`, `MessageStorage`, and `RunnerHealth`
27
+ * - `clientOnly` does not start a socket server or receive shard assignments
28
+ * - Ping health checks use the same socket protocol, so unreachable ports,
29
+ * firewalls, or serialization mismatches can make a runner appear unhealthy
30
+ *
31
+ * @since 4.0.0
3
32
  */
4
33
  import { layerClientProtocol, layerSocketServer } from "@effect/platform-node-shared/NodeClusterSocket"
5
34
  import type { ConfigError } from "effect/Config"
@@ -25,20 +54,24 @@ import * as Undici from "./Undici.ts"
25
54
 
26
55
  export {
27
56
  /**
28
- * @since 1.0.0
29
57
  * @category Re-exports
58
+ * @since 4.0.0
30
59
  */
31
60
  layerClientProtocol,
32
61
  /**
33
- * @since 1.0.0
34
62
  * @category Re-exports
63
+ * @since 4.0.0
35
64
  */
36
65
  layerSocketServer
37
66
  }
38
67
 
39
68
  /**
40
- * @since 1.0.0
69
+ * Builds the Node cluster socket sharding layer, configuring RPC
70
+ * serialization, message storage, runner health checks, and optional
71
+ * client-only mode.
72
+ *
41
73
  * @category Layers
74
+ * @since 4.0.0
42
75
  */
43
76
  export const layer = <
44
77
  const ClientOnly extends boolean = false,
@@ -111,8 +144,12 @@ export const layer = <
111
144
  }
112
145
 
113
146
  /**
114
- * @since 1.0.0
147
+ * Provides an Undici dispatcher for Kubernetes API calls, using the service
148
+ * account CA certificate when it is available and falling back to the default
149
+ * dispatcher otherwise.
150
+ *
115
151
  * @category Layers
152
+ * @since 4.0.0
116
153
  */
117
154
  export const layerDispatcherK8s: Layer.Layer<NodeHttpClient.Dispatcher> = Layer.effect(NodeHttpClient.Dispatcher)(
118
155
  Effect.gen(function*() {
@@ -140,8 +177,11 @@ export const layerDispatcherK8s: Layer.Layer<NodeHttpClient.Dispatcher> = Layer.
140
177
  )
141
178
 
142
179
  /**
143
- * @since 1.0.0
180
+ * Provides a `K8sHttpClient` backed by the Undici HTTP client and the
181
+ * Kubernetes-aware dispatcher.
182
+ *
144
183
  * @category Layers
184
+ * @since 4.0.0
145
185
  */
146
186
  export const layerK8sHttpClient: Layer.Layer<K8sHttpClient.K8sHttpClient> = K8sHttpClient.layer.pipe(
147
187
  Layer.provide(Layer.fresh(NodeHttpClient.layerUndiciNoDispatcher)),
@@ -1,12 +1,31 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Provides the Node.js `FileSystem` layer for Effect programs.
3
+ *
4
+ * Use this module when a Node application, CLI, script, or test needs to
5
+ * satisfy the `FileSystem` service with real filesystem access for reading and
6
+ * writing files, creating directories and temporary files, inspecting metadata,
7
+ * managing links, or watching paths for changes.
8
+ *
9
+ * This module only exposes the Node-backed layer; filesystem operations are
10
+ * accessed through the `FileSystem` service from `effect/FileSystem`. Provide
11
+ * `NodeFileSystem.layer` at the edge of the program, or use
12
+ * `NodeServices.layer` when you also want the standard Node path, stdio,
13
+ * terminal, and child process services. The implementation is shared with
14
+ * other Node-compatible platform packages, so optional services such as
15
+ * `FileSystem.WatchBackend` are honored when present; otherwise file watching
16
+ * follows Node's `node:fs.watch` behavior. Paths are interpreted by Node, so
17
+ * relative paths use the current working directory and platform path rules.
18
+ *
19
+ * @since 4.0.0
3
20
  */
4
21
  import * as NodeFileSystem from "@effect/platform-node-shared/NodeFileSystem"
5
22
  import type { FileSystem } from "effect/FileSystem"
6
23
  import type * as Layer from "effect/Layer"
7
24
 
8
25
  /**
9
- * @since 1.0.0
26
+ * Provides the `FileSystem` service backed by Node filesystem APIs.
27
+ *
10
28
  * @category layer
29
+ * @since 4.0.0
11
30
  */
12
31
  export const layer: Layer.Layer<FileSystem> = NodeFileSystem.layer
@@ -1,5 +1,31 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Node.js implementations of the Effect `HttpClient`.
3
+ *
4
+ * This module provides the Node-specific layers and constructors for sending
5
+ * Effect HTTP client requests. It re-exports the fetch-based client for
6
+ * programs that want to use `globalThis.fetch`, provides an Undici-backed
7
+ * client for applications that need Undici dispatcher control, and provides a
8
+ * lower-level `node:http` / `node:https` client for integrations that need
9
+ * native Node agent configuration.
10
+ *
11
+ * Use these clients in server-side applications, CLIs, tests, and integrations
12
+ * where requests should participate in Effect resource management, interruption,
13
+ * streaming, and typed transport / decode errors. The Undici path sends each
14
+ * request through the current `Dispatcher`; `layerUndici` owns a scoped
15
+ * `Agent`, while `dispatcherLayerGlobal` uses Undici's process-global dispatcher
16
+ * without destroying it. The `node:http` path uses separate scoped HTTP and
17
+ * HTTPS agents, making it the right choice when native agent options such as
18
+ * TLS, proxy, keep-alive, or socket behavior need to be configured directly.
19
+ *
20
+ * The backends are not completely interchangeable. Fetch, Undici, and
21
+ * `node:http` expose different agent and dispatcher hooks, body implementations,
22
+ * abort behavior, upgrade support, and response body readers. This module
23
+ * converts Effect request bodies to the selected runtime representation:
24
+ * streams remain streaming, `FormData` may contribute generated content headers,
25
+ * and body read failures are reported as `HttpClientError` decode or transport
26
+ * errors.
27
+ *
28
+ * @since 4.0.0
3
29
  */
4
30
  import * as Context from "effect/Context"
5
31
  import * as Effect from "effect/Effect"
@@ -36,18 +62,18 @@ import * as Undici from "./Undici.ts"
36
62
 
37
63
  export {
38
64
  /**
39
- * @since 1.0.0
40
65
  * @category Fetch
66
+ * @since 4.0.0
41
67
  */
42
68
  Fetch,
43
69
  /**
44
- * @since 1.0.0
45
70
  * @category Fetch
71
+ * @since 4.0.0
46
72
  */
47
73
  layer as layerFetch,
48
74
  /**
49
- * @since 1.0.0
50
75
  * @category Fetch
76
+ * @since 4.0.0
51
77
  */
52
78
  RequestInit
53
79
  } from "effect/unstable/http/FetchHttpClient"
@@ -57,16 +83,22 @@ export {
57
83
  // -----------------------------------------------------------------------------
58
84
 
59
85
  /**
60
- * @since 1.0.0
86
+ * Service tag for the Undici `Dispatcher` used by the Undici-backed HTTP
87
+ * client.
88
+ *
61
89
  * @category Dispatcher
90
+ * @since 4.0.0
62
91
  */
63
92
  export class Dispatcher extends Context.Service<Dispatcher, Undici.Dispatcher>()(
64
93
  "@effect/platform-node/NodeHttpClient/Dispatcher"
65
94
  ) {}
66
95
 
67
96
  /**
68
- * @since 1.0.0
97
+ * Acquires a new Undici `Agent` dispatcher and destroys it when the enclosing
98
+ * scope is finalized.
99
+ *
69
100
  * @category Dispatcher
101
+ * @since 4.0.0
70
102
  */
71
103
  export const makeDispatcher: Effect.Effect<Undici.Dispatcher, never, Scope.Scope> = Effect.acquireRelease(
72
104
  Effect.sync(() => new Undici.Agent()),
@@ -74,20 +106,28 @@ export const makeDispatcher: Effect.Effect<Undici.Dispatcher, never, Scope.Scope
74
106
  )
75
107
 
76
108
  /**
77
- * @since 1.0.0
109
+ * Provides the `Dispatcher` service using a scoped Undici `Agent`.
110
+ *
78
111
  * @category Dispatcher
112
+ * @since 4.0.0
79
113
  */
80
114
  export const layerDispatcher: Layer.Layer<Dispatcher> = Layer.effect(Dispatcher)(makeDispatcher)
81
115
 
82
116
  /**
83
- * @since 1.0.0
117
+ * Provides the `Dispatcher` service from Undici's process-global dispatcher,
118
+ * without creating or owning a new agent.
119
+ *
84
120
  * @category Dispatcher
121
+ * @since 4.0.0
85
122
  */
86
123
  export const dispatcherLayerGlobal: Layer.Layer<Dispatcher> = Layer.sync(Dispatcher)(() => Undici.getGlobalDispatcher())
87
124
 
88
125
  /**
89
- * @since 1.0.0
126
+ * Fiber reference containing default Undici request options applied to requests
127
+ * sent by `makeUndici`.
128
+ *
90
129
  * @category undici
130
+ * @since 4.0.0
91
131
  */
92
132
  export const UndiciOptions = Context.Reference<Partial<Undici.Dispatcher.RequestOptions>>(
93
133
  "@effect/platform-node/NodeHttpClient/UndiciOptions",
@@ -95,8 +135,12 @@ export const UndiciOptions = Context.Reference<Partial<Undici.Dispatcher.Request
95
135
  )
96
136
 
97
137
  /**
98
- * @since 1.0.0
138
+ * Creates an `HttpClient` that sends requests through the current Undici
139
+ * `Dispatcher`, converts Effect HTTP bodies to Undici bodies, and maps
140
+ * transport and decode failures to `HttpClientError`.
141
+ *
99
142
  * @category undici
143
+ * @since 4.0.0
100
144
  */
101
145
  export const makeUndici = Effect.gen(function*() {
102
146
  const dispatcher = yield* Dispatcher
@@ -309,8 +353,11 @@ class UndiciResponse extends Inspectable.Class implements HttpClientResponse, Pi
309
353
  }
310
354
 
311
355
  /**
312
- * @since 1.0.0
356
+ * Provides an Undici-backed `HttpClient` using the current `Dispatcher`
357
+ * service.
358
+ *
313
359
  * @category Undici
360
+ * @since 4.0.0
314
361
  */
315
362
  export const layerUndiciNoDispatcher: Layer.Layer<
316
363
  Client.HttpClient,
@@ -319,8 +366,11 @@ export const layerUndiciNoDispatcher: Layer.Layer<
319
366
  > = Client.layerMergedContext(makeUndici)
320
367
 
321
368
  /**
322
- * @since 1.0.0
369
+ * Provides an Undici-backed `HttpClient` together with a scoped default
370
+ * Undici `Agent` dispatcher.
371
+ *
323
372
  * @category Undici
373
+ * @since 4.0.0
324
374
  */
325
375
  export const layerUndici: Layer.Layer<Client.HttpClient> = Layer.provide(layerUndiciNoDispatcher, layerDispatcher)
326
376
 
@@ -329,8 +379,11 @@ export const layerUndici: Layer.Layer<Client.HttpClient> = Layer.provide(layerUn
329
379
  // -----------------------------------------------------------------------------
330
380
 
331
381
  /**
332
- * @since 1.0.0
382
+ * Service tag for the paired Node `http` and `https` agents used by the
383
+ * node:http-backed HTTP client.
384
+ *
333
385
  * @category HttpAgent
386
+ * @since 4.0.0
334
387
  */
335
388
  export class HttpAgent extends Context.Service<HttpAgent, {
336
389
  readonly http: Http.Agent
@@ -338,8 +391,11 @@ export class HttpAgent extends Context.Service<HttpAgent, {
338
391
  }>()("@effect/platform-node/NodeHttpClient/HttpAgent") {}
339
392
 
340
393
  /**
341
- * @since 1.0.0
394
+ * Acquires Node `http` and `https` agents with the supplied options and
395
+ * destroys both agents when the enclosing scope is finalized.
396
+ *
342
397
  * @category HttpAgent
398
+ * @since 4.0.0
343
399
  */
344
400
  export const makeAgent = (options?: Https.AgentOptions): Effect.Effect<HttpAgent["Service"], never, Scope.Scope> =>
345
401
  Effect.zipWith(
@@ -355,22 +411,32 @@ export const makeAgent = (options?: Https.AgentOptions): Effect.Effect<HttpAgent
355
411
  )
356
412
 
357
413
  /**
358
- * @since 1.0.0
414
+ * Provides the `HttpAgent` service using scoped Node `http` and `https`
415
+ * agents configured with the supplied options.
416
+ *
359
417
  * @category HttpAgent
418
+ * @since 4.0.0
360
419
  */
361
420
  export const layerAgentOptions: (options?: Https.AgentOptions | undefined) => Layer.Layer<
362
421
  HttpAgent
363
422
  > = flow(makeAgent, Layer.effect(HttpAgent))
364
423
 
365
424
  /**
366
- * @since 1.0.0
425
+ * Provides the `HttpAgent` service using default scoped Node `http` and
426
+ * `https` agents.
427
+ *
367
428
  * @category HttpAgent
429
+ * @since 4.0.0
368
430
  */
369
431
  export const layerAgent: Layer.Layer<HttpAgent> = layerAgentOptions()
370
432
 
371
433
  /**
372
- * @since 1.0.0
434
+ * Creates an `HttpClient` backed by Node `http` and `https`, using the
435
+ * current `HttpAgent`, streaming request bodies, and wrapping Node responses
436
+ * as `HttpClientResponse` values.
437
+ *
373
438
  * @category node:http
439
+ * @since 4.0.0
374
440
  */
375
441
  export const makeNodeHttp = Effect.gen(function*() {
376
442
  const agent = yield* HttpAgent
@@ -579,8 +645,11 @@ class NodeHttpResponse extends NodeHttpIncomingMessage<Error.HttpClientError> im
579
645
  }
580
646
 
581
647
  /**
582
- * @since 1.0.0
648
+ * Provides a node:http-backed `HttpClient` using the current `HttpAgent`
649
+ * service.
650
+ *
583
651
  * @category node:http
652
+ * @since 4.0.0
584
653
  */
585
654
  export const layerNodeHttpNoAgent: Layer.Layer<
586
655
  Client.HttpClient,
@@ -589,7 +658,10 @@ export const layerNodeHttpNoAgent: Layer.Layer<
589
658
  > = Client.layerMergedContext(makeNodeHttp)
590
659
 
591
660
  /**
592
- * @since 1.0.0
661
+ * Provides a node:http-backed `HttpClient` together with default scoped Node
662
+ * `http` and `https` agents.
663
+ *
593
664
  * @category node:http
665
+ * @since 4.0.0
594
666
  */
595
667
  export const layerNodeHttp: Layer.Layer<Client.HttpClient> = Layer.provide(layerNodeHttpNoAgent, layerAgent)
@@ -1,5 +1,17 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Utilities for adapting Node `http.IncomingMessage` values to the Effect HTTP
3
+ * incoming message interface used by the platform Node server and client
4
+ * implementations.
5
+ *
6
+ * This module is useful when code needs to keep access to Node's request or
7
+ * response object while also exposing Effect's typed headers, remote address,
8
+ * body decoders, and stream interface. The body helpers consume Node's readable
9
+ * stream, cache decoded text and array-buffer results, and honor the
10
+ * `HttpIncomingMessage.MaxBodySize` fiber ref. Prefer a single body access
11
+ * strategy per message: raw `stream` access is not cached, and Node request
12
+ * bodies cannot be replayed once the underlying stream has been consumed.
13
+ *
14
+ * @since 4.0.0
3
15
  */
4
16
  import * as Effect from "effect/Effect"
5
17
  import * as Inspectable from "effect/Inspectable"
@@ -13,14 +25,20 @@ import type * as Http from "node:http"
13
25
  import * as NodeStream from "./NodeStream.ts"
14
26
 
15
27
  /**
16
- * @since 1.0.0
28
+ * Base adapter from Node `IncomingMessage` to Effect HTTP incoming messages,
29
+ * exposing headers, remote address, stream access, and cached text, JSON, URL
30
+ * parameter, and array-buffer body decoders with caller-provided error mapping.
31
+ *
17
32
  * @category Constructors
33
+ * @since 4.0.0
18
34
  */
19
35
  export abstract class NodeHttpIncomingMessage<E> extends Inspectable.Class
20
36
  implements IncomingMessage.HttpIncomingMessage<E>
21
37
  {
22
38
  /**
23
- * @since 1.0.0
39
+ * Marks this value as an HTTP incoming message for runtime guards.
40
+ *
41
+ * @since 4.0.0
24
42
  */
25
43
  readonly [IncomingMessage.TypeId]: typeof IncomingMessage.TypeId
26
44
  readonly source: Http.IncomingMessage
@@ -1,5 +1,26 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Node.js implementation of the Effect HTTP platform service.
3
+ *
4
+ * This module connects the portable `HttpPlatform` file response helpers to
5
+ * Node runtime primitives. It is used by Node HTTP servers and static file
6
+ * handlers when returning local files, public assets, downloads, byte ranges,
7
+ * or Web `File` values as `HttpServerResponse` bodies.
8
+ *
9
+ * Path-based responses are served with `node:fs.createReadStream`; Web `File`
10
+ * responses are bridged with `Readable.fromWeb`. The implementation fills in
11
+ * `content-type` from `Mime`, falls back to `application/octet-stream`, and
12
+ * writes the `content-length` for the selected range or whole file. Node's
13
+ * stream `end` option is inclusive, so the platform converts Effect's half-open
14
+ * range before reading. Empty bodies use an empty readable stream.
15
+ *
16
+ * Provide `layer` at the Node runtime edge when file responses, static serving,
17
+ * or response bodies created from files need real filesystem and ETag support.
18
+ * These responses are raw Node streams, so they are intended for the Node HTTP
19
+ * server adapter; keep files available until the response body has been
20
+ * consumed and prefer the portable `HttpServerResponse` constructors when a
21
+ * response does not depend on Node file or stream behavior.
22
+ *
23
+ * @since 4.0.0
3
24
  */
4
25
  import { pipe } from "effect/Function"
5
26
  import * as Layer from "effect/Layer"
@@ -13,8 +34,11 @@ import Mime from "./Mime.ts"
13
34
  import * as NodeFileSystem from "./NodeFileSystem.ts"
14
35
 
15
36
  /**
16
- * @since 1.0.0
37
+ * Creates the Node `HttpPlatform`, serving file responses from Node readable
38
+ * streams and adding MIME type and content-length headers when needed.
39
+ *
17
40
  * @category Constructors
41
+ * @since 4.0.0
18
42
  */
19
43
  export const make = Platform.make({
20
44
  fileResponse(path, status, statusText, headers, start, end, contentLength) {
@@ -47,8 +71,11 @@ export const make = Platform.make({
47
71
  })
48
72
 
49
73
  /**
50
- * @since 1.0.0
74
+ * Provides the Node `HttpPlatform` together with the filesystem and ETag
75
+ * services it needs for file responses.
76
+ *
51
77
  * @category Layers
78
+ * @since 4.0.0
52
79
  */
53
80
  export const layer: Layer.Layer<Platform.HttpPlatform> = pipe(
54
81
  Layer.effect(Platform.HttpPlatform)(make),
@@ -1,5 +1,34 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Node.js implementation of the Effect `HttpServer`.
3
+ *
4
+ * This module adapts a supplied Node `http.Server` into Effect's
5
+ * platform-independent HTTP server service. It starts the server with Node
6
+ * `listen` options, converts `request` events into `HttpServerRequest` values,
7
+ * writes `HttpServerResponse` bodies through Node's `ServerResponse`, and
8
+ * handles `upgrade` events by exposing the upgraded socket through
9
+ * `HttpServerRequest.upgrade`.
10
+ *
11
+ * Common use cases include serving an Effect HTTP application with {@link layer}
12
+ * or {@link layerConfig}, embedding request or upgrade handlers into an
13
+ * existing Node server with {@link makeHandler} and {@link makeUpgradeHandler},
14
+ * and using {@link layerTest} for integration tests that need an ephemeral
15
+ * listening port and a client pointed at it.
16
+ *
17
+ * Listen options are passed directly to Node, so host, port, backlog, and Unix
18
+ * socket path behavior follow `node:http`. The server begins listening when the
19
+ * `HttpServer` is acquired, and handlers are installed when `serve` is run.
20
+ * Request fibers are interrupted with `ClientAbort` when the client disconnects
21
+ * before a response finishes. WebSocket support only applies to Node `upgrade`
22
+ * requests, and ordinary HTTP requests fail if their application attempts to use
23
+ * `HttpServerRequest.upgrade`.
24
+ *
25
+ * Scope ownership is important: the server is closed when the acquiring scope
26
+ * finalizes, while each `serve` call installs its own request and upgrade
27
+ * listeners and removes them on finalization. Unless preemptive shutdown is
28
+ * disabled, finalizing a serve scope also starts a graceful server close, using
29
+ * the configured timeout or the default timeout.
30
+ *
31
+ * @since 4.0.0
3
32
  */
4
33
  import * as Cause from "effect/Cause"
5
34
  import * as Config from "effect/Config"
@@ -52,8 +81,12 @@ import * as NodeServices from "./NodeServices.ts"
52
81
  import { NodeWS } from "./NodeSocket.ts"
53
82
 
54
83
  /**
55
- * @since 1.0.0
84
+ * Creates a scoped `HttpServer` from a Node `http.Server`, starts listening
85
+ * with the supplied options, registers request and upgrade handling, and closes
86
+ * the server during scope finalization with optional graceful-shutdown control.
87
+ *
56
88
  * @category constructors
89
+ * @since 4.0.0
57
90
  */
58
91
  export const make = Effect.fnUntraced(function*(
59
92
  evaluate: LazyArg<Http.Server>,
@@ -145,8 +178,12 @@ export const make = Effect.fnUntraced(function*(
145
178
  })
146
179
 
147
180
  /**
148
- * @since 1.0.0
181
+ * Creates a Node `request` event handler for an Effect HTTP application,
182
+ * injecting a `HttpServerRequest` and interrupting the request fiber if the
183
+ * client closes the response before it finishes.
184
+ *
149
185
  * @category Handlers
186
+ * @since 4.0.0
150
187
  */
151
188
  export const makeHandler = <
152
189
  R,
@@ -183,8 +220,12 @@ export const makeHandler = <
183
220
  }
184
221
 
185
222
  /**
186
- * @since 1.0.0
223
+ * Creates a Node `upgrade` event handler for an Effect HTTP application,
224
+ * exposing the upgraded WebSocket as the request's `upgrade` effect and
225
+ * interrupting the request fiber when the socket closes early.
226
+ *
187
227
  * @category Handlers
228
+ * @since 4.0.0
188
229
  */
189
230
  export const makeUpgradeHandler = <
190
231
  R,
@@ -366,8 +407,11 @@ class ServerRequestImpl extends NodeHttpIncomingMessage<HttpServerError> impleme
366
407
  }
367
408
 
368
409
  /**
369
- * @since 1.0.0
410
+ * Provides an `HttpServer` by creating and managing a scoped Node
411
+ * `http.Server` with the supplied listen and shutdown options.
412
+ *
370
413
  * @category Layers
414
+ * @since 4.0.0
371
415
  */
372
416
  export const layerServer: (
373
417
  evaluate: LazyArg<Http.Server<typeof Http.IncomingMessage, typeof Http.ServerResponse>>,
@@ -378,8 +422,11 @@ export const layerServer: (
378
422
  ) => Layer.Layer<HttpServer.HttpServer, ServeError> = flow(make, Layer.effect(HttpServer.HttpServer))
379
423
 
380
424
  /**
381
- * @since 1.0.0
425
+ * Provides the Node HTTP support services used by `NodeHttpServer`, including
426
+ * the HTTP platform, ETag generator, and core Node platform services.
427
+ *
382
428
  * @category Layers
429
+ * @since 4.0.0
383
430
  */
384
431
  export const layerHttpServices: Layer.Layer<
385
432
  NodeServices.NodeServices | HttpPlatform.HttpPlatform | Etag.Generator
@@ -390,8 +437,11 @@ export const layerHttpServices: Layer.Layer<
390
437
  )
391
438
 
392
439
  /**
393
- * @since 1.0.0
440
+ * Provides a Node `HttpServer` together with the Node HTTP platform, ETag, and
441
+ * core platform services required to serve requests.
442
+ *
394
443
  * @category Layers
444
+ * @since 4.0.0
395
445
  */
396
446
  export const layer = (
397
447
  evaluate: LazyArg<Http.Server>,
@@ -409,8 +459,11 @@ export const layer = (
409
459
  )
410
460
 
411
461
  /**
412
- * @since 1.0.0
462
+ * Provides a Node `HttpServer` and HTTP support services, reading the listen
463
+ * and shutdown options from a `Config` value.
464
+ *
413
465
  * @category Layers
466
+ * @since 4.0.0
414
467
  */
415
468
  export const layerConfig = (
416
469
  evaluate: LazyArg<Http.Server>,
@@ -432,8 +485,11 @@ export const layerConfig = (
432
485
  )
433
486
 
434
487
  /**
435
- * @since 1.0.0
488
+ * Provides a test HTTP server listening on an ephemeral port together with a
489
+ * Fetch-backed `HttpClient` configured for server integration tests.
490
+ *
436
491
  * @category Testing
492
+ * @since 4.0.0
437
493
  */
438
494
  export const layerTest: Layer.Layer<
439
495
  | HttpServer.HttpServer