@effect/platform-bun 0.87.0 → 4.0.0-beta.0
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.
- package/dist/BunChildProcessSpawner.d.ts +7 -0
- package/dist/BunChildProcessSpawner.d.ts.map +1 -0
- package/dist/BunChildProcessSpawner.js +7 -0
- package/dist/BunChildProcessSpawner.js.map +1 -0
- package/dist/BunClusterHttp.d.ts +45 -0
- package/dist/BunClusterHttp.d.ts.map +1 -0
- package/dist/BunClusterHttp.js +48 -0
- package/dist/BunClusterHttp.js.map +1 -0
- package/dist/BunClusterSocket.d.ts +46 -0
- package/dist/BunClusterSocket.d.ts.map +1 -0
- package/dist/BunClusterSocket.js +60 -0
- package/dist/BunClusterSocket.js.map +1 -0
- package/dist/BunFileSystem.d.ts +8 -0
- package/dist/BunFileSystem.d.ts.map +1 -0
- package/dist/BunFileSystem.js.map +1 -0
- package/dist/BunHttpClient.d.ts +9 -0
- package/dist/BunHttpClient.d.ts.map +1 -0
- package/dist/BunHttpClient.js +9 -0
- package/dist/BunHttpClient.js.map +1 -0
- package/dist/BunHttpPlatform.d.ts +8 -0
- package/dist/BunHttpPlatform.d.ts.map +1 -0
- package/dist/BunHttpPlatform.js +35 -0
- package/dist/BunHttpPlatform.js.map +1 -0
- package/dist/BunHttpServer.d.ts +71 -0
- package/dist/BunHttpServer.d.ts.map +1 -0
- package/dist/{esm/internal/httpServer.js → BunHttpServer.js} +149 -118
- package/dist/BunHttpServer.js.map +1 -0
- package/dist/BunHttpServerRequest.d.ts +10 -0
- package/dist/BunHttpServerRequest.d.ts.map +1 -0
- package/dist/BunHttpServerRequest.js +6 -0
- package/dist/BunHttpServerRequest.js.map +1 -0
- package/dist/BunMultipart.d.ts +20 -0
- package/dist/BunMultipart.d.ts.map +1 -0
- package/dist/BunMultipart.js +17 -0
- package/dist/BunMultipart.js.map +1 -0
- package/dist/BunPath.d.ts +18 -0
- package/dist/BunPath.d.ts.map +1 -0
- package/dist/BunPath.js.map +1 -0
- package/dist/BunRedis.d.ts +35 -0
- package/dist/BunRedis.d.ts.map +1 -0
- package/dist/BunRedis.js +51 -0
- package/dist/BunRedis.js.map +1 -0
- package/dist/BunRuntime.d.ts +94 -0
- package/dist/BunRuntime.d.ts.map +1 -0
- package/dist/BunRuntime.js +33 -0
- package/dist/BunRuntime.js.map +1 -0
- package/dist/BunServices.d.ts +20 -0
- package/dist/BunServices.d.ts.map +1 -0
- package/dist/BunServices.js +12 -0
- package/dist/BunServices.js.map +1 -0
- package/dist/BunSink.d.ts.map +1 -0
- package/dist/BunSink.js.map +1 -0
- package/dist/BunSocket.d.ts +26 -0
- package/dist/BunSocket.d.ts.map +1 -0
- package/dist/BunSocket.js +18 -0
- package/dist/BunSocket.js.map +1 -0
- package/dist/BunSocketServer.d.ts.map +1 -0
- package/dist/BunSocketServer.js.map +1 -0
- package/dist/BunStdio.d.ts +8 -0
- package/dist/BunStdio.d.ts.map +1 -0
- package/dist/BunStdio.js +10 -0
- package/dist/BunStdio.js.map +1 -0
- package/dist/BunStream.d.ts +18 -0
- package/dist/BunStream.d.ts.map +1 -0
- package/dist/BunStream.js +44 -0
- package/dist/BunStream.js.map +1 -0
- package/dist/{dts/BunTerminal.d.ts → BunTerminal.d.ts} +2 -2
- package/dist/BunTerminal.d.ts.map +1 -0
- package/dist/{esm/BunTerminal.js → BunTerminal.js} +1 -1
- package/dist/BunTerminal.js.map +1 -0
- package/dist/BunWorker.d.ts +13 -0
- package/dist/BunWorker.d.ts.map +1 -0
- package/dist/BunWorker.js +59 -0
- package/dist/BunWorker.js.map +1 -0
- package/dist/BunWorkerRunner.d.ts +8 -0
- package/dist/BunWorkerRunner.d.ts.map +1 -0
- package/dist/BunWorkerRunner.js +88 -0
- package/dist/BunWorkerRunner.js.map +1 -0
- package/dist/index.d.ts +90 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/{esm/index.js → index.js} +21 -7
- package/dist/index.js.map +1 -0
- package/package.json +51 -195
- package/src/BunChildProcessSpawner.ts +6 -0
- package/src/BunClusterHttp.ts +48 -35
- package/src/BunClusterSocket.ts +55 -21
- package/src/BunFileSystem.ts +3 -3
- package/src/BunHttpClient.ts +9 -0
- package/src/BunHttpPlatform.ts +28 -9
- package/src/BunHttpServer.ts +510 -58
- package/src/BunHttpServerRequest.ts +4 -4
- package/src/BunMultipart.ts +22 -11
- package/src/BunPath.ts +5 -6
- package/src/BunRedis.ts +74 -0
- package/src/BunRuntime.ts +95 -3
- package/src/BunServices.ts +33 -0
- package/src/BunSocket.ts +20 -10
- package/src/BunStdio.ts +12 -0
- package/src/BunStream.ts +51 -0
- package/src/BunTerminal.ts +2 -2
- package/src/BunWorker.ts +63 -21
- package/src/BunWorkerRunner.ts +92 -11
- package/src/index.ts +37 -19
- package/BunClusterHttp/package.json +0 -6
- package/BunClusterSocket/package.json +0 -6
- package/BunCommandExecutor/package.json +0 -6
- package/BunContext/package.json +0 -6
- package/BunFileSystem/ParcelWatcher/package.json +0 -6
- package/BunFileSystem/package.json +0 -6
- package/BunHttpPlatform/package.json +0 -6
- package/BunHttpServer/package.json +0 -6
- package/BunHttpServerRequest/package.json +0 -6
- package/BunKeyValueStore/package.json +0 -6
- package/BunMultipart/package.json +0 -6
- package/BunPath/package.json +0 -6
- package/BunRuntime/package.json +0 -6
- package/BunSink/package.json +0 -6
- package/BunSocket/package.json +0 -6
- package/BunSocketServer/package.json +0 -6
- package/BunStream/package.json +0 -6
- package/BunTerminal/package.json +0 -6
- package/BunWorker/package.json +0 -6
- package/BunWorkerRunner/package.json +0 -6
- package/dist/cjs/BunClusterHttp.js +0 -59
- package/dist/cjs/BunClusterHttp.js.map +0 -1
- package/dist/cjs/BunClusterSocket.js +0 -55
- package/dist/cjs/BunClusterSocket.js.map +0 -1
- package/dist/cjs/BunCommandExecutor.js +0 -18
- package/dist/cjs/BunCommandExecutor.js.map +0 -1
- package/dist/cjs/BunContext.js +0 -20
- package/dist/cjs/BunContext.js.map +0 -1
- package/dist/cjs/BunFileSystem/ParcelWatcher.js +0 -18
- package/dist/cjs/BunFileSystem/ParcelWatcher.js.map +0 -1
- package/dist/cjs/BunFileSystem.js +0 -18
- package/dist/cjs/BunFileSystem.js.map +0 -1
- package/dist/cjs/BunHttpPlatform.js +0 -19
- package/dist/cjs/BunHttpPlatform.js.map +0 -1
- package/dist/cjs/BunHttpServer.js +0 -48
- package/dist/cjs/BunHttpServer.js.map +0 -1
- package/dist/cjs/BunHttpServerRequest.js +0 -14
- package/dist/cjs/BunHttpServerRequest.js.map +0 -1
- package/dist/cjs/BunKeyValueStore.js +0 -18
- package/dist/cjs/BunKeyValueStore.js.map +0 -1
- package/dist/cjs/BunMultipart.js +0 -19
- package/dist/cjs/BunMultipart.js.map +0 -1
- package/dist/cjs/BunPath.js +0 -28
- package/dist/cjs/BunPath.js.map +0 -1
- package/dist/cjs/BunRuntime.js +0 -18
- package/dist/cjs/BunRuntime.js.map +0 -1
- package/dist/cjs/BunSink.js +0 -17
- package/dist/cjs/BunSink.js.map +0 -1
- package/dist/cjs/BunSocket.js +0 -45
- package/dist/cjs/BunSocket.js.map +0 -1
- package/dist/cjs/BunSocketServer.js +0 -17
- package/dist/cjs/BunSocketServer.js.map +0 -1
- package/dist/cjs/BunStream.js +0 -17
- package/dist/cjs/BunStream.js.map +0 -1
- package/dist/cjs/BunTerminal.js +0 -23
- package/dist/cjs/BunTerminal.js.map +0 -1
- package/dist/cjs/BunWorker.js +0 -29
- package/dist/cjs/BunWorker.js.map +0 -1
- package/dist/cjs/BunWorkerRunner.js +0 -21
- package/dist/cjs/BunWorkerRunner.js.map +0 -1
- package/dist/cjs/index.js +0 -46
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/internal/httpPlatform.js +0 -36
- package/dist/cjs/internal/httpPlatform.js.map +0 -1
- package/dist/cjs/internal/httpServer.js +0 -356
- package/dist/cjs/internal/httpServer.js.map +0 -1
- package/dist/cjs/internal/multipart.js +0 -160
- package/dist/cjs/internal/multipart.js.map +0 -1
- package/dist/cjs/internal/worker.js +0 -63
- package/dist/cjs/internal/worker.js.map +0 -1
- package/dist/cjs/internal/workerRunner.js +0 -84
- package/dist/cjs/internal/workerRunner.js.map +0 -1
- package/dist/dts/BunClusterHttp.d.ts +0 -30
- package/dist/dts/BunClusterHttp.d.ts.map +0 -1
- package/dist/dts/BunClusterSocket.d.ts +0 -35
- package/dist/dts/BunClusterSocket.d.ts.map +0 -1
- package/dist/dts/BunCommandExecutor.d.ts +0 -9
- package/dist/dts/BunCommandExecutor.d.ts.map +0 -1
- package/dist/dts/BunContext.d.ts +0 -20
- package/dist/dts/BunContext.d.ts.map +0 -1
- package/dist/dts/BunFileSystem/ParcelWatcher.d.ts +0 -8
- package/dist/dts/BunFileSystem/ParcelWatcher.d.ts.map +0 -1
- package/dist/dts/BunFileSystem.d.ts +0 -8
- package/dist/dts/BunFileSystem.d.ts.map +0 -1
- package/dist/dts/BunHttpPlatform.d.ts +0 -19
- package/dist/dts/BunHttpPlatform.d.ts.map +0 -1
- package/dist/dts/BunHttpServer.d.ts +0 -72
- package/dist/dts/BunHttpServer.d.ts.map +0 -1
- package/dist/dts/BunHttpServerRequest.d.ts +0 -10
- package/dist/dts/BunHttpServerRequest.d.ts.map +0 -1
- package/dist/dts/BunKeyValueStore.d.ts +0 -9
- package/dist/dts/BunKeyValueStore.d.ts.map +0 -1
- package/dist/dts/BunMultipart.d.ts +0 -20
- package/dist/dts/BunMultipart.d.ts.map +0 -1
- package/dist/dts/BunPath.d.ts +0 -21
- package/dist/dts/BunPath.d.ts.map +0 -1
- package/dist/dts/BunRuntime.d.ts +0 -7
- package/dist/dts/BunRuntime.d.ts.map +0 -1
- package/dist/dts/BunSink.d.ts.map +0 -1
- package/dist/dts/BunSocket.d.ts +0 -22
- package/dist/dts/BunSocket.d.ts.map +0 -1
- package/dist/dts/BunSocketServer.d.ts.map +0 -1
- package/dist/dts/BunStream.d.ts +0 -8
- package/dist/dts/BunStream.d.ts.map +0 -1
- package/dist/dts/BunTerminal.d.ts.map +0 -1
- package/dist/dts/BunWorker.d.ts +0 -26
- package/dist/dts/BunWorker.d.ts.map +0 -1
- package/dist/dts/BunWorkerRunner.d.ts +0 -17
- package/dist/dts/BunWorkerRunner.d.ts.map +0 -1
- package/dist/dts/index.d.ts +0 -77
- package/dist/dts/index.d.ts.map +0 -1
- package/dist/dts/internal/httpPlatform.d.ts +0 -2
- package/dist/dts/internal/httpPlatform.d.ts.map +0 -1
- package/dist/dts/internal/httpServer.d.ts +0 -2
- package/dist/dts/internal/httpServer.d.ts.map +0 -1
- package/dist/dts/internal/multipart.d.ts +0 -2
- package/dist/dts/internal/multipart.d.ts.map +0 -1
- package/dist/dts/internal/worker.d.ts +0 -2
- package/dist/dts/internal/worker.d.ts.map +0 -1
- package/dist/dts/internal/workerRunner.d.ts +0 -2
- package/dist/dts/internal/workerRunner.d.ts.map +0 -1
- package/dist/esm/BunClusterHttp.js +0 -50
- package/dist/esm/BunClusterHttp.js.map +0 -1
- package/dist/esm/BunClusterSocket.js +0 -45
- package/dist/esm/BunClusterSocket.js.map +0 -1
- package/dist/esm/BunCommandExecutor.js +0 -10
- package/dist/esm/BunCommandExecutor.js.map +0 -1
- package/dist/esm/BunContext.js +0 -13
- package/dist/esm/BunContext.js.map +0 -1
- package/dist/esm/BunFileSystem/ParcelWatcher.js +0 -10
- package/dist/esm/BunFileSystem/ParcelWatcher.js.map +0 -1
- package/dist/esm/BunFileSystem.js.map +0 -1
- package/dist/esm/BunHttpPlatform.js +0 -12
- package/dist/esm/BunHttpPlatform.js.map +0 -1
- package/dist/esm/BunHttpServer.js +0 -41
- package/dist/esm/BunHttpServer.js.map +0 -1
- package/dist/esm/BunHttpServerRequest.js +0 -7
- package/dist/esm/BunHttpServerRequest.js.map +0 -1
- package/dist/esm/BunKeyValueStore.js +0 -10
- package/dist/esm/BunKeyValueStore.js.map +0 -1
- package/dist/esm/BunMultipart.js +0 -12
- package/dist/esm/BunMultipart.js.map +0 -1
- package/dist/esm/BunPath.js.map +0 -1
- package/dist/esm/BunRuntime.js +0 -10
- package/dist/esm/BunRuntime.js.map +0 -1
- package/dist/esm/BunSink.js.map +0 -1
- package/dist/esm/BunSocket.js +0 -20
- package/dist/esm/BunSocket.js.map +0 -1
- package/dist/esm/BunSocketServer.js.map +0 -1
- package/dist/esm/BunStream.js +0 -8
- package/dist/esm/BunStream.js.map +0 -1
- package/dist/esm/BunTerminal.js.map +0 -1
- package/dist/esm/BunWorker.js +0 -22
- package/dist/esm/BunWorker.js.map +0 -1
- package/dist/esm/BunWorkerRunner.js +0 -13
- package/dist/esm/BunWorkerRunner.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/internal/httpPlatform.js +0 -29
- package/dist/esm/internal/httpPlatform.js.map +0 -1
- package/dist/esm/internal/httpServer.js.map +0 -1
- package/dist/esm/internal/multipart.js +0 -151
- package/dist/esm/internal/multipart.js.map +0 -1
- package/dist/esm/internal/worker.js +0 -54
- package/dist/esm/internal/worker.js.map +0 -1
- package/dist/esm/internal/workerRunner.js +0 -77
- package/dist/esm/internal/workerRunner.js.map +0 -1
- package/dist/esm/package.json +0 -4
- package/index/package.json +0 -6
- package/src/BunCommandExecutor.ts +0 -13
- package/src/BunContext.ts +0 -40
- package/src/BunFileSystem/ParcelWatcher.ts +0 -12
- package/src/BunKeyValueStore.ts +0 -15
- package/src/internal/httpPlatform.ts +0 -25
- package/src/internal/httpServer.ts +0 -478
- package/src/internal/multipart.ts +0 -149
- package/src/internal/worker.ts +0 -68
- package/src/internal/workerRunner.ts +0 -87
- /package/dist/{esm/BunFileSystem.js → BunFileSystem.js} +0 -0
- /package/dist/{esm/BunPath.js → BunPath.js} +0 -0
- /package/dist/{dts/BunSink.d.ts → BunSink.d.ts} +0 -0
- /package/dist/{esm/BunSink.js → BunSink.js} +0 -0
- /package/dist/{dts/BunSocketServer.d.ts → BunSocketServer.d.ts} +0 -0
- /package/dist/{esm/BunSocketServer.js → BunSocketServer.js} +0 -0
package/src/BunClusterSocket.ts
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @since 1.0.0
|
|
3
3
|
*/
|
|
4
|
-
import * as MessageStorage from "@effect/cluster/MessageStorage"
|
|
5
|
-
import * as RunnerHealth from "@effect/cluster/RunnerHealth"
|
|
6
|
-
import * as Runners from "@effect/cluster/Runners"
|
|
7
|
-
import * as RunnerStorage from "@effect/cluster/RunnerStorage"
|
|
8
|
-
import type { Sharding } from "@effect/cluster/Sharding"
|
|
9
|
-
import * as ShardingConfig from "@effect/cluster/ShardingConfig"
|
|
10
|
-
import * as SocketRunner from "@effect/cluster/SocketRunner"
|
|
11
|
-
import * as SqlMessageStorage from "@effect/cluster/SqlMessageStorage"
|
|
12
|
-
import * as SqlRunnerStorage from "@effect/cluster/SqlRunnerStorage"
|
|
13
4
|
import { layerClientProtocol, layerSocketServer } from "@effect/platform-node-shared/NodeClusterSocket"
|
|
14
|
-
import type * as
|
|
15
|
-
import * as
|
|
16
|
-
import
|
|
17
|
-
import type { ConfigError } from "effect/ConfigError"
|
|
5
|
+
import type * as Config from "effect/Config"
|
|
6
|
+
import * as Effect from "effect/Effect"
|
|
7
|
+
import * as FileSystem from "effect/FileSystem"
|
|
18
8
|
import * as Layer from "effect/Layer"
|
|
9
|
+
import * as K8sHttpClient from "effect/unstable/cluster/K8sHttpClient"
|
|
10
|
+
import * as MessageStorage from "effect/unstable/cluster/MessageStorage"
|
|
11
|
+
import * as RunnerHealth from "effect/unstable/cluster/RunnerHealth"
|
|
12
|
+
import * as Runners from "effect/unstable/cluster/Runners"
|
|
13
|
+
import * as RunnerStorage from "effect/unstable/cluster/RunnerStorage"
|
|
14
|
+
import type { Sharding } from "effect/unstable/cluster/Sharding"
|
|
15
|
+
import * as ShardingConfig from "effect/unstable/cluster/ShardingConfig"
|
|
16
|
+
import * as SocketRunner from "effect/unstable/cluster/SocketRunner"
|
|
17
|
+
import * as SqlMessageStorage from "effect/unstable/cluster/SqlMessageStorage"
|
|
18
|
+
import * as SqlRunnerStorage from "effect/unstable/cluster/SqlRunnerStorage"
|
|
19
|
+
import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient"
|
|
20
|
+
import * as RpcSerialization from "effect/unstable/rpc/RpcSerialization"
|
|
21
|
+
import type * as SocketServer from "effect/unstable/socket/SocketServer"
|
|
22
|
+
import type { SqlClient } from "effect/unstable/sql/SqlClient"
|
|
23
|
+
import * as BunFileSystem from "./BunFileSystem.ts"
|
|
19
24
|
|
|
20
25
|
export {
|
|
21
26
|
/**
|
|
@@ -42,18 +47,23 @@ export const layer = <
|
|
|
42
47
|
readonly serialization?: "msgpack" | "ndjson" | undefined
|
|
43
48
|
readonly clientOnly?: ClientOnly | undefined
|
|
44
49
|
readonly storage?: Storage | undefined
|
|
45
|
-
readonly
|
|
50
|
+
readonly runnerHealth?: "ping" | "k8s" | undefined
|
|
51
|
+
readonly runnerHealthK8s?: {
|
|
52
|
+
readonly namespace?: string | undefined
|
|
53
|
+
readonly labelSelector?: string | undefined
|
|
54
|
+
} | undefined
|
|
55
|
+
readonly shardingConfig?: Partial<ShardingConfig.ShardingConfig["Service"]> | undefined
|
|
46
56
|
}
|
|
47
57
|
): ClientOnly extends true ? Layer.Layer<
|
|
48
58
|
Sharding | Runners.Runners | ("byo" extends Storage ? never : MessageStorage.MessageStorage),
|
|
49
|
-
ConfigError,
|
|
59
|
+
Config.ConfigError,
|
|
50
60
|
"local" extends Storage ? never
|
|
51
61
|
: "byo" extends Storage ? (MessageStorage.MessageStorage | RunnerStorage.RunnerStorage)
|
|
52
62
|
: SqlClient
|
|
53
63
|
> :
|
|
54
64
|
Layer.Layer<
|
|
55
65
|
Sharding | Runners.Runners | ("byo" extends Storage ? never : MessageStorage.MessageStorage),
|
|
56
|
-
SocketServer.SocketServerError | ConfigError,
|
|
66
|
+
SocketServer.SocketServerError | Config.ConfigError,
|
|
57
67
|
"local" extends Storage ? never
|
|
58
68
|
: "byo" extends Storage ? (MessageStorage.MessageStorage | RunnerStorage.RunnerStorage)
|
|
59
69
|
: SqlClient
|
|
@@ -67,11 +77,10 @@ export const layer = <
|
|
|
67
77
|
|
|
68
78
|
const runnerHealth: Layer.Layer<any, any, any> = options?.clientOnly
|
|
69
79
|
? Layer.empty as any
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// )
|
|
80
|
+
: options?.runnerHealth === "k8s"
|
|
81
|
+
? RunnerHealth.layerK8s(options.runnerHealthK8s).pipe(
|
|
82
|
+
Layer.provide([BunFileSystem.layer, layerK8sHttpClient])
|
|
83
|
+
)
|
|
75
84
|
: RunnerHealth.layerPing.pipe(
|
|
76
85
|
Layer.provide(Runners.layerRpc),
|
|
77
86
|
Layer.provide(layerClientProtocol)
|
|
@@ -99,3 +108,28 @@ export const layer = <
|
|
|
99
108
|
)
|
|
100
109
|
) as any
|
|
101
110
|
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @since 1.0.0
|
|
114
|
+
* @category Layers
|
|
115
|
+
*/
|
|
116
|
+
export const layerK8sHttpClient: Layer.Layer<K8sHttpClient.K8sHttpClient> = K8sHttpClient.layer.pipe(
|
|
117
|
+
Layer.provide(Layer.unwrap(Effect.gen(function*() {
|
|
118
|
+
const fs = yield* FileSystem.FileSystem
|
|
119
|
+
const caCertOption = yield* fs.readFile("/var/run/secrets/kubernetes.io/serviceaccount/ca.crt").pipe(
|
|
120
|
+
Effect.option
|
|
121
|
+
)
|
|
122
|
+
if (caCertOption._tag === "None") {
|
|
123
|
+
return FetchHttpClient.layer
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return Layer.fresh(FetchHttpClient.layer).pipe(
|
|
127
|
+
Layer.provide(Layer.succeed(FetchHttpClient.RequestInit, {
|
|
128
|
+
tls: {
|
|
129
|
+
ca: caCertOption.value
|
|
130
|
+
}
|
|
131
|
+
} as any))
|
|
132
|
+
)
|
|
133
|
+
}))),
|
|
134
|
+
Layer.provide(BunFileSystem.layer)
|
|
135
|
+
)
|
package/src/BunFileSystem.ts
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* @since 1.0.0
|
|
3
3
|
*/
|
|
4
4
|
import * as NodeFileSystem from "@effect/platform-node-shared/NodeFileSystem"
|
|
5
|
-
import type { FileSystem } from "
|
|
6
|
-
import type
|
|
5
|
+
import type { FileSystem } from "effect/FileSystem"
|
|
6
|
+
import type * as Layer from "effect/Layer"
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @since 1.0.0
|
|
10
10
|
* @category layer
|
|
11
11
|
*/
|
|
12
|
-
export const layer: Layer<FileSystem> = NodeFileSystem.layer
|
|
12
|
+
export const layer: Layer.Layer<FileSystem, never, never> = NodeFileSystem.layer
|
package/src/BunHttpPlatform.ts
CHANGED
|
@@ -1,21 +1,40 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @since 1.0.0
|
|
3
3
|
*/
|
|
4
|
-
import type
|
|
5
|
-
import type
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import * as
|
|
4
|
+
import type { Effect } from "effect"
|
|
5
|
+
import type { FileSystem } from "effect/FileSystem"
|
|
6
|
+
import * as Layer from "effect/Layer"
|
|
7
|
+
import * as Etag from "effect/unstable/http/Etag"
|
|
8
|
+
import * as Platform from "effect/unstable/http/HttpPlatform"
|
|
9
|
+
import * as Response from "effect/unstable/http/HttpServerResponse"
|
|
10
|
+
import * as BunFileSystem from "./BunFileSystem.ts"
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* @since 1.0.0
|
|
13
14
|
* @category constructors
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
|
+
const make: Effect.Effect<
|
|
17
|
+
Platform.HttpPlatform["Service"],
|
|
18
|
+
never,
|
|
19
|
+
FileSystem | Etag.Generator
|
|
20
|
+
> = Platform.make({
|
|
21
|
+
fileResponse(path, status, statusText, headers, start, end, _contentLength) {
|
|
22
|
+
let file = Bun.file(path)
|
|
23
|
+
if (start > 0 || end !== undefined) {
|
|
24
|
+
file = file.slice(start, end)
|
|
25
|
+
}
|
|
26
|
+
return Response.raw(file, { headers, status, statusText })
|
|
27
|
+
},
|
|
28
|
+
fileWebResponse(file, status, statusText, headers, _options) {
|
|
29
|
+
return Response.raw(file, { headers, status, statusText })
|
|
30
|
+
}
|
|
31
|
+
})
|
|
16
32
|
|
|
17
33
|
/**
|
|
18
34
|
* @since 1.0.0
|
|
19
|
-
* @category
|
|
35
|
+
* @category Layers
|
|
20
36
|
*/
|
|
21
|
-
export const layer
|
|
37
|
+
export const layer = Layer.effect(Platform.HttpPlatform)(make).pipe(
|
|
38
|
+
Layer.provide(BunFileSystem.layer),
|
|
39
|
+
Layer.provide(Etag.layer)
|
|
40
|
+
)
|