@effect/platform-bun 0.7.2 → 0.7.4
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/BunContext/dist/effect-platform-bun-BunContext.cjs.d.mts +2 -0
- package/BunContext/dist/effect-platform-bun-BunContext.cjs.d.mts.map +1 -0
- package/BunContext/dist/effect-platform-bun-BunContext.cjs.d.ts +2 -0
- package/BunContext/dist/effect-platform-bun-BunContext.cjs.d.ts.map +1 -0
- package/BunContext/dist/effect-platform-bun-BunContext.cjs.dev.js +14 -0
- package/BunContext/dist/effect-platform-bun-BunContext.cjs.js +7 -0
- package/BunContext/dist/effect-platform-bun-BunContext.cjs.mjs +3 -0
- package/BunContext/dist/effect-platform-bun-BunContext.cjs.prod.js +14 -0
- package/BunContext/dist/effect-platform-bun-BunContext.esm.js +22 -0
- package/BunContext/package.json +4 -0
- package/Command/dist/effect-platform-bun-Command.cjs.d.mts +2 -0
- package/Command/dist/effect-platform-bun-Command.cjs.d.mts.map +1 -0
- package/Command/dist/effect-platform-bun-Command.cjs.d.ts +2 -0
- package/Command/dist/effect-platform-bun-Command.cjs.d.ts.map +1 -0
- package/Command/dist/effect-platform-bun-Command.cjs.dev.js +72 -0
- package/Command/dist/effect-platform-bun-Command.cjs.js +7 -0
- package/Command/dist/effect-platform-bun-Command.cjs.mjs +18 -0
- package/Command/dist/effect-platform-bun-Command.cjs.prod.js +72 -0
- package/Command/dist/effect-platform-bun-Command.esm.js +5 -0
- package/Command/package.json +4 -0
- package/CommandExecutor/dist/effect-platform-bun-CommandExecutor.cjs.d.mts +2 -0
- package/CommandExecutor/dist/effect-platform-bun-CommandExecutor.cjs.d.mts.map +1 -0
- package/CommandExecutor/dist/effect-platform-bun-CommandExecutor.cjs.d.ts +2 -0
- package/CommandExecutor/dist/effect-platform-bun-CommandExecutor.cjs.d.ts.map +1 -0
- package/CommandExecutor/dist/effect-platform-bun-CommandExecutor.cjs.dev.js +16 -0
- package/CommandExecutor/dist/effect-platform-bun-CommandExecutor.cjs.js +7 -0
- package/CommandExecutor/dist/effect-platform-bun-CommandExecutor.cjs.mjs +4 -0
- package/CommandExecutor/dist/effect-platform-bun-CommandExecutor.cjs.prod.js +16 -0
- package/CommandExecutor/dist/effect-platform-bun-CommandExecutor.esm.js +5 -0
- package/CommandExecutor/package.json +4 -0
- package/Effectify/dist/effect-platform-bun-Effectify.cjs.d.mts +2 -0
- package/Effectify/dist/effect-platform-bun-Effectify.cjs.d.mts.map +1 -0
- package/Effectify/dist/effect-platform-bun-Effectify.cjs.d.ts +2 -0
- package/Effectify/dist/effect-platform-bun-Effectify.cjs.d.ts.map +1 -0
- package/Effectify/dist/effect-platform-bun-Effectify.cjs.dev.js +12 -0
- package/Effectify/dist/effect-platform-bun-Effectify.cjs.js +7 -0
- package/Effectify/dist/effect-platform-bun-Effectify.cjs.mjs +3 -0
- package/Effectify/dist/effect-platform-bun-Effectify.cjs.prod.js +12 -0
- package/Effectify/dist/effect-platform-bun-Effectify.esm.js +5 -0
- package/Effectify/package.json +4 -0
- package/Error/dist/effect-platform-bun-Error.cjs.d.mts +2 -0
- package/Error/dist/effect-platform-bun-Error.cjs.d.mts.map +1 -0
- package/Error/dist/effect-platform-bun-Error.cjs.d.ts +2 -0
- package/Error/dist/effect-platform-bun-Error.cjs.d.ts.map +1 -0
- package/Error/dist/effect-platform-bun-Error.cjs.dev.js +28 -0
- package/Error/dist/effect-platform-bun-Error.cjs.js +7 -0
- package/Error/dist/effect-platform-bun-Error.cjs.mjs +7 -0
- package/Error/dist/effect-platform-bun-Error.cjs.prod.js +28 -0
- package/Error/dist/effect-platform-bun-Error.esm.js +5 -0
- package/Error/package.json +4 -0
- package/FileSystem/dist/effect-platform-bun-FileSystem.cjs.d.mts +2 -0
- package/FileSystem/dist/effect-platform-bun-FileSystem.cjs.d.mts.map +1 -0
- package/FileSystem/dist/effect-platform-bun-FileSystem.cjs.d.ts +2 -0
- package/FileSystem/dist/effect-platform-bun-FileSystem.cjs.d.ts.map +1 -0
- package/FileSystem/dist/effect-platform-bun-FileSystem.cjs.dev.js +20 -0
- package/FileSystem/dist/effect-platform-bun-FileSystem.cjs.js +7 -0
- package/FileSystem/dist/effect-platform-bun-FileSystem.cjs.mjs +5 -0
- package/FileSystem/dist/effect-platform-bun-FileSystem.cjs.prod.js +20 -0
- package/FileSystem/dist/effect-platform-bun-FileSystem.esm.js +5 -0
- package/FileSystem/package.json +4 -0
- package/Http/Platform/dist/effect-platform-bun-Http-Platform.cjs.d.mts +2 -0
- package/Http/Platform/dist/effect-platform-bun-Http-Platform.cjs.d.mts.map +1 -0
- package/Http/Platform/dist/effect-platform-bun-Http-Platform.cjs.d.ts +2 -0
- package/Http/Platform/dist/effect-platform-bun-Http-Platform.cjs.d.ts.map +1 -0
- package/Http/Platform/dist/effect-platform-bun-Http-Platform.cjs.dev.js +85 -0
- package/Http/Platform/dist/effect-platform-bun-Http-Platform.cjs.js +7 -0
- package/Http/Platform/dist/effect-platform-bun-Http-Platform.cjs.mjs +1 -0
- package/Http/Platform/dist/effect-platform-bun-Http-Platform.cjs.prod.js +85 -0
- package/Http/Platform/dist/effect-platform-bun-Http-Platform.esm.js +22 -0
- package/Http/Platform/package.json +4 -0
- package/Http/Server/dist/effect-platform-bun-Http-Server.cjs.d.mts +2 -0
- package/Http/Server/dist/effect-platform-bun-Http-Server.cjs.d.mts.map +1 -0
- package/Http/Server/dist/effect-platform-bun-Http-Server.cjs.d.ts +2 -0
- package/Http/Server/dist/effect-platform-bun-Http-Server.cjs.d.ts.map +1 -0
- package/Http/Server/dist/effect-platform-bun-Http-Server.cjs.dev.js +39 -0
- package/Http/Server/dist/effect-platform-bun-Http-Server.cjs.js +7 -0
- package/Http/Server/dist/effect-platform-bun-Http-Server.cjs.mjs +1 -0
- package/Http/Server/dist/effect-platform-bun-Http-Server.cjs.prod.js +39 -0
- package/Http/Server/dist/effect-platform-bun-Http-Server.esm.js +29 -0
- package/Http/Server/package.json +4 -0
- package/HttpClient/dist/effect-platform-bun-HttpClient.cjs.d.mts +2 -0
- package/HttpClient/dist/effect-platform-bun-HttpClient.cjs.d.mts.map +1 -0
- package/HttpClient/dist/effect-platform-bun-HttpClient.cjs.d.ts +2 -0
- package/HttpClient/dist/effect-platform-bun-HttpClient.cjs.d.ts.map +1 -0
- package/HttpClient/dist/effect-platform-bun-HttpClient.cjs.dev.js +47 -0
- package/HttpClient/dist/effect-platform-bun-HttpClient.cjs.js +7 -0
- package/HttpClient/dist/effect-platform-bun-HttpClient.cjs.mjs +9 -0
- package/HttpClient/dist/effect-platform-bun-HttpClient.cjs.prod.js +47 -0
- package/HttpClient/dist/effect-platform-bun-HttpClient.esm.js +18 -0
- package/HttpClient/package.json +4 -0
- package/HttpServer/dist/effect-platform-bun-HttpServer.cjs.d.mts +2 -0
- package/HttpServer/dist/effect-platform-bun-HttpServer.cjs.d.mts.map +1 -0
- package/HttpServer/dist/effect-platform-bun-HttpServer.cjs.d.ts +2 -0
- package/HttpServer/dist/effect-platform-bun-HttpServer.cjs.d.ts.map +1 -0
- package/HttpServer/dist/effect-platform-bun-HttpServer.cjs.dev.js +75 -0
- package/HttpServer/dist/effect-platform-bun-HttpServer.cjs.js +7 -0
- package/HttpServer/dist/effect-platform-bun-HttpServer.cjs.mjs +14 -0
- package/HttpServer/dist/effect-platform-bun-HttpServer.cjs.prod.js +75 -0
- package/HttpServer/dist/effect-platform-bun-HttpServer.esm.js +28 -0
- package/HttpServer/package.json +4 -0
- package/KeyValueStore/dist/effect-platform-bun-KeyValueStore.cjs.d.mts +2 -0
- package/KeyValueStore/dist/effect-platform-bun-KeyValueStore.cjs.d.mts.map +1 -0
- package/KeyValueStore/dist/effect-platform-bun-KeyValueStore.cjs.d.ts +2 -0
- package/KeyValueStore/dist/effect-platform-bun-KeyValueStore.cjs.d.ts.map +1 -0
- package/KeyValueStore/dist/effect-platform-bun-KeyValueStore.cjs.dev.js +19 -0
- package/KeyValueStore/dist/effect-platform-bun-KeyValueStore.cjs.js +7 -0
- package/KeyValueStore/dist/effect-platform-bun-KeyValueStore.cjs.mjs +1 -0
- package/KeyValueStore/dist/effect-platform-bun-KeyValueStore.cjs.prod.js +19 -0
- package/KeyValueStore/dist/effect-platform-bun-KeyValueStore.esm.js +9 -0
- package/KeyValueStore/package.json +4 -0
- package/Path/dist/effect-platform-bun-Path.cjs.d.mts +2 -0
- package/Path/dist/effect-platform-bun-Path.cjs.d.mts.map +1 -0
- package/Path/dist/effect-platform-bun-Path.cjs.d.ts +2 -0
- package/Path/dist/effect-platform-bun-Path.cjs.d.ts.map +1 -0
- package/Path/dist/effect-platform-bun-Path.cjs.dev.js +24 -0
- package/Path/dist/effect-platform-bun-Path.cjs.js +7 -0
- package/Path/dist/effect-platform-bun-Path.cjs.mjs +6 -0
- package/Path/dist/effect-platform-bun-Path.cjs.prod.js +24 -0
- package/Path/dist/effect-platform-bun-Path.esm.js +5 -0
- package/Path/package.json +4 -0
- package/Runtime/dist/effect-platform-bun-Runtime.cjs.d.mts +2 -0
- package/Runtime/dist/effect-platform-bun-Runtime.cjs.d.mts.map +1 -0
- package/Runtime/dist/effect-platform-bun-Runtime.cjs.d.ts +2 -0
- package/Runtime/dist/effect-platform-bun-Runtime.cjs.d.ts.map +1 -0
- package/Runtime/dist/effect-platform-bun-Runtime.cjs.dev.js +16 -0
- package/Runtime/dist/effect-platform-bun-Runtime.cjs.js +7 -0
- package/Runtime/dist/effect-platform-bun-Runtime.cjs.mjs +4 -0
- package/Runtime/dist/effect-platform-bun-Runtime.cjs.prod.js +16 -0
- package/Runtime/dist/effect-platform-bun-Runtime.esm.js +5 -0
- package/Runtime/package.json +4 -0
- package/Sink/dist/effect-platform-bun-Sink.cjs.d.mts +2 -0
- package/Sink/dist/effect-platform-bun-Sink.cjs.d.mts.map +1 -0
- package/Sink/dist/effect-platform-bun-Sink.cjs.d.ts +2 -0
- package/Sink/dist/effect-platform-bun-Sink.cjs.d.ts.map +1 -0
- package/Sink/dist/effect-platform-bun-Sink.cjs.dev.js +12 -0
- package/Sink/dist/effect-platform-bun-Sink.cjs.js +7 -0
- package/Sink/dist/effect-platform-bun-Sink.cjs.mjs +3 -0
- package/Sink/dist/effect-platform-bun-Sink.cjs.prod.js +12 -0
- package/Sink/dist/effect-platform-bun-Sink.esm.js +5 -0
- package/Sink/package.json +4 -0
- package/Stream/dist/effect-platform-bun-Stream.cjs.d.mts +2 -0
- package/Stream/dist/effect-platform-bun-Stream.cjs.d.mts.map +1 -0
- package/Stream/dist/effect-platform-bun-Stream.cjs.d.ts +2 -0
- package/Stream/dist/effect-platform-bun-Stream.cjs.d.ts.map +1 -0
- package/Stream/dist/effect-platform-bun-Stream.cjs.dev.js +20 -0
- package/Stream/dist/effect-platform-bun-Stream.cjs.js +7 -0
- package/Stream/dist/effect-platform-bun-Stream.cjs.mjs +5 -0
- package/Stream/dist/effect-platform-bun-Stream.cjs.prod.js +20 -0
- package/Stream/dist/effect-platform-bun-Stream.esm.js +5 -0
- package/Stream/package.json +4 -0
- package/dist/BunContext-3aacfc41.cjs.dev.js +50 -0
- package/dist/BunContext-af359ac7.cjs.prod.js +50 -0
- package/dist/Command-073352c2.cjs.dev.js +29 -0
- package/dist/Command-86aff121.cjs.prod.js +29 -0
- package/dist/CommandExecutor-79029a6f.cjs.prod.js +15 -0
- package/dist/CommandExecutor-9fdee39f.cjs.dev.js +15 -0
- package/dist/Effectify-1e2cf960.cjs.dev.js +14 -0
- package/dist/Effectify-583bea25.cjs.prod.js +14 -0
- package/dist/Error-06928f75.cjs.dev.js +18 -0
- package/dist/Error-77b41701.cjs.prod.js +18 -0
- package/dist/FileSystem-0f2d7096.cjs.prod.js +16 -0
- package/dist/FileSystem-3eb9e057.cjs.dev.js +16 -0
- package/dist/HttpClient-91ed29d7.cjs.dev.js +52 -0
- package/dist/HttpClient-a34271de.cjs.prod.js +52 -0
- package/dist/HttpServer-93d1b5e2.cjs.prod.js +66 -0
- package/dist/HttpServer-ae717a37.cjs.dev.js +66 -0
- package/dist/KeyValueStore-9e969cb3.cjs.dev.js +52 -0
- package/dist/KeyValueStore-ddd3d960.cjs.prod.js +52 -0
- package/dist/Path-49561a01.cjs.dev.js +17 -0
- package/dist/Path-9c4bff86.cjs.prod.js +17 -0
- package/dist/Runtime-399be72e.cjs.prod.js +15 -0
- package/dist/Runtime-ad8dde5f.cjs.dev.js +15 -0
- package/dist/Server-3766cdb3.cjs.dev.js +314 -0
- package/dist/Server-4fe393ab.cjs.prod.js +314 -0
- package/dist/Sink-0100d655.cjs.prod.js +14 -0
- package/dist/Sink-59df5de5.cjs.dev.js +14 -0
- package/dist/Stream-a7a516a8.cjs.dev.js +16 -0
- package/dist/Stream-d0a08460.cjs.prod.js +16 -0
- package/{BunContext.d.ts → dist/declarations/src/BunContext.d.ts} +3 -6
- package/dist/declarations/src/BunContext.d.ts.map +1 -0
- package/dist/declarations/src/Command.d.ts.map +1 -0
- package/dist/declarations/src/CommandExecutor.d.ts.map +1 -0
- package/dist/declarations/src/Effectify.d.ts.map +1 -0
- package/dist/declarations/src/Error.d.ts.map +1 -0
- package/dist/declarations/src/FileSystem.d.ts.map +1 -0
- package/{Http → dist/declarations/src/Http}/Platform.d.ts +1 -1
- package/dist/declarations/src/Http/Platform.d.ts.map +1 -0
- package/{Http → dist/declarations/src/Http}/Server.d.ts +1 -1
- package/dist/declarations/src/Http/Server.d.ts.map +1 -0
- package/dist/declarations/src/HttpClient.d.ts.map +1 -0
- package/{HttpServer.d.ts → dist/declarations/src/HttpServer.d.ts} +1 -1
- package/dist/declarations/src/HttpServer.d.ts.map +1 -0
- package/dist/declarations/src/KeyValueStore.d.ts.map +1 -0
- package/dist/declarations/src/Path.d.ts.map +1 -0
- package/dist/declarations/src/Runtime.d.ts.map +1 -0
- package/dist/declarations/src/Sink.d.ts.map +1 -0
- package/dist/declarations/src/Stream.d.ts.map +1 -0
- package/dist/declarations/src/index.d.ts +55 -0
- package/dist/declarations/src/index.d.ts.map +1 -0
- package/dist/effect-platform-bun.cjs.d.mts +2 -0
- package/dist/effect-platform-bun.cjs.d.mts.map +1 -0
- package/dist/effect-platform-bun.cjs.d.ts +2 -0
- package/dist/effect-platform-bun.cjs.d.ts.map +1 -0
- package/dist/effect-platform-bun.cjs.dev.js +73 -0
- package/dist/effect-platform-bun.cjs.js +7 -0
- package/dist/effect-platform-bun.cjs.mjs +15 -0
- package/dist/effect-platform-bun.cjs.prod.js +73 -0
- package/dist/effect-platform-bun.esm.js +26 -0
- package/internal/http/platform.esm.js +33 -0
- package/{mjs/internal/http/server.mjs → internal/http/server.esm.js} +26 -25
- package/package.json +152 -31
- package/src/BunContext.ts +3 -3
- package/src/Http/Platform.ts +2 -2
- package/src/Http/Server.ts +2 -2
- package/src/HttpServer.ts +1 -1
- package/src/index.ts +13 -13
- package/src/internal/http/platform.ts +1 -1
- package/src/internal/http/server.ts +3 -3
- package/BunContext.d.ts.map +0 -1
- package/BunContext.js +0 -23
- package/BunContext.js.map +0 -1
- package/Command.d.ts.map +0 -1
- package/Command.js +0 -103
- package/Command.js.map +0 -1
- package/CommandExecutor.d.ts.map +0 -1
- package/CommandExecutor.js +0 -19
- package/CommandExecutor.js.map +0 -1
- package/Effectify.d.ts.map +0 -1
- package/Effectify.js +0 -13
- package/Effectify.js.map +0 -1
- package/Error.d.ts.map +0 -1
- package/Error.js +0 -25
- package/Error.js.map +0 -1
- package/FileSystem.d.ts.map +0 -1
- package/FileSystem.js +0 -25
- package/FileSystem.js.map +0 -1
- package/Http/Platform.d.ts.map +0 -1
- package/Http/Platform.js +0 -40
- package/Http/Platform.js.map +0 -1
- package/Http/Server.d.ts.map +0 -1
- package/Http/Server.js +0 -46
- package/Http/Server.js.map +0 -1
- package/HttpClient.d.ts.map +0 -1
- package/HttpClient.js +0 -23
- package/HttpClient.js.map +0 -1
- package/HttpServer.d.ts.map +0 -1
- package/HttpServer.js +0 -33
- package/HttpServer.js.map +0 -1
- package/KeyValueStore.d.ts.map +0 -1
- package/KeyValueStore.js +0 -28
- package/KeyValueStore.js.map +0 -1
- package/Path.d.ts.map +0 -1
- package/Path.js +0 -31
- package/Path.js.map +0 -1
- package/Runtime.d.ts.map +0 -1
- package/Runtime.js +0 -19
- package/Runtime.js.map +0 -1
- package/Sink.d.ts.map +0 -1
- package/Sink.js +0 -13
- package/Sink.js.map +0 -1
- package/Stream.d.ts.map +0 -1
- package/Stream.js +0 -25
- package/Stream.js.map +0 -1
- package/index.d.ts +0 -55
- package/index.d.ts.map +0 -1
- package/index.js +0 -35
- package/index.js.map +0 -1
- package/internal/http/platform.d.ts +0 -2
- package/internal/http/platform.d.ts.map +0 -1
- package/internal/http/platform.js +0 -38
- package/internal/http/platform.js.map +0 -1
- package/internal/http/server.d.ts +0 -2
- package/internal/http/server.d.ts.map +0 -1
- package/internal/http/server.js +0 -239
- package/internal/http/server.js.map +0 -1
- package/mjs/BunContext.mjs +0 -14
- package/mjs/BunContext.mjs.map +0 -1
- package/mjs/Command.mjs +0 -85
- package/mjs/Command.mjs.map +0 -1
- package/mjs/CommandExecutor.mjs +0 -15
- package/mjs/CommandExecutor.mjs.map +0 -1
- package/mjs/Effectify.mjs +0 -10
- package/mjs/Effectify.mjs.map +0 -1
- package/mjs/Error.mjs +0 -20
- package/mjs/Error.mjs.map +0 -1
- package/mjs/FileSystem.mjs +0 -20
- package/mjs/FileSystem.mjs.map +0 -1
- package/mjs/Http/Platform.mjs +0 -16
- package/mjs/Http/Platform.mjs.map +0 -1
- package/mjs/Http/Server.mjs +0 -21
- package/mjs/Http/Server.mjs.map +0 -1
- package/mjs/HttpClient.mjs +0 -61
- package/mjs/HttpClient.mjs.map +0 -1
- package/mjs/HttpServer.mjs +0 -101
- package/mjs/HttpServer.mjs.map +0 -1
- package/mjs/KeyValueStore.mjs +0 -13
- package/mjs/KeyValueStore.mjs.map +0 -1
- package/mjs/Path.mjs +0 -25
- package/mjs/Path.mjs.map +0 -1
- package/mjs/Runtime.mjs +0 -15
- package/mjs/Runtime.mjs.map +0 -1
- package/mjs/Sink.mjs +0 -10
- package/mjs/Sink.mjs.map +0 -1
- package/mjs/Stream.mjs +0 -20
- package/mjs/Stream.mjs.map +0 -1
- package/mjs/index.mjs +0 -27
- package/mjs/index.mjs.map +0 -1
- package/mjs/internal/http/platform.mjs +0 -30
- package/mjs/internal/http/platform.mjs.map +0 -1
- package/mjs/internal/http/server.mjs.map +0 -1
- package/tsconfig.build.json +0 -12
- package/tsconfig.examples.json +0 -12
- package/tsconfig.json +0 -11
- package/tsconfig.test.json +0 -17
- /package/{Command.d.ts → dist/declarations/src/Command.d.ts} +0 -0
- /package/{CommandExecutor.d.ts → dist/declarations/src/CommandExecutor.d.ts} +0 -0
- /package/{Effectify.d.ts → dist/declarations/src/Effectify.d.ts} +0 -0
- /package/{Error.d.ts → dist/declarations/src/Error.d.ts} +0 -0
- /package/{FileSystem.d.ts → dist/declarations/src/FileSystem.d.ts} +0 -0
- /package/{HttpClient.d.ts → dist/declarations/src/HttpClient.d.ts} +0 -0
- /package/{KeyValueStore.d.ts → dist/declarations/src/KeyValueStore.d.ts} +0 -0
- /package/{Path.d.ts → dist/declarations/src/Path.d.ts} +0 -0
- /package/{Runtime.d.ts → dist/declarations/src/Runtime.d.ts} +0 -0
- /package/{Sink.d.ts → dist/declarations/src/Sink.d.ts} +0 -0
- /package/{Stream.d.ts → dist/declarations/src/Stream.d.ts} +0 -0
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var FormData = require('@effect/platform-node/Http/FormData');
|
|
4
|
+
var Headers = require('@effect/platform/Http/Headers');
|
|
5
|
+
var IncomingMessage = require('@effect/platform/Http/IncomingMessage');
|
|
6
|
+
var Middleware = require('@effect/platform/Http/Middleware');
|
|
7
|
+
var Server$1 = require('@effect/platform/Http/Server');
|
|
8
|
+
var Error = require('@effect/platform/Http/ServerError');
|
|
9
|
+
var ServerRequest = require('@effect/platform/Http/ServerRequest');
|
|
10
|
+
var UrlParams = require('@effect/platform/Http/UrlParams');
|
|
11
|
+
var Cause = require('effect/Cause');
|
|
12
|
+
var Config = require('effect/Config');
|
|
13
|
+
var Effect = require('effect/Effect');
|
|
14
|
+
var Function = require('effect/Function');
|
|
15
|
+
var Layer = require('effect/Layer');
|
|
16
|
+
var Option = require('effect/Option');
|
|
17
|
+
var Runtime = require('effect/Runtime');
|
|
18
|
+
var Stream = require('effect/Stream');
|
|
19
|
+
var node_stream = require('node:stream');
|
|
20
|
+
var Http_Platform_dist_effectPlatformBunHttpPlatform = require('../Http/Platform/dist/effect-platform-bun-Http-Platform.cjs.dev.js');
|
|
21
|
+
|
|
22
|
+
function _interopNamespace(e) {
|
|
23
|
+
if (e && e.__esModule) return e;
|
|
24
|
+
var n = Object.create(null);
|
|
25
|
+
if (e) {
|
|
26
|
+
Object.keys(e).forEach(function (k) {
|
|
27
|
+
if (k !== 'default') {
|
|
28
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
29
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function () { return e[k]; }
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
n["default"] = e;
|
|
37
|
+
return Object.freeze(n);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function _mergeNamespaces(n, m) {
|
|
41
|
+
m.forEach(function (e) {
|
|
42
|
+
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
43
|
+
if (k !== 'default' && !(k in n)) {
|
|
44
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
45
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
get: function () { return e[k]; }
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
return Object.freeze(n);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
var FormData__namespace = /*#__PURE__*/_interopNamespace(FormData);
|
|
56
|
+
var Headers__namespace = /*#__PURE__*/_interopNamespace(Headers);
|
|
57
|
+
var IncomingMessage__namespace = /*#__PURE__*/_interopNamespace(IncomingMessage);
|
|
58
|
+
var Middleware__namespace = /*#__PURE__*/_interopNamespace(Middleware);
|
|
59
|
+
var Server__namespace = /*#__PURE__*/_interopNamespace(Server$1);
|
|
60
|
+
var Error__namespace = /*#__PURE__*/_interopNamespace(Error);
|
|
61
|
+
var ServerRequest__namespace = /*#__PURE__*/_interopNamespace(ServerRequest);
|
|
62
|
+
var UrlParams__namespace = /*#__PURE__*/_interopNamespace(UrlParams);
|
|
63
|
+
var Cause__namespace = /*#__PURE__*/_interopNamespace(Cause);
|
|
64
|
+
var Config__namespace = /*#__PURE__*/_interopNamespace(Config);
|
|
65
|
+
var Effect__namespace = /*#__PURE__*/_interopNamespace(Effect);
|
|
66
|
+
var Layer__namespace = /*#__PURE__*/_interopNamespace(Layer);
|
|
67
|
+
var Option__namespace = /*#__PURE__*/_interopNamespace(Option);
|
|
68
|
+
var Runtime__namespace = /*#__PURE__*/_interopNamespace(Runtime);
|
|
69
|
+
var Stream__namespace = /*#__PURE__*/_interopNamespace(Stream);
|
|
70
|
+
|
|
71
|
+
/** @internal */
|
|
72
|
+
const make$1 = options => Effect__namespace.gen(function* (_) {
|
|
73
|
+
const handlerStack = [function (_request, _server) {
|
|
74
|
+
return new Response("not found", {
|
|
75
|
+
status: 404
|
|
76
|
+
});
|
|
77
|
+
}];
|
|
78
|
+
const server = Bun.serve({
|
|
79
|
+
...options,
|
|
80
|
+
fetch: handlerStack[0]
|
|
81
|
+
});
|
|
82
|
+
yield* _(Effect__namespace.addFinalizer(() => Effect__namespace.sync(() => {
|
|
83
|
+
server.stop();
|
|
84
|
+
})));
|
|
85
|
+
return Server__namespace.make({
|
|
86
|
+
address: {
|
|
87
|
+
_tag: "TcpAddress",
|
|
88
|
+
port: server.port,
|
|
89
|
+
hostname: server.hostname
|
|
90
|
+
},
|
|
91
|
+
serve(httpApp, middleware) {
|
|
92
|
+
const app = middleware ? middleware(respond(httpApp)) : respond(httpApp);
|
|
93
|
+
return Function.pipe(Effect__namespace.all([Effect__namespace.runtime(), Effect__namespace.fiberId]), Effect__namespace.zipLeft(Effect__namespace.addFinalizer(() => Effect__namespace.sync(() => {
|
|
94
|
+
handlerStack.pop();
|
|
95
|
+
server.reload({
|
|
96
|
+
fetch: handlerStack[handlerStack.length - 1]
|
|
97
|
+
});
|
|
98
|
+
}))), Effect__namespace.flatMap(([runtime, fiberId]) => Effect__namespace.async(() => {
|
|
99
|
+
const runFork = Runtime__namespace.runFork(runtime);
|
|
100
|
+
function handler(request, _server) {
|
|
101
|
+
console.log(request);
|
|
102
|
+
return new Promise((resolve, reject) => {
|
|
103
|
+
const fiber = runFork(Effect__namespace.provideService(app, ServerRequest__namespace.ServerRequest, new ServerRequestImpl(request, resolve, reject, removeHost(request.url))));
|
|
104
|
+
request.signal.addEventListener("abort", () => {
|
|
105
|
+
runFork(fiber.interruptAsFork(fiberId));
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
handlerStack.push(handler);
|
|
110
|
+
server.reload({
|
|
111
|
+
fetch: handler
|
|
112
|
+
});
|
|
113
|
+
})));
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
const makeResponse = (request, response) => {
|
|
118
|
+
if (request.method === "HEAD") {
|
|
119
|
+
return new Response(undefined, {
|
|
120
|
+
status: response.status,
|
|
121
|
+
statusText: response.statusText,
|
|
122
|
+
headers: response.headers
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
const body = response.body;
|
|
126
|
+
switch (body._tag) {
|
|
127
|
+
case "Empty":
|
|
128
|
+
{
|
|
129
|
+
return new Response(undefined, {
|
|
130
|
+
status: response.status,
|
|
131
|
+
statusText: response.statusText,
|
|
132
|
+
headers: response.headers
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
case "Uint8Array":
|
|
136
|
+
case "Raw":
|
|
137
|
+
{
|
|
138
|
+
return new Response(body.body, {
|
|
139
|
+
status: response.status,
|
|
140
|
+
statusText: response.statusText,
|
|
141
|
+
headers: response.headers
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
case "FormData":
|
|
145
|
+
{
|
|
146
|
+
return new Response(body.formData, {
|
|
147
|
+
status: response.status,
|
|
148
|
+
statusText: response.statusText,
|
|
149
|
+
headers: response.headers
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
case "Stream":
|
|
153
|
+
{
|
|
154
|
+
return new Response(Stream__namespace.toReadableStream(body.stream), {
|
|
155
|
+
status: response.status,
|
|
156
|
+
statusText: response.statusText,
|
|
157
|
+
headers: response.headers
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
const respond = /*#__PURE__*/Middleware__namespace.make(httpApp => Effect__namespace.flatMap(ServerRequest__namespace.ServerRequest, request => Effect__namespace.onExit(httpApp, exit => Effect__namespace.sync(() => {
|
|
163
|
+
if (exit._tag === "Success") {
|
|
164
|
+
request.resolve(makeResponse(request, exit.value));
|
|
165
|
+
} else {
|
|
166
|
+
request.reject(Cause__namespace.pretty(exit.cause));
|
|
167
|
+
}
|
|
168
|
+
}))));
|
|
169
|
+
|
|
170
|
+
/** @internal */
|
|
171
|
+
const layer$1 = options => Layer__namespace.merge(Layer__namespace.scoped(Server__namespace.Server, make$1(options)), Http_Platform_dist_effectPlatformBunHttpPlatform.layer);
|
|
172
|
+
|
|
173
|
+
/** @internal */
|
|
174
|
+
const layerConfig$1 = options => Layer__namespace.merge(Layer__namespace.scoped(Server__namespace.Server, Effect__namespace.flatMap(Effect__namespace.config(Config__namespace.unwrap(options)), make$1)), Http_Platform_dist_effectPlatformBunHttpPlatform.layer);
|
|
175
|
+
class ServerRequestImpl {
|
|
176
|
+
constructor(source, resolve, reject, url, headersOverride, remoteAddressOverride) {
|
|
177
|
+
this.source = source;
|
|
178
|
+
this.resolve = resolve;
|
|
179
|
+
this.reject = reject;
|
|
180
|
+
this.url = url;
|
|
181
|
+
this.headersOverride = headersOverride;
|
|
182
|
+
this.remoteAddressOverride = remoteAddressOverride;
|
|
183
|
+
this[ServerRequest__namespace.TypeId] = ServerRequest__namespace.TypeId;
|
|
184
|
+
this[IncomingMessage__namespace.TypeId] = IncomingMessage__namespace.TypeId;
|
|
185
|
+
}
|
|
186
|
+
modify(options) {
|
|
187
|
+
return new ServerRequestImpl(this.source, this.resolve, this.reject, options.url ?? this.url, options.headers ?? this.headersOverride, options.remoteAddress ?? this.remoteAddressOverride);
|
|
188
|
+
}
|
|
189
|
+
get method() {
|
|
190
|
+
return this.source.method;
|
|
191
|
+
}
|
|
192
|
+
get originalUrl() {
|
|
193
|
+
return this.source.url;
|
|
194
|
+
}
|
|
195
|
+
get remoteAddress() {
|
|
196
|
+
return this.remoteAddressOverride ? Option__namespace.some(this.remoteAddressOverride) : Option__namespace.none();
|
|
197
|
+
}
|
|
198
|
+
get headers() {
|
|
199
|
+
this.headersOverride ??= Headers__namespace.fromInput(this.source.headers);
|
|
200
|
+
return this.headersOverride;
|
|
201
|
+
}
|
|
202
|
+
get stream() {
|
|
203
|
+
return this.source.body ? Stream__namespace.fromReadableStream(() => this.source.body, _ => Error__namespace.RequestError({
|
|
204
|
+
request: this,
|
|
205
|
+
reason: "Decode",
|
|
206
|
+
error: _
|
|
207
|
+
})) : Stream__namespace.fail(Error__namespace.RequestError({
|
|
208
|
+
request: this,
|
|
209
|
+
reason: "Decode",
|
|
210
|
+
error: "can not create stream from empty body"
|
|
211
|
+
}));
|
|
212
|
+
}
|
|
213
|
+
get text() {
|
|
214
|
+
if (this.textEffect) {
|
|
215
|
+
return this.textEffect;
|
|
216
|
+
}
|
|
217
|
+
this.textEffect = Effect__namespace.runSync(Effect__namespace.cached(Effect__namespace.tryPromise({
|
|
218
|
+
try: () => this.source.text(),
|
|
219
|
+
catch: error => Error__namespace.RequestError({
|
|
220
|
+
request: this,
|
|
221
|
+
reason: "Decode",
|
|
222
|
+
error
|
|
223
|
+
})
|
|
224
|
+
})));
|
|
225
|
+
return this.textEffect;
|
|
226
|
+
}
|
|
227
|
+
get json() {
|
|
228
|
+
return Effect__namespace.tryMap(this.text, {
|
|
229
|
+
try: _ => JSON.parse(_),
|
|
230
|
+
catch: error => Error__namespace.RequestError({
|
|
231
|
+
request: this,
|
|
232
|
+
reason: "Decode",
|
|
233
|
+
error
|
|
234
|
+
})
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
get urlParamsBody() {
|
|
238
|
+
return Effect__namespace.flatMap(this.text, _ => Effect__namespace.try({
|
|
239
|
+
try: () => UrlParams__namespace.fromInput(new URLSearchParams(_)),
|
|
240
|
+
catch: error => Error__namespace.RequestError({
|
|
241
|
+
request: this,
|
|
242
|
+
reason: "Decode",
|
|
243
|
+
error
|
|
244
|
+
})
|
|
245
|
+
}));
|
|
246
|
+
}
|
|
247
|
+
get formData() {
|
|
248
|
+
if (this.formDataEffect) {
|
|
249
|
+
return this.formDataEffect;
|
|
250
|
+
}
|
|
251
|
+
this.formDataEffect = Effect__namespace.runSync(Effect__namespace.cached(FormData__namespace.formData(node_stream.Readable.fromWeb(this.source.body), this.headers)));
|
|
252
|
+
return this.formDataEffect;
|
|
253
|
+
}
|
|
254
|
+
get formDataStream() {
|
|
255
|
+
return FormData__namespace.stream(node_stream.Readable.fromWeb(this.source.body), this.headers);
|
|
256
|
+
}
|
|
257
|
+
get arrayBuffer() {
|
|
258
|
+
if (this.arrayBuffer) {
|
|
259
|
+
return this.arrayBuffer;
|
|
260
|
+
}
|
|
261
|
+
this.arrayBufferEffect = Effect__namespace.runSync(Effect__namespace.cached(Effect__namespace.tryPromise({
|
|
262
|
+
try: () => this.source.arrayBuffer(),
|
|
263
|
+
catch: error => Error__namespace.RequestError({
|
|
264
|
+
request: this,
|
|
265
|
+
reason: "Decode",
|
|
266
|
+
error
|
|
267
|
+
})
|
|
268
|
+
})));
|
|
269
|
+
return this.arrayBufferEffect;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const removeHost = url => {
|
|
273
|
+
if (url[0] === "/") {
|
|
274
|
+
return url;
|
|
275
|
+
}
|
|
276
|
+
const index = url.indexOf("/", url.indexOf("//") + 2);
|
|
277
|
+
return index === -1 ? "/" : url.slice(index);
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* @since 1.0.0
|
|
282
|
+
*
|
|
283
|
+
* Also includes exports from [`@effect/platform/Http/Server`](https://effect-ts.github.io/platform/platform/Http/Server.ts.html).
|
|
284
|
+
*/
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* @since 1.0.0
|
|
288
|
+
* @category constructors
|
|
289
|
+
*/
|
|
290
|
+
const make = make$1;
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* @since 1.0.0
|
|
294
|
+
* @category layers
|
|
295
|
+
*/
|
|
296
|
+
const layer = layer$1;
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* @since 1.0.0
|
|
300
|
+
* @category layers
|
|
301
|
+
*/
|
|
302
|
+
const layerConfig = layerConfig$1;
|
|
303
|
+
|
|
304
|
+
var Server = /*#__PURE__*/_mergeNamespaces({
|
|
305
|
+
__proto__: null,
|
|
306
|
+
make: make,
|
|
307
|
+
layer: layer,
|
|
308
|
+
layerConfig: layerConfig
|
|
309
|
+
}, [Server__namespace]);
|
|
310
|
+
|
|
311
|
+
exports.Server = Server;
|
|
312
|
+
exports.layer = layer;
|
|
313
|
+
exports.layerConfig = layerConfig;
|
|
314
|
+
exports.make = make;
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var FormData = require('@effect/platform-node/Http/FormData');
|
|
4
|
+
var Headers = require('@effect/platform/Http/Headers');
|
|
5
|
+
var IncomingMessage = require('@effect/platform/Http/IncomingMessage');
|
|
6
|
+
var Middleware = require('@effect/platform/Http/Middleware');
|
|
7
|
+
var Server$1 = require('@effect/platform/Http/Server');
|
|
8
|
+
var Error = require('@effect/platform/Http/ServerError');
|
|
9
|
+
var ServerRequest = require('@effect/platform/Http/ServerRequest');
|
|
10
|
+
var UrlParams = require('@effect/platform/Http/UrlParams');
|
|
11
|
+
var Cause = require('effect/Cause');
|
|
12
|
+
var Config = require('effect/Config');
|
|
13
|
+
var Effect = require('effect/Effect');
|
|
14
|
+
var Function = require('effect/Function');
|
|
15
|
+
var Layer = require('effect/Layer');
|
|
16
|
+
var Option = require('effect/Option');
|
|
17
|
+
var Runtime = require('effect/Runtime');
|
|
18
|
+
var Stream = require('effect/Stream');
|
|
19
|
+
var node_stream = require('node:stream');
|
|
20
|
+
var Http_Platform_dist_effectPlatformBunHttpPlatform = require('../Http/Platform/dist/effect-platform-bun-Http-Platform.cjs.prod.js');
|
|
21
|
+
|
|
22
|
+
function _interopNamespace(e) {
|
|
23
|
+
if (e && e.__esModule) return e;
|
|
24
|
+
var n = Object.create(null);
|
|
25
|
+
if (e) {
|
|
26
|
+
Object.keys(e).forEach(function (k) {
|
|
27
|
+
if (k !== 'default') {
|
|
28
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
29
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function () { return e[k]; }
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
n["default"] = e;
|
|
37
|
+
return Object.freeze(n);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function _mergeNamespaces(n, m) {
|
|
41
|
+
m.forEach(function (e) {
|
|
42
|
+
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
43
|
+
if (k !== 'default' && !(k in n)) {
|
|
44
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
45
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
get: function () { return e[k]; }
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
return Object.freeze(n);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
var FormData__namespace = /*#__PURE__*/_interopNamespace(FormData);
|
|
56
|
+
var Headers__namespace = /*#__PURE__*/_interopNamespace(Headers);
|
|
57
|
+
var IncomingMessage__namespace = /*#__PURE__*/_interopNamespace(IncomingMessage);
|
|
58
|
+
var Middleware__namespace = /*#__PURE__*/_interopNamespace(Middleware);
|
|
59
|
+
var Server__namespace = /*#__PURE__*/_interopNamespace(Server$1);
|
|
60
|
+
var Error__namespace = /*#__PURE__*/_interopNamespace(Error);
|
|
61
|
+
var ServerRequest__namespace = /*#__PURE__*/_interopNamespace(ServerRequest);
|
|
62
|
+
var UrlParams__namespace = /*#__PURE__*/_interopNamespace(UrlParams);
|
|
63
|
+
var Cause__namespace = /*#__PURE__*/_interopNamespace(Cause);
|
|
64
|
+
var Config__namespace = /*#__PURE__*/_interopNamespace(Config);
|
|
65
|
+
var Effect__namespace = /*#__PURE__*/_interopNamespace(Effect);
|
|
66
|
+
var Layer__namespace = /*#__PURE__*/_interopNamespace(Layer);
|
|
67
|
+
var Option__namespace = /*#__PURE__*/_interopNamespace(Option);
|
|
68
|
+
var Runtime__namespace = /*#__PURE__*/_interopNamespace(Runtime);
|
|
69
|
+
var Stream__namespace = /*#__PURE__*/_interopNamespace(Stream);
|
|
70
|
+
|
|
71
|
+
/** @internal */
|
|
72
|
+
const make$1 = options => Effect__namespace.gen(function* (_) {
|
|
73
|
+
const handlerStack = [function (_request, _server) {
|
|
74
|
+
return new Response("not found", {
|
|
75
|
+
status: 404
|
|
76
|
+
});
|
|
77
|
+
}];
|
|
78
|
+
const server = Bun.serve({
|
|
79
|
+
...options,
|
|
80
|
+
fetch: handlerStack[0]
|
|
81
|
+
});
|
|
82
|
+
yield* _(Effect__namespace.addFinalizer(() => Effect__namespace.sync(() => {
|
|
83
|
+
server.stop();
|
|
84
|
+
})));
|
|
85
|
+
return Server__namespace.make({
|
|
86
|
+
address: {
|
|
87
|
+
_tag: "TcpAddress",
|
|
88
|
+
port: server.port,
|
|
89
|
+
hostname: server.hostname
|
|
90
|
+
},
|
|
91
|
+
serve(httpApp, middleware) {
|
|
92
|
+
const app = middleware ? middleware(respond(httpApp)) : respond(httpApp);
|
|
93
|
+
return Function.pipe(Effect__namespace.all([Effect__namespace.runtime(), Effect__namespace.fiberId]), Effect__namespace.zipLeft(Effect__namespace.addFinalizer(() => Effect__namespace.sync(() => {
|
|
94
|
+
handlerStack.pop();
|
|
95
|
+
server.reload({
|
|
96
|
+
fetch: handlerStack[handlerStack.length - 1]
|
|
97
|
+
});
|
|
98
|
+
}))), Effect__namespace.flatMap(([runtime, fiberId]) => Effect__namespace.async(() => {
|
|
99
|
+
const runFork = Runtime__namespace.runFork(runtime);
|
|
100
|
+
function handler(request, _server) {
|
|
101
|
+
console.log(request);
|
|
102
|
+
return new Promise((resolve, reject) => {
|
|
103
|
+
const fiber = runFork(Effect__namespace.provideService(app, ServerRequest__namespace.ServerRequest, new ServerRequestImpl(request, resolve, reject, removeHost(request.url))));
|
|
104
|
+
request.signal.addEventListener("abort", () => {
|
|
105
|
+
runFork(fiber.interruptAsFork(fiberId));
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
handlerStack.push(handler);
|
|
110
|
+
server.reload({
|
|
111
|
+
fetch: handler
|
|
112
|
+
});
|
|
113
|
+
})));
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
const makeResponse = (request, response) => {
|
|
118
|
+
if (request.method === "HEAD") {
|
|
119
|
+
return new Response(undefined, {
|
|
120
|
+
status: response.status,
|
|
121
|
+
statusText: response.statusText,
|
|
122
|
+
headers: response.headers
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
const body = response.body;
|
|
126
|
+
switch (body._tag) {
|
|
127
|
+
case "Empty":
|
|
128
|
+
{
|
|
129
|
+
return new Response(undefined, {
|
|
130
|
+
status: response.status,
|
|
131
|
+
statusText: response.statusText,
|
|
132
|
+
headers: response.headers
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
case "Uint8Array":
|
|
136
|
+
case "Raw":
|
|
137
|
+
{
|
|
138
|
+
return new Response(body.body, {
|
|
139
|
+
status: response.status,
|
|
140
|
+
statusText: response.statusText,
|
|
141
|
+
headers: response.headers
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
case "FormData":
|
|
145
|
+
{
|
|
146
|
+
return new Response(body.formData, {
|
|
147
|
+
status: response.status,
|
|
148
|
+
statusText: response.statusText,
|
|
149
|
+
headers: response.headers
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
case "Stream":
|
|
153
|
+
{
|
|
154
|
+
return new Response(Stream__namespace.toReadableStream(body.stream), {
|
|
155
|
+
status: response.status,
|
|
156
|
+
statusText: response.statusText,
|
|
157
|
+
headers: response.headers
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
const respond = /*#__PURE__*/Middleware__namespace.make(httpApp => Effect__namespace.flatMap(ServerRequest__namespace.ServerRequest, request => Effect__namespace.onExit(httpApp, exit => Effect__namespace.sync(() => {
|
|
163
|
+
if (exit._tag === "Success") {
|
|
164
|
+
request.resolve(makeResponse(request, exit.value));
|
|
165
|
+
} else {
|
|
166
|
+
request.reject(Cause__namespace.pretty(exit.cause));
|
|
167
|
+
}
|
|
168
|
+
}))));
|
|
169
|
+
|
|
170
|
+
/** @internal */
|
|
171
|
+
const layer$1 = options => Layer__namespace.merge(Layer__namespace.scoped(Server__namespace.Server, make$1(options)), Http_Platform_dist_effectPlatformBunHttpPlatform.layer);
|
|
172
|
+
|
|
173
|
+
/** @internal */
|
|
174
|
+
const layerConfig$1 = options => Layer__namespace.merge(Layer__namespace.scoped(Server__namespace.Server, Effect__namespace.flatMap(Effect__namespace.config(Config__namespace.unwrap(options)), make$1)), Http_Platform_dist_effectPlatformBunHttpPlatform.layer);
|
|
175
|
+
class ServerRequestImpl {
|
|
176
|
+
constructor(source, resolve, reject, url, headersOverride, remoteAddressOverride) {
|
|
177
|
+
this.source = source;
|
|
178
|
+
this.resolve = resolve;
|
|
179
|
+
this.reject = reject;
|
|
180
|
+
this.url = url;
|
|
181
|
+
this.headersOverride = headersOverride;
|
|
182
|
+
this.remoteAddressOverride = remoteAddressOverride;
|
|
183
|
+
this[ServerRequest__namespace.TypeId] = ServerRequest__namespace.TypeId;
|
|
184
|
+
this[IncomingMessage__namespace.TypeId] = IncomingMessage__namespace.TypeId;
|
|
185
|
+
}
|
|
186
|
+
modify(options) {
|
|
187
|
+
return new ServerRequestImpl(this.source, this.resolve, this.reject, options.url ?? this.url, options.headers ?? this.headersOverride, options.remoteAddress ?? this.remoteAddressOverride);
|
|
188
|
+
}
|
|
189
|
+
get method() {
|
|
190
|
+
return this.source.method;
|
|
191
|
+
}
|
|
192
|
+
get originalUrl() {
|
|
193
|
+
return this.source.url;
|
|
194
|
+
}
|
|
195
|
+
get remoteAddress() {
|
|
196
|
+
return this.remoteAddressOverride ? Option__namespace.some(this.remoteAddressOverride) : Option__namespace.none();
|
|
197
|
+
}
|
|
198
|
+
get headers() {
|
|
199
|
+
this.headersOverride ??= Headers__namespace.fromInput(this.source.headers);
|
|
200
|
+
return this.headersOverride;
|
|
201
|
+
}
|
|
202
|
+
get stream() {
|
|
203
|
+
return this.source.body ? Stream__namespace.fromReadableStream(() => this.source.body, _ => Error__namespace.RequestError({
|
|
204
|
+
request: this,
|
|
205
|
+
reason: "Decode",
|
|
206
|
+
error: _
|
|
207
|
+
})) : Stream__namespace.fail(Error__namespace.RequestError({
|
|
208
|
+
request: this,
|
|
209
|
+
reason: "Decode",
|
|
210
|
+
error: "can not create stream from empty body"
|
|
211
|
+
}));
|
|
212
|
+
}
|
|
213
|
+
get text() {
|
|
214
|
+
if (this.textEffect) {
|
|
215
|
+
return this.textEffect;
|
|
216
|
+
}
|
|
217
|
+
this.textEffect = Effect__namespace.runSync(Effect__namespace.cached(Effect__namespace.tryPromise({
|
|
218
|
+
try: () => this.source.text(),
|
|
219
|
+
catch: error => Error__namespace.RequestError({
|
|
220
|
+
request: this,
|
|
221
|
+
reason: "Decode",
|
|
222
|
+
error
|
|
223
|
+
})
|
|
224
|
+
})));
|
|
225
|
+
return this.textEffect;
|
|
226
|
+
}
|
|
227
|
+
get json() {
|
|
228
|
+
return Effect__namespace.tryMap(this.text, {
|
|
229
|
+
try: _ => JSON.parse(_),
|
|
230
|
+
catch: error => Error__namespace.RequestError({
|
|
231
|
+
request: this,
|
|
232
|
+
reason: "Decode",
|
|
233
|
+
error
|
|
234
|
+
})
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
get urlParamsBody() {
|
|
238
|
+
return Effect__namespace.flatMap(this.text, _ => Effect__namespace.try({
|
|
239
|
+
try: () => UrlParams__namespace.fromInput(new URLSearchParams(_)),
|
|
240
|
+
catch: error => Error__namespace.RequestError({
|
|
241
|
+
request: this,
|
|
242
|
+
reason: "Decode",
|
|
243
|
+
error
|
|
244
|
+
})
|
|
245
|
+
}));
|
|
246
|
+
}
|
|
247
|
+
get formData() {
|
|
248
|
+
if (this.formDataEffect) {
|
|
249
|
+
return this.formDataEffect;
|
|
250
|
+
}
|
|
251
|
+
this.formDataEffect = Effect__namespace.runSync(Effect__namespace.cached(FormData__namespace.formData(node_stream.Readable.fromWeb(this.source.body), this.headers)));
|
|
252
|
+
return this.formDataEffect;
|
|
253
|
+
}
|
|
254
|
+
get formDataStream() {
|
|
255
|
+
return FormData__namespace.stream(node_stream.Readable.fromWeb(this.source.body), this.headers);
|
|
256
|
+
}
|
|
257
|
+
get arrayBuffer() {
|
|
258
|
+
if (this.arrayBuffer) {
|
|
259
|
+
return this.arrayBuffer;
|
|
260
|
+
}
|
|
261
|
+
this.arrayBufferEffect = Effect__namespace.runSync(Effect__namespace.cached(Effect__namespace.tryPromise({
|
|
262
|
+
try: () => this.source.arrayBuffer(),
|
|
263
|
+
catch: error => Error__namespace.RequestError({
|
|
264
|
+
request: this,
|
|
265
|
+
reason: "Decode",
|
|
266
|
+
error
|
|
267
|
+
})
|
|
268
|
+
})));
|
|
269
|
+
return this.arrayBufferEffect;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const removeHost = url => {
|
|
273
|
+
if (url[0] === "/") {
|
|
274
|
+
return url;
|
|
275
|
+
}
|
|
276
|
+
const index = url.indexOf("/", url.indexOf("//") + 2);
|
|
277
|
+
return index === -1 ? "/" : url.slice(index);
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* @since 1.0.0
|
|
282
|
+
*
|
|
283
|
+
* Also includes exports from [`@effect/platform/Http/Server`](https://effect-ts.github.io/platform/platform/Http/Server.ts.html).
|
|
284
|
+
*/
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* @since 1.0.0
|
|
288
|
+
* @category constructors
|
|
289
|
+
*/
|
|
290
|
+
const make = make$1;
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* @since 1.0.0
|
|
294
|
+
* @category layers
|
|
295
|
+
*/
|
|
296
|
+
const layer = layer$1;
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* @since 1.0.0
|
|
300
|
+
* @category layers
|
|
301
|
+
*/
|
|
302
|
+
const layerConfig = layerConfig$1;
|
|
303
|
+
|
|
304
|
+
var Server = /*#__PURE__*/_mergeNamespaces({
|
|
305
|
+
__proto__: null,
|
|
306
|
+
make: make,
|
|
307
|
+
layer: layer,
|
|
308
|
+
layerConfig: layerConfig
|
|
309
|
+
}, [Server__namespace]);
|
|
310
|
+
|
|
311
|
+
exports.Server = Server;
|
|
312
|
+
exports.layer = layer;
|
|
313
|
+
exports.layerConfig = layerConfig;
|
|
314
|
+
exports.make = make;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Stream$1 = require('@effect/platform-node/Stream');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @since 1.0.0
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
var Stream = /*#__PURE__*/Object.freeze({
|
|
10
|
+
__proto__: null,
|
|
11
|
+
fromReadable: Stream$1.fromReadable,
|
|
12
|
+
toString: Stream$1.toString,
|
|
13
|
+
toUint8Array: Stream$1.toUint8Array
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
exports.Stream = Stream;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Stream$1 = require('@effect/platform-node/Stream');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @since 1.0.0
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
var Stream = /*#__PURE__*/Object.freeze({
|
|
10
|
+
__proto__: null,
|
|
11
|
+
fromReadable: Stream$1.fromReadable,
|
|
12
|
+
toString: Stream$1.toString,
|
|
13
|
+
toUint8Array: Stream$1.toUint8Array
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
exports.Stream = Stream;
|