@effect/platform-bun 0.1.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/BunContext.d.ts +15 -0
- package/BunContext.d.ts.map +1 -0
- package/BunContext.js +23 -0
- package/BunContext.js.map +1 -0
- package/Command.d.ts +111 -0
- package/Command.d.ts.map +1 -0
- package/Command.js +103 -0
- package/Command.js.map +1 -0
- package/CommandExecutor.d.ts +41 -0
- package/CommandExecutor.d.ts.map +1 -0
- package/CommandExecutor.js +19 -0
- package/CommandExecutor.js.map +1 -0
- package/Effectify.d.ts +19 -0
- package/Effectify.d.ts.map +1 -0
- package/Effectify.js +13 -0
- package/Effectify.js.map +1 -0
- package/Error.d.ts +30 -0
- package/Error.d.ts.map +1 -0
- package/Error.js +25 -0
- package/Error.js.map +1 -0
- package/FileSystem.d.ts +71 -0
- package/FileSystem.d.ts.map +1 -0
- package/FileSystem.js +25 -0
- package/FileSystem.js.map +1 -0
- package/Http/Server.d.ts +34 -0
- package/Http/Server.d.ts.map +1 -0
- package/Http/Server.js +49 -0
- package/Http/Server.js.map +1 -0
- package/Http/ServerResponse.d.ts +23 -0
- package/Http/ServerResponse.d.ts.map +1 -0
- package/Http/ServerResponse.js +38 -0
- package/Http/ServerResponse.js.map +1 -0
- package/HttpClient.d.ts +61 -0
- package/HttpClient.d.ts.map +1 -0
- package/HttpClient.js +23 -0
- package/HttpClient.js.map +1 -0
- package/HttpServer.d.ts +101 -0
- package/HttpServer.d.ts.map +1 -0
- package/HttpServer.js +33 -0
- package/HttpServer.js.map +1 -0
- package/KeyValueStore.d.ts +13 -0
- package/KeyValueStore.d.ts.map +1 -0
- package/KeyValueStore.js +28 -0
- package/KeyValueStore.js.map +1 -0
- package/LICENSE +21 -0
- package/Path.d.ts +25 -0
- package/Path.d.ts.map +1 -0
- package/Path.js +31 -0
- package/Path.js.map +1 -0
- package/README.md +3 -0
- package/Runtime.d.ts +26 -0
- package/Runtime.d.ts.map +1 -0
- package/Runtime.js +19 -0
- package/Runtime.js.map +1 -0
- package/Sink.d.ts +16 -0
- package/Sink.d.ts.map +1 -0
- package/Sink.js +13 -0
- package/Sink.js.map +1 -0
- package/Stream.d.ts +26 -0
- package/Stream.d.ts.map +1 -0
- package/Stream.js +25 -0
- package/Stream.js.map +1 -0
- package/internal/http/server.d.ts +2 -0
- package/internal/http/server.d.ts.map +1 -0
- package/internal/http/server.js +203 -0
- package/internal/http/server.js.map +1 -0
- package/internal/http/serverResponse.d.ts +2 -0
- package/internal/http/serverResponse.d.ts.map +1 -0
- package/internal/http/serverResponse.js +52 -0
- package/internal/http/serverResponse.js.map +1 -0
- package/mjs/BunContext.mjs +14 -0
- package/mjs/BunContext.mjs.map +1 -0
- package/mjs/Command.mjs +85 -0
- package/mjs/Command.mjs.map +1 -0
- package/mjs/CommandExecutor.mjs +15 -0
- package/mjs/CommandExecutor.mjs.map +1 -0
- package/mjs/Effectify.mjs +10 -0
- package/mjs/Effectify.mjs.map +1 -0
- package/mjs/Error.mjs +20 -0
- package/mjs/Error.mjs.map +1 -0
- package/mjs/FileSystem.mjs +20 -0
- package/mjs/FileSystem.mjs.map +1 -0
- package/mjs/Http/Server.mjs +21 -0
- package/mjs/Http/Server.mjs.map +1 -0
- package/mjs/Http/ServerResponse.mjs +13 -0
- package/mjs/Http/ServerResponse.mjs.map +1 -0
- package/mjs/HttpClient.mjs +61 -0
- package/mjs/HttpClient.mjs.map +1 -0
- package/mjs/HttpServer.mjs +101 -0
- package/mjs/HttpServer.mjs.map +1 -0
- package/mjs/KeyValueStore.mjs +13 -0
- package/mjs/KeyValueStore.mjs.map +1 -0
- package/mjs/Path.mjs +25 -0
- package/mjs/Path.mjs.map +1 -0
- package/mjs/Runtime.mjs +15 -0
- package/mjs/Runtime.mjs.map +1 -0
- package/mjs/Sink.mjs +10 -0
- package/mjs/Sink.mjs.map +1 -0
- package/mjs/Stream.mjs +20 -0
- package/mjs/Stream.mjs.map +1 -0
- package/mjs/internal/http/server.mjs +192 -0
- package/mjs/internal/http/server.mjs.map +1 -0
- package/mjs/internal/http/serverResponse.mjs +42 -0
- package/mjs/internal/http/serverResponse.mjs.map +1 -0
- package/package.json +33 -0
- package/src/BunContext.ts +24 -0
- package/src/Command.ts +114 -0
- package/src/CommandExecutor.ts +44 -0
- package/src/Effectify.ts +22 -0
- package/src/Error.ts +31 -0
- package/src/FileSystem.ts +74 -0
- package/src/Http/Server.ts +43 -0
- package/src/Http/ServerResponse.ts +33 -0
- package/src/HttpClient.ts +62 -0
- package/src/HttpServer.ts +102 -0
- package/src/KeyValueStore.ts +15 -0
- package/src/Path.ts +26 -0
- package/src/Runtime.ts +29 -0
- package/src/Sink.ts +19 -0
- package/src/Stream.ts +29 -0
- package/src/internal/http/server.ts +263 -0
- package/src/internal/http/serverResponse.ts +52 -0
- package/tsconfig.build.json +12 -0
- package/tsconfig.examples.json +12 -0
- package/tsconfig.json +11 -0
- package/tsconfig.test.json +17 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since 1.0.0
|
|
3
|
+
*/
|
|
4
|
+
import * as server from "@effect/platform-bun/Http/Server";
|
|
5
|
+
import * as response from "@effect/platform-bun/Http/ServerResponse";
|
|
6
|
+
import * as etag from "@effect/platform-node/Http/Etag";
|
|
7
|
+
import * as formData from "@effect/platform-node/Http/FormData";
|
|
8
|
+
import * as app from "@effect/platform/Http/App";
|
|
9
|
+
import * as body from "@effect/platform/Http/Body";
|
|
10
|
+
import * as headers from "@effect/platform/Http/Headers";
|
|
11
|
+
import * as middleware from "@effect/platform/Http/Middleware";
|
|
12
|
+
import * as router from "@effect/platform/Http/Router";
|
|
13
|
+
import * as error from "@effect/platform/Http/ServerError";
|
|
14
|
+
import * as request from "@effect/platform/Http/ServerRequest";
|
|
15
|
+
import * as urlParams from "@effect/platform/Http/UrlParams";
|
|
16
|
+
export {
|
|
17
|
+
/**
|
|
18
|
+
* @since 1.0.0
|
|
19
|
+
*
|
|
20
|
+
* - Docs: [Http/App](https://effect-ts.github.io/platform/platform/Http/App.ts.html)
|
|
21
|
+
* - Module: `@effect/platform/Http/App`
|
|
22
|
+
*/
|
|
23
|
+
app,
|
|
24
|
+
/**
|
|
25
|
+
* @since 1.0.0
|
|
26
|
+
*
|
|
27
|
+
* - Docs: [Http/Body](https://effect-ts.github.io/platform/platform/Http/Body.ts.html)
|
|
28
|
+
* - Module: `@effect/platform/Http/Body`
|
|
29
|
+
*/
|
|
30
|
+
body,
|
|
31
|
+
/**
|
|
32
|
+
* @since 1.0.0
|
|
33
|
+
*
|
|
34
|
+
* - Docs: [Http/ServerError](https://effect-ts.github.io/platform/platform/Http/ServerError.ts.html)
|
|
35
|
+
* - Module: `@effect/platform/Http/ServerError`
|
|
36
|
+
*/
|
|
37
|
+
error,
|
|
38
|
+
/**
|
|
39
|
+
* @since 1.0.0
|
|
40
|
+
*
|
|
41
|
+
* - Docs: [Http/Etag](https://effect-ts.github.io/platform/platform-node/Http/Etag.ts.html)
|
|
42
|
+
* - Module: `@effect/platform-node/Http/Etag`
|
|
43
|
+
*/
|
|
44
|
+
etag,
|
|
45
|
+
/**
|
|
46
|
+
* @since 1.0.0
|
|
47
|
+
*
|
|
48
|
+
* - Docs: [Http/FormData](https://effect-ts.github.io/platform/platform-node/Http/FormData.ts.html)
|
|
49
|
+
* - Module: `@effect/platform-node/Http/FormData`
|
|
50
|
+
*/
|
|
51
|
+
formData,
|
|
52
|
+
/**
|
|
53
|
+
* @since 1.0.0
|
|
54
|
+
*
|
|
55
|
+
* - Docs: [Http/Headers](https://effect-ts.github.io/platform/platform/Http/Headers.ts.html)
|
|
56
|
+
* - Module: `@effect/platform/Http/Headers`
|
|
57
|
+
*/
|
|
58
|
+
headers,
|
|
59
|
+
/**
|
|
60
|
+
* @since 1.0.0
|
|
61
|
+
*
|
|
62
|
+
* - Docs: [Http/Middleware](https://effect-ts.github.io/platform/platform/Http/Middleware.ts.html)
|
|
63
|
+
* - Module: `@effect/platform/Http/Middleware`
|
|
64
|
+
*/
|
|
65
|
+
middleware,
|
|
66
|
+
/**
|
|
67
|
+
* @since 1.0.0
|
|
68
|
+
*
|
|
69
|
+
* - Docs: [Http/ServerRequest](https://effect-ts.github.io/platform/platform/Http/ServerRequest.ts.html)
|
|
70
|
+
* - Module: `@effect/platform/Http/ServerRequest`
|
|
71
|
+
*/
|
|
72
|
+
request,
|
|
73
|
+
/**
|
|
74
|
+
* @since 1.0.0
|
|
75
|
+
*
|
|
76
|
+
* - Docs: [Http/ServerResponse](https://effect-ts.github.io/platform/platform-bun/Http/ServerResponse.ts.html)
|
|
77
|
+
* - Module: `@effect/platform-bun/Http/ServerResponse`
|
|
78
|
+
*/
|
|
79
|
+
response,
|
|
80
|
+
/**
|
|
81
|
+
* @since 1.0.0
|
|
82
|
+
*
|
|
83
|
+
* - Docs: [Http/Router](https://effect-ts.github.io/platform/platform/Http/Router.ts.html)
|
|
84
|
+
* - Module: `@effect/platform/Http/Router`
|
|
85
|
+
*/
|
|
86
|
+
router,
|
|
87
|
+
/**
|
|
88
|
+
* @since 1.0.0
|
|
89
|
+
*
|
|
90
|
+
* - Docs: [Http/Router](https://effect-ts.github.io/platform/platform-bun/Http/Server.ts.html)
|
|
91
|
+
* - Module: `@effect/platform-bun/Http/Server`
|
|
92
|
+
*/
|
|
93
|
+
server,
|
|
94
|
+
/**
|
|
95
|
+
* @since 1.0.0
|
|
96
|
+
*
|
|
97
|
+
* - Docs: [Http/UrlParams](https://effect-ts.github.io/platform/platform/Http/UrlParams.ts.html)
|
|
98
|
+
* - Module: `@effect/platform/Http/UrlParams`
|
|
99
|
+
*/
|
|
100
|
+
urlParams };
|
|
101
|
+
//# sourceMappingURL=HttpServer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpServer.mjs","names":["server","response","etag","formData","app","body","headers","middleware","router","error","request","urlParams"],"sources":["../src/HttpServer.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAGA,OAAO,KAAKA,MAAM,MAAM,kCAAkC;AAC1D,OAAO,KAAKC,QAAQ,MAAM,0CAA0C;AACpE,OAAO,KAAKC,IAAI,MAAM,iCAAiC;AACvD,OAAO,KAAKC,QAAQ,MAAM,qCAAqC;AAC/D,OAAO,KAAKC,GAAG,MAAM,2BAA2B;AAChD,OAAO,KAAKC,IAAI,MAAM,4BAA4B;AAClD,OAAO,KAAKC,OAAO,MAAM,+BAA+B;AACxD,OAAO,KAAKC,UAAU,MAAM,kCAAkC;AAC9D,OAAO,KAAKC,MAAM,MAAM,8BAA8B;AACtD,OAAO,KAAKC,KAAK,MAAM,mCAAmC;AAC1D,OAAO,KAAKC,OAAO,MAAM,qCAAqC;AAC9D,OAAO,KAAKC,SAAS,MAAM,iCAAiC;AAE5D;AACE;;;;;;AAMAP,GAAG;AACH;;;;;;AAMAC,IAAI;AACJ;;;;;;AAMAI,KAAK;AACL;;;;;;AAMAP,IAAI;AACJ;;;;;;AAMAC,QAAQ;AACR;;;;;;AAMAG,OAAO;AACP;;;;;;AAMAC,UAAU;AACV;;;;;;AAMAG,OAAO;AACP;;;;;;AAMAT,QAAQ;AACR;;;;;;AAMAO,MAAM;AACN;;;;;;AAMAR,MAAM;AACN;;;;;;AAMAW,SAAS"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since 1.0.0
|
|
3
|
+
*
|
|
4
|
+
* Also includes exports from [`@effect/platform/KeyValueStore`](https://effect-ts.github.io/platform/platform/KeyValueStore.ts.html).
|
|
5
|
+
*/
|
|
6
|
+
export * from "@effect/platform/KeyValueStore";
|
|
7
|
+
export {
|
|
8
|
+
/**
|
|
9
|
+
* @since 1.0.0
|
|
10
|
+
* @category layers
|
|
11
|
+
*/
|
|
12
|
+
layerFileSystem } from "@effect/platform-node/KeyValueStore";
|
|
13
|
+
//# sourceMappingURL=KeyValueStore.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KeyValueStore.mjs","names":["layerFileSystem"],"sources":["../src/KeyValueStore.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;AAMA,cAAc,gCAAgC;AAE9C;AACE;;;;AAIAA,eAAe,QACV,qCAAqC"}
|
package/mjs/Path.mjs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since 1.0.0
|
|
3
|
+
*/
|
|
4
|
+
export {
|
|
5
|
+
/**
|
|
6
|
+
* @since 1.0.0
|
|
7
|
+
* @category layer
|
|
8
|
+
*/
|
|
9
|
+
layer,
|
|
10
|
+
/**
|
|
11
|
+
* @since 1.0.0
|
|
12
|
+
* @category layer
|
|
13
|
+
*/
|
|
14
|
+
layerPosix,
|
|
15
|
+
/**
|
|
16
|
+
* @since 1.0.0
|
|
17
|
+
* @category layer
|
|
18
|
+
*/
|
|
19
|
+
layerWin32,
|
|
20
|
+
/**
|
|
21
|
+
* @since 1.0.0
|
|
22
|
+
* @category tag
|
|
23
|
+
*/
|
|
24
|
+
Path } from "@effect/platform-node/Path";
|
|
25
|
+
//# sourceMappingURL=Path.mjs.map
|
package/mjs/Path.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Path.mjs","names":["layer","layerPosix","layerWin32","Path"],"sources":["../src/Path.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAIA;AACE;;;;AAIAA,KAAK;AACL;;;;AAIAC,UAAU;AACV;;;;AAIAC,UAAU;AACV;;;;AAIAC,IAAI,QACC,4BAA4B"}
|
package/mjs/Runtime.mjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since 1.0.0
|
|
3
|
+
*/
|
|
4
|
+
export {
|
|
5
|
+
/**
|
|
6
|
+
* @category teardown
|
|
7
|
+
* @since 1.0.0
|
|
8
|
+
*/
|
|
9
|
+
defaultTeardown,
|
|
10
|
+
/**
|
|
11
|
+
* @since 1.0.0
|
|
12
|
+
* @category runtime
|
|
13
|
+
*/
|
|
14
|
+
runMain } from "@effect/platform-node/Runtime";
|
|
15
|
+
//# sourceMappingURL=Runtime.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Runtime.mjs","names":["defaultTeardown","runMain"],"sources":["../src/Runtime.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAiBA;AACE;;;;AAIAA,eAAe;AACf;;;;AAIAC,OAAO,QACF,+BAA+B"}
|
package/mjs/Sink.mjs
ADDED
package/mjs/Sink.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sink.mjs","names":["fromWritable"],"sources":["../src/Sink.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAYA;AACE;;;;AAIAA,YAAY,QACP,4BAA4B"}
|
package/mjs/Stream.mjs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since 1.0.0
|
|
3
|
+
*/
|
|
4
|
+
export {
|
|
5
|
+
/**
|
|
6
|
+
* @category constructors
|
|
7
|
+
* @since 1.0.0
|
|
8
|
+
*/
|
|
9
|
+
fromReadable,
|
|
10
|
+
/**
|
|
11
|
+
* @since 1.0.0
|
|
12
|
+
* @category conversions
|
|
13
|
+
*/
|
|
14
|
+
toString,
|
|
15
|
+
/**
|
|
16
|
+
* @since 1.0.0
|
|
17
|
+
* @category conversions
|
|
18
|
+
*/
|
|
19
|
+
toUint8Array } from "@effect/platform-node/Stream";
|
|
20
|
+
//# sourceMappingURL=Stream.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Stream.mjs","names":["fromReadable","toString","toUint8Array"],"sources":["../src/Stream.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAYA;AACE;;;;AAIAA,YAAY;AACZ;;;;AAIAC,QAAQ;AACR;;;;AAIAC,YAAY,QACP,8BAA8B"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import * as Config from "@effect/io/Config";
|
|
2
|
+
import * as Effect from "@effect/io/Effect";
|
|
3
|
+
import * as Layer from "@effect/io/Layer";
|
|
4
|
+
import * as Runtime from "@effect/io/Runtime";
|
|
5
|
+
import * as Etag from "@effect/platform-node/Http/Etag";
|
|
6
|
+
import * as FormData from "@effect/platform-node/Http/FormData";
|
|
7
|
+
import * as Headers from "@effect/platform/Http/Headers";
|
|
8
|
+
import * as IncomingMessage from "@effect/platform/Http/IncomingMessage";
|
|
9
|
+
import * as Server from "@effect/platform/Http/Server";
|
|
10
|
+
import * as Error from "@effect/platform/Http/ServerError";
|
|
11
|
+
import * as ServerRequest from "@effect/platform/Http/ServerRequest";
|
|
12
|
+
import * as UrlParams from "@effect/platform/Http/UrlParams";
|
|
13
|
+
import * as Stream from "@effect/stream/Stream";
|
|
14
|
+
import { Readable } from "node:stream";
|
|
15
|
+
/** @internal */
|
|
16
|
+
export const make = options => Effect.gen(function* (_) {
|
|
17
|
+
const handlerStack = [function (_request, _server) {
|
|
18
|
+
return new Response("not found", {
|
|
19
|
+
status: 404
|
|
20
|
+
});
|
|
21
|
+
}];
|
|
22
|
+
const server = Bun.serve({
|
|
23
|
+
...options,
|
|
24
|
+
fetch: handlerStack[0]
|
|
25
|
+
});
|
|
26
|
+
yield* _(Effect.addFinalizer(() => Effect.sync(() => {
|
|
27
|
+
server.stop();
|
|
28
|
+
})));
|
|
29
|
+
return Server.make({
|
|
30
|
+
address: {
|
|
31
|
+
_tag: "TcpAddress",
|
|
32
|
+
port: server.port,
|
|
33
|
+
hostname: server.hostname
|
|
34
|
+
},
|
|
35
|
+
serve(httpApp, middleware) {
|
|
36
|
+
const app = Effect.flatMap(middleware ? middleware(httpApp) : httpApp, respond);
|
|
37
|
+
return Effect.acquireRelease(() => Effect.sync(() => {
|
|
38
|
+
handlerStack.pop();
|
|
39
|
+
server.reload({
|
|
40
|
+
fetch: handlerStack[handlerStack.length - 1]
|
|
41
|
+
});
|
|
42
|
+
}))(Effect.flatMap(runtime => Effect.async(() => {
|
|
43
|
+
const runPromise = Runtime.runPromise(runtime);
|
|
44
|
+
function handler(request, _server) {
|
|
45
|
+
return runPromise(Effect.provideService(app, ServerRequest.ServerRequest, new ServerRequestImpl(request)));
|
|
46
|
+
}
|
|
47
|
+
handlerStack.push(handler);
|
|
48
|
+
server.reload({
|
|
49
|
+
fetch: handler
|
|
50
|
+
});
|
|
51
|
+
}))(Effect.runtime()));
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
const respond = response => Effect.sync(() => {
|
|
56
|
+
const body = response.body;
|
|
57
|
+
switch (body._tag) {
|
|
58
|
+
case "Empty":
|
|
59
|
+
{
|
|
60
|
+
return new Response(undefined, {
|
|
61
|
+
status: response.status,
|
|
62
|
+
statusText: response.statusText,
|
|
63
|
+
headers: response.headers
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
case "Uint8Array":
|
|
67
|
+
case "Raw":
|
|
68
|
+
{
|
|
69
|
+
return new Response(body.body, {
|
|
70
|
+
status: response.status,
|
|
71
|
+
statusText: response.statusText,
|
|
72
|
+
headers: response.headers
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
case "FormData":
|
|
76
|
+
{
|
|
77
|
+
return new Response(body.formData, {
|
|
78
|
+
status: response.status,
|
|
79
|
+
statusText: response.statusText,
|
|
80
|
+
headers: response.headers
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
case "Stream":
|
|
84
|
+
{
|
|
85
|
+
return new Response(Stream.toReadableStream(body.stream), {
|
|
86
|
+
status: response.status,
|
|
87
|
+
statusText: response.statusText,
|
|
88
|
+
headers: response.headers
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
/** @internal */
|
|
94
|
+
export const layer = options => Layer.merge(Layer.scoped(Server.Server, make(options)), Etag.layer);
|
|
95
|
+
/** @internal */
|
|
96
|
+
export const layerConfig = options => Layer.merge(Layer.scoped(Server.Server, Effect.flatMap(Effect.config(Config.unwrap(options)), make)), Etag.layer);
|
|
97
|
+
class ServerRequestImpl {
|
|
98
|
+
constructor(source, url = source.url, headersOverride) {
|
|
99
|
+
this.source = source;
|
|
100
|
+
this.url = url;
|
|
101
|
+
this.headersOverride = headersOverride;
|
|
102
|
+
this[ServerRequest.TypeId] = ServerRequest.TypeId;
|
|
103
|
+
this[IncomingMessage.TypeId] = IncomingMessage.TypeId;
|
|
104
|
+
}
|
|
105
|
+
get method() {
|
|
106
|
+
return this.source.method;
|
|
107
|
+
}
|
|
108
|
+
get originalUrl() {
|
|
109
|
+
return this.source.url;
|
|
110
|
+
}
|
|
111
|
+
get headers() {
|
|
112
|
+
this.headersOverride ??= Headers.fromInput(this.source.headers);
|
|
113
|
+
return this.headersOverride;
|
|
114
|
+
}
|
|
115
|
+
setUrl(url) {
|
|
116
|
+
return new ServerRequestImpl(this.source, url);
|
|
117
|
+
}
|
|
118
|
+
replaceHeaders(headers) {
|
|
119
|
+
return new ServerRequestImpl(this.source, this.url, headers);
|
|
120
|
+
}
|
|
121
|
+
get stream() {
|
|
122
|
+
return this.source.body ? Stream.fromReadableStream(() => this.source.body, _ => Error.RequestError({
|
|
123
|
+
request: this,
|
|
124
|
+
reason: "Decode",
|
|
125
|
+
error: _
|
|
126
|
+
})) : Stream.fail(Error.RequestError({
|
|
127
|
+
request: this,
|
|
128
|
+
reason: "Decode",
|
|
129
|
+
error: "can not create stream from empty body"
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
get text() {
|
|
133
|
+
if (this.textEffect) {
|
|
134
|
+
return this.textEffect;
|
|
135
|
+
}
|
|
136
|
+
this.textEffect = Effect.runSync(Effect.cached(Effect.tryPromise({
|
|
137
|
+
try: () => this.source.text(),
|
|
138
|
+
catch: error => Error.RequestError({
|
|
139
|
+
request: this,
|
|
140
|
+
reason: "Decode",
|
|
141
|
+
error
|
|
142
|
+
})
|
|
143
|
+
})));
|
|
144
|
+
return this.textEffect;
|
|
145
|
+
}
|
|
146
|
+
get json() {
|
|
147
|
+
return Effect.tryMap(this.text, {
|
|
148
|
+
try: _ => JSON.parse(_),
|
|
149
|
+
catch: error => Error.RequestError({
|
|
150
|
+
request: this,
|
|
151
|
+
reason: "Decode",
|
|
152
|
+
error
|
|
153
|
+
})
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
get urlParamsBody() {
|
|
157
|
+
return Effect.flatMap(this.text, _ => Effect.try({
|
|
158
|
+
try: () => UrlParams.fromInput(new URLSearchParams(_)),
|
|
159
|
+
catch: error => Error.RequestError({
|
|
160
|
+
request: this,
|
|
161
|
+
reason: "Decode",
|
|
162
|
+
error
|
|
163
|
+
})
|
|
164
|
+
}));
|
|
165
|
+
}
|
|
166
|
+
get formData() {
|
|
167
|
+
if (this.formDataEffect) {
|
|
168
|
+
return this.formDataEffect;
|
|
169
|
+
}
|
|
170
|
+
this.formDataEffect = Effect.runSync(Effect.cached(FormData.formData(Readable.fromWeb(this.source.body), this.headers)));
|
|
171
|
+
return this.formDataEffect;
|
|
172
|
+
}
|
|
173
|
+
get formDataStream() {
|
|
174
|
+
return FormData.stream(Readable.fromWeb(this.source.body), this.headers);
|
|
175
|
+
}
|
|
176
|
+
get arrayBuffer() {
|
|
177
|
+
if (this.arrayBuffer) {
|
|
178
|
+
return this.arrayBuffer;
|
|
179
|
+
}
|
|
180
|
+
this.arrayBufferEffect = Effect.runSync(Effect.cached(Effect.tryPromise({
|
|
181
|
+
try: () => this.source.arrayBuffer(),
|
|
182
|
+
catch: error => Error.RequestError({
|
|
183
|
+
request: this,
|
|
184
|
+
reason: "Decode",
|
|
185
|
+
error
|
|
186
|
+
})
|
|
187
|
+
})));
|
|
188
|
+
return this.arrayBufferEffect;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
ServerRequest.TypeId, IncomingMessage.TypeId;
|
|
192
|
+
//# sourceMappingURL=server.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.mjs","names":["Config","Effect","Layer","Runtime","Etag","FormData","Headers","IncomingMessage","Server","Error","ServerRequest","UrlParams","Stream","Readable","make","options","gen","_","handlerStack","_request","_server","Response","status","server","Bun","serve","fetch","addFinalizer","sync","stop","address","_tag","port","hostname","httpApp","middleware","app","flatMap","respond","acquireRelease","pop","reload","length","runtime","async","runPromise","handler","request","provideService","ServerRequestImpl","push","response","body","undefined","statusText","headers","formData","toReadableStream","stream","layer","merge","scoped","layerConfig","config","unwrap","constructor","source","url","headersOverride","TypeId","method","originalUrl","fromInput","setUrl","replaceHeaders","fromReadableStream","RequestError","reason","error","fail","text","textEffect","runSync","cached","tryPromise","try","catch","json","tryMap","JSON","parse","urlParamsBody","URLSearchParams","formDataEffect","fromWeb","formDataStream","arrayBuffer","arrayBufferEffect"],"sources":["../../../src/internal/http/server.ts"],"sourcesContent":[null],"mappings":"AACA,OAAO,KAAKA,MAAM,MAAM,mBAAmB;AAC3C,OAAO,KAAKC,MAAM,MAAM,mBAAmB;AAC3C,OAAO,KAAKC,KAAK,MAAM,kBAAkB;AACzC,OAAO,KAAKC,OAAO,MAAM,oBAAoB;AAE7C,OAAO,KAAKC,IAAI,MAAM,iCAAiC;AACvD,OAAO,KAAKC,QAAQ,MAAM,qCAAqC;AAG/D,OAAO,KAAKC,OAAO,MAAM,+BAA+B;AACxD,OAAO,KAAKC,eAAe,MAAM,uCAAuC;AAExE,OAAO,KAAKC,MAAM,MAAM,8BAA8B;AACtD,OAAO,KAAKC,KAAK,MAAM,mCAAmC;AAC1D,OAAO,KAAKC,aAAa,MAAM,qCAAqC;AAEpE,OAAO,KAAKC,SAAS,MAAM,iCAAiC;AAE5D,OAAO,KAAKC,MAAM,MAAM,uBAAuB;AAE/C,SAASC,QAAQ,QAAQ,aAAa;AAEtC;AACA,OAAO,MAAMC,IAAI,GACfC,OAA8C,IAE9Cd,MAAM,CAACe,GAAG,CAAC,WAAUC,CAAC;EACpB,MAAMC,YAAY,GAAiF,CACjG,UAASC,QAAQ,EAAEC,OAAO;IACxB,OAAO,I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,CAACA,WAAW;;IAEzB,IAAI,CAACC,iBAAiB,GAAGhG,MAAM,CAACiF,OAAO,CAACjF,MAAM,CAACkF,MAAM,CACnDlF,MAAM,CAACmF,UAAU,CAAC;MAChBC,GAAG,EAAEA,CAAA,KAAM,IAAI,CAACnB,MAAM,CAAC8B,WAAW,EAAE;MACpCV,KAAK,EAAGR,KAAK,IACXrE,KAAK,CAACmE,YAAY,CAAC;QACjB7B,OAAO,EAAE,IAAI;QACb8B,MAAM,EAAE,QAAQ;QAChBC;OACD;KACJ,CAAC,CACH,CAAC;IACF,OAAO,IAAI,CAACmB,iBAAiB;EAC/B;;AAhIUvF,aAAa,CAAC2D,MAAM,EACpB9D,eAAe,CAAC8D,MAAM"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as Effect from "@effect/io/Effect";
|
|
2
|
+
import * as FileSystem from "@effect/platform/FileSystem";
|
|
3
|
+
import * as Etag from "@effect/platform/Http/Etag";
|
|
4
|
+
import * as ServerResponse from "@effect/platform/Http/ServerResponse";
|
|
5
|
+
/** @internal */
|
|
6
|
+
export const file = (path, options) => Effect.map(({
|
|
7
|
+
etag,
|
|
8
|
+
info
|
|
9
|
+
}) => {
|
|
10
|
+
const headers = {
|
|
11
|
+
...(options?.headers ?? {}),
|
|
12
|
+
etag: Etag.toString(etag)
|
|
13
|
+
};
|
|
14
|
+
if (info.mtime._tag === "Some") {
|
|
15
|
+
headers["last-modified"] = info.mtime.value.toUTCString();
|
|
16
|
+
}
|
|
17
|
+
let file = Bun.file(path);
|
|
18
|
+
if (options?.bytesToRead !== undefined || options?.offset !== undefined) {
|
|
19
|
+
const start = Number(options?.offset ?? 0);
|
|
20
|
+
const end = options?.bytesToRead !== undefined ? start + Number(options.bytesToRead) : undefined;
|
|
21
|
+
file = file.slice(start, end);
|
|
22
|
+
}
|
|
23
|
+
return ServerResponse.raw(file, {
|
|
24
|
+
...options,
|
|
25
|
+
headers
|
|
26
|
+
});
|
|
27
|
+
})(Effect.bind("etag", ({
|
|
28
|
+
info
|
|
29
|
+
}) => Effect.flatMap(Etag.Generator, generator => generator.fromFileInfo(info)))(Effect.bindTo(Effect.flatMap(FileSystem.FileSystem, fs => fs.stat(path)), "info")));
|
|
30
|
+
/** @internal */
|
|
31
|
+
export const fileWeb = (file, options) => Effect.flatMap(Etag.Generator, generator => Effect.map(generator.fromFileWeb(file), etag => {
|
|
32
|
+
const headers = {
|
|
33
|
+
...(options?.headers ?? {}),
|
|
34
|
+
etag: Etag.toString(etag),
|
|
35
|
+
"last-modified": new Date(file.lastModified).toUTCString()
|
|
36
|
+
};
|
|
37
|
+
return ServerResponse.raw(file, {
|
|
38
|
+
...options,
|
|
39
|
+
headers
|
|
40
|
+
});
|
|
41
|
+
}));
|
|
42
|
+
//# sourceMappingURL=serverResponse.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serverResponse.mjs","names":["Effect","FileSystem","Etag","ServerResponse","file","path","options","map","etag","info","headers","toString","mtime","_tag","value","toUTCString","Bun","bytesToRead","undefined","offset","start","Number","end","slice","raw","bind","flatMap","Generator","generator","fromFileInfo","bindTo","fs","stat","fileWeb","fromFileWeb","Date","lastModified"],"sources":["../../../src/internal/http/serverResponse.ts"],"sourcesContent":[null],"mappings":"AACA,OAAO,KAAKA,MAAM,MAAM,mBAAmB;AAE3C,OAAO,KAAKC,UAAU,MAAM,6BAA6B;AAEzD,OAAO,KAAKC,IAAI,MAAM,4BAA4B;AAClD,OAAO,KAAKC,cAAc,MAAM,sCAAsC;AAEtE;AACA,OAAO,MAAMC,IAAI,GAAGA,CAClBC,IAAY,EACZC,OAA2E,KASzEN,MAAM,CAACO,GAAG,CAAC,CAAC;EAAEC,IAAI;EAAEC;AAAI,CAAE,KAAI;EAC5B,MAAMC,OAAO,GAA2B;IACtC,IAAIJ,OAAO,EAAEI,OAAO,IAAI,EAAE,CAAC;IAC3BF,IAAI,EAAEN,IAAI,CAACS,QAAQ,CAACH,IAAI;GACzB;EAC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,CAACqB,SAAS,CAACM,WAAW,CAAC9B,IAAI,CAAC,EAAGI,IAAI,IAAI;EAC/C,MAAME,OAAO,GAA2B;IACtC,IAAIJ,OAAO,EAAEI,OAAO,IAAI,EAAE,CAAC;IAC3BF,IAAI,EAAEN,IAAI,CAACS,QAAQ,CAACH,IAAI,CAAC;IACzB,eAAe,EAAE,IAAI2B,IAAI,CAAC/B,IAAI,CAACgC,YAAY,CAAC,CAACrB,WAAW;GACzD;EACD,OAAOZ,cAAc,CAACqB,GAAG,CAACpB,IAAI,EAAE;IAAE,GAAGE,OAAO;IAAEI;EAAO,CAAE,CAAC;AAC1D,CAAC,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@effect/platform-bun",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Unified interfaces for common platform-specific services",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/effect-ts/platform.git"
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
"./*": {
|
|
15
|
+
"import": {
|
|
16
|
+
"types": "./*.d.ts",
|
|
17
|
+
"default": "./mjs/*.mjs"
|
|
18
|
+
},
|
|
19
|
+
"require": {
|
|
20
|
+
"types": "./*.d.ts",
|
|
21
|
+
"default": "./*.js"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"sideEffects": [],
|
|
26
|
+
"author": "Effect contributors",
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@effect/data": "^0.17.5",
|
|
29
|
+
"@effect/io": "^0.38.2",
|
|
30
|
+
"@effect/stream": "^0.34.0",
|
|
31
|
+
"@effect/platform-node": "^0.13.17"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since 1.0.0
|
|
3
|
+
*/
|
|
4
|
+
import { pipe } from "@effect/data/Function"
|
|
5
|
+
import * as Layer from "@effect/io/Layer"
|
|
6
|
+
import * as CommandExecutor from "@effect/platform-bun/CommandExecutor"
|
|
7
|
+
import * as FileSystem from "@effect/platform-bun/FileSystem"
|
|
8
|
+
import * as Path from "@effect/platform-bun/Path"
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @since 1.0.0
|
|
12
|
+
* @category models
|
|
13
|
+
*/
|
|
14
|
+
export type BunContext = CommandExecutor.CommandExecutor | FileSystem.FileSystem | Path.Path
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @since 1.0.0
|
|
18
|
+
* @category layer
|
|
19
|
+
*/
|
|
20
|
+
export const layer: Layer.Layer<never, never, BunContext> = pipe(
|
|
21
|
+
FileSystem.layer,
|
|
22
|
+
Layer.merge(Path.layer),
|
|
23
|
+
Layer.merge(Layer.provideMerge(FileSystem.layer, CommandExecutor.layer))
|
|
24
|
+
)
|
package/src/Command.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since 1.0.0
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export type {
|
|
6
|
+
/**
|
|
7
|
+
* @since 1.0.0
|
|
8
|
+
* @category model
|
|
9
|
+
*/
|
|
10
|
+
Command,
|
|
11
|
+
/**
|
|
12
|
+
* @since 1.0.0
|
|
13
|
+
* @category model
|
|
14
|
+
*/
|
|
15
|
+
CommandInput,
|
|
16
|
+
/**
|
|
17
|
+
* @since 1.0.0
|
|
18
|
+
* @category model
|
|
19
|
+
*/
|
|
20
|
+
CommandOutput,
|
|
21
|
+
/**
|
|
22
|
+
* @since 1.0.0
|
|
23
|
+
* @category model
|
|
24
|
+
*/
|
|
25
|
+
PipedCommand,
|
|
26
|
+
/**
|
|
27
|
+
* @since 1.0.0
|
|
28
|
+
* @category model
|
|
29
|
+
*/
|
|
30
|
+
StandardCommand
|
|
31
|
+
} from "@effect/platform/Command"
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
/**
|
|
35
|
+
* @since 1.0.0
|
|
36
|
+
* @category combinators
|
|
37
|
+
*/
|
|
38
|
+
env,
|
|
39
|
+
/**
|
|
40
|
+
* @since 1.0.0
|
|
41
|
+
* @category execution
|
|
42
|
+
*/
|
|
43
|
+
exitCode,
|
|
44
|
+
/**
|
|
45
|
+
* @since 1.0.0
|
|
46
|
+
* @category combinators
|
|
47
|
+
*/
|
|
48
|
+
feed,
|
|
49
|
+
/**
|
|
50
|
+
* @since 1.0.0
|
|
51
|
+
* @category combinators
|
|
52
|
+
*/
|
|
53
|
+
flatten,
|
|
54
|
+
/**
|
|
55
|
+
* @since 1.0.0
|
|
56
|
+
* @category refinements
|
|
57
|
+
*/
|
|
58
|
+
isCommand,
|
|
59
|
+
/**
|
|
60
|
+
* @since 1.0.0
|
|
61
|
+
* @category execution
|
|
62
|
+
*/
|
|
63
|
+
lines,
|
|
64
|
+
/**
|
|
65
|
+
* @since 1.0.0
|
|
66
|
+
* @category constructors
|
|
67
|
+
*/
|
|
68
|
+
make,
|
|
69
|
+
/**
|
|
70
|
+
* @since 1.0.0
|
|
71
|
+
* @category combinators
|
|
72
|
+
*/
|
|
73
|
+
pipeTo,
|
|
74
|
+
/**
|
|
75
|
+
* @since 1.0.0
|
|
76
|
+
* @category execution
|
|
77
|
+
*/
|
|
78
|
+
start,
|
|
79
|
+
/**
|
|
80
|
+
* @since 1.0.0
|
|
81
|
+
* @category combinators
|
|
82
|
+
*/
|
|
83
|
+
stderr,
|
|
84
|
+
/**
|
|
85
|
+
* @since 1.0.0
|
|
86
|
+
* @category combinators
|
|
87
|
+
*/
|
|
88
|
+
stdin,
|
|
89
|
+
/**
|
|
90
|
+
* @since 1.0.0
|
|
91
|
+
* @category combinators
|
|
92
|
+
*/
|
|
93
|
+
stdout,
|
|
94
|
+
/**
|
|
95
|
+
* @since 1.0.0
|
|
96
|
+
* @category execution
|
|
97
|
+
*/
|
|
98
|
+
stream,
|
|
99
|
+
/**
|
|
100
|
+
* @since 1.0.0
|
|
101
|
+
* @category execution
|
|
102
|
+
*/
|
|
103
|
+
streamLines,
|
|
104
|
+
/**
|
|
105
|
+
* @since 1.0.0
|
|
106
|
+
* @category execution
|
|
107
|
+
*/
|
|
108
|
+
string,
|
|
109
|
+
/**
|
|
110
|
+
* @since 1.0.0
|
|
111
|
+
* @category combinators
|
|
112
|
+
*/
|
|
113
|
+
workingDirectory
|
|
114
|
+
} from "@effect/platform/Command"
|