@effect/platform-deno 4.0.0-beta.104
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/LICENSE +21 -0
- package/README.md +13 -0
- package/dist/DenoChildProcessSpawner.d.ts +39 -0
- package/dist/DenoChildProcessSpawner.d.ts.map +1 -0
- package/dist/DenoChildProcessSpawner.js +311 -0
- package/dist/DenoChildProcessSpawner.js.map +1 -0
- package/dist/DenoClusterHttp.d.ts +60 -0
- package/dist/DenoClusterHttp.d.ts.map +1 -0
- package/dist/DenoClusterHttp.js +78 -0
- package/dist/DenoClusterHttp.js.map +1 -0
- package/dist/DenoClusterSocket.d.ts +65 -0
- package/dist/DenoClusterSocket.d.ts.map +1 -0
- package/dist/DenoClusterSocket.js +101 -0
- package/dist/DenoClusterSocket.js.map +1 -0
- package/dist/DenoCrypto.d.ts +25 -0
- package/dist/DenoCrypto.d.ts.map +1 -0
- package/dist/DenoCrypto.js +52 -0
- package/dist/DenoCrypto.js.map +1 -0
- package/dist/DenoFileSystem.d.ts +10 -0
- package/dist/DenoFileSystem.d.ts.map +1 -0
- package/dist/DenoFileSystem.js +331 -0
- package/dist/DenoFileSystem.js.map +1 -0
- package/dist/DenoHttpClient.d.ts +9 -0
- package/dist/DenoHttpClient.d.ts.map +1 -0
- package/dist/DenoHttpClient.js +9 -0
- package/dist/DenoHttpClient.js.map +1 -0
- package/dist/DenoHttpPlatform.d.ts +34 -0
- package/dist/DenoHttpPlatform.d.ts.map +1 -0
- package/dist/DenoHttpPlatform.js +88 -0
- package/dist/DenoHttpPlatform.js.map +1 -0
- package/dist/DenoHttpServer.d.ts +99 -0
- package/dist/DenoHttpServer.d.ts.map +1 -0
- package/dist/DenoHttpServer.js +353 -0
- package/dist/DenoHttpServer.js.map +1 -0
- package/dist/DenoHttpServerRequest.d.ts +18 -0
- package/dist/DenoHttpServerRequest.d.ts.map +1 -0
- package/dist/DenoHttpServerRequest.js +8 -0
- package/dist/DenoHttpServerRequest.js.map +1 -0
- package/dist/DenoKeyValueStore.d.ts +22 -0
- package/dist/DenoKeyValueStore.d.ts.map +1 -0
- package/dist/DenoKeyValueStore.js +21 -0
- package/dist/DenoKeyValueStore.js.map +1 -0
- package/dist/DenoMultipart.d.ts +32 -0
- package/dist/DenoMultipart.d.ts.map +1 -0
- package/dist/DenoMultipart.js +25 -0
- package/dist/DenoMultipart.js.map +1 -0
- package/dist/DenoPath.d.ts +43 -0
- package/dist/DenoPath.d.ts.map +1 -0
- package/dist/DenoPath.js +81 -0
- package/dist/DenoPath.js.map +1 -0
- package/dist/DenoRedis.d.ts +60 -0
- package/dist/DenoRedis.d.ts.map +1 -0
- package/dist/DenoRedis.js +76 -0
- package/dist/DenoRedis.js.map +1 -0
- package/dist/DenoRuntime.d.ts +36 -0
- package/dist/DenoRuntime.d.ts.map +1 -0
- package/dist/DenoRuntime.js +35 -0
- package/dist/DenoRuntime.js.map +1 -0
- package/dist/DenoServices.d.ts +34 -0
- package/dist/DenoServices.d.ts.map +1 -0
- package/dist/DenoServices.js +16 -0
- package/dist/DenoServices.js.map +1 -0
- package/dist/DenoSocket.d.ts +99 -0
- package/dist/DenoSocket.d.ts.map +1 -0
- package/dist/DenoSocket.js +192 -0
- package/dist/DenoSocket.js.map +1 -0
- package/dist/DenoSocketServer.d.ts +70 -0
- package/dist/DenoSocketServer.d.ts.map +1 -0
- package/dist/DenoSocketServer.js +68 -0
- package/dist/DenoSocketServer.js.map +1 -0
- package/dist/DenoStdio.d.ts +11 -0
- package/dist/DenoStdio.d.ts.map +1 -0
- package/dist/DenoStdio.js +39 -0
- package/dist/DenoStdio.js.map +1 -0
- package/dist/DenoTerminal.d.ts +21 -0
- package/dist/DenoTerminal.d.ts.map +1 -0
- package/dist/DenoTerminal.js +27 -0
- package/dist/DenoTerminal.js.map +1 -0
- package/dist/DenoWorker.d.ts +17 -0
- package/dist/DenoWorker.d.ts.map +1 -0
- package/dist/DenoWorker.js +54 -0
- package/dist/DenoWorker.js.map +1 -0
- package/dist/DenoWorkerRunner.d.ts +24 -0
- package/dist/DenoWorkerRunner.d.ts.map +1 -0
- package/dist/DenoWorkerRunner.js +150 -0
- package/dist/DenoWorkerRunner.js.map +1 -0
- package/dist/index.d.ts +88 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +89 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/denoSocketServer.d.ts +7 -0
- package/dist/internal/denoSocketServer.d.ts.map +1 -0
- package/dist/internal/denoSocketServer.js +55 -0
- package/dist/internal/denoSocketServer.js.map +1 -0
- package/dist/internal/error.d.ts +4 -0
- package/dist/internal/error.d.ts.map +1 -0
- package/dist/internal/error.js +46 -0
- package/dist/internal/error.js.map +1 -0
- package/package.json +72 -0
- package/src/DenoChildProcessSpawner.ts +439 -0
- package/src/DenoClusterHttp.ts +156 -0
- package/src/DenoClusterSocket.ts +197 -0
- package/src/DenoCrypto.ts +63 -0
- package/src/DenoFileSystem.ts +497 -0
- package/src/DenoHttpClient.ts +9 -0
- package/src/DenoHttpPlatform.ts +93 -0
- package/src/DenoHttpServer.ts +535 -0
- package/src/DenoHttpServerRequest.ts +18 -0
- package/src/DenoKeyValueStore.ts +28 -0
- package/src/DenoMultipart.ts +53 -0
- package/src/DenoPath.ts +102 -0
- package/src/DenoRedis.ts +113 -0
- package/src/DenoRuntime.ts +73 -0
- package/src/DenoServices.ts +49 -0
- package/src/DenoSocket.ts +318 -0
- package/src/DenoSocketServer.ts +120 -0
- package/src/DenoStdio.ts +51 -0
- package/src/DenoTerminal.ts +32 -0
- package/src/DenoWorker.ts +75 -0
- package/src/DenoWorkerRunner.ts +175 -0
- package/src/index.ts +110 -0
- package/src/internal/denoSocketServer.ts +89 -0
- package/src/internal/error.ts +63 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deno implementation of the Effect HTTP platform service.
|
|
3
|
+
*
|
|
4
|
+
* File responses use `Deno.FsFile.readable` directly so full-file responses
|
|
5
|
+
* retain Deno's resource-backed fast path. Deno closes the file after the body
|
|
6
|
+
* is sent, but server adapters must cancel a raw body when they do not send it,
|
|
7
|
+
* including when handling `HEAD` requests.
|
|
8
|
+
*
|
|
9
|
+
* The provided layer uses strong ETags, unlike the portable `HttpPlatform`
|
|
10
|
+
* layer, which uses weak ETags.
|
|
11
|
+
*
|
|
12
|
+
* @since 4.0.0
|
|
13
|
+
*/
|
|
14
|
+
import * as NodeHttpCompression from "@effect/platform-node-shared/NodeHttpCompression";
|
|
15
|
+
import { contentType } from "@std/media-types";
|
|
16
|
+
import { extname } from "@std/path";
|
|
17
|
+
import { ByteSliceStream } from "@std/streams";
|
|
18
|
+
import * as Layer from "effect/Layer";
|
|
19
|
+
import * as Etag from "effect/unstable/http/Etag";
|
|
20
|
+
import * as Platform from "effect/unstable/http/HttpPlatform";
|
|
21
|
+
import * as Response from "effect/unstable/http/HttpServerResponse";
|
|
22
|
+
import * as DenoFileSystem from "./DenoFileSystem.js";
|
|
23
|
+
// gzip and deflate use the native CompressionStream, which does not expose a
|
|
24
|
+
// per-chunk flush control. br and zstd go through node:zlib compatibility
|
|
25
|
+
// streams and flush each input chunk.
|
|
26
|
+
const compression = NodeHttpCompression.make(Platform.makeCompressionWeb({
|
|
27
|
+
algorithms: NodeHttpCompression.algorithms,
|
|
28
|
+
transform: (algorithm, options) => algorithm === "gzip" || algorithm === "deflate"
|
|
29
|
+
? Platform.compressionTransformWeb(algorithm)
|
|
30
|
+
: NodeHttpCompression.compressTransformWeb(algorithm, options)
|
|
31
|
+
}));
|
|
32
|
+
/**
|
|
33
|
+
* Creates the Deno `HttpPlatform`, serving file responses from resource-backed
|
|
34
|
+
* readable streams and adding content type and content length headers.
|
|
35
|
+
*
|
|
36
|
+
* @category constructors
|
|
37
|
+
* @since 4.0.0
|
|
38
|
+
*/
|
|
39
|
+
export const make = Platform.make({
|
|
40
|
+
platform: "deno",
|
|
41
|
+
compression,
|
|
42
|
+
fileResponse(path, status, statusText, headers, start, end, contentLength) {
|
|
43
|
+
let body;
|
|
44
|
+
if (contentLength === 0) {
|
|
45
|
+
body = new ReadableStream({
|
|
46
|
+
start(controller) {
|
|
47
|
+
controller.close();
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
const file = Deno.openSync(path);
|
|
53
|
+
file.seekSync(start, Deno.SeekMode.Start);
|
|
54
|
+
body = end === undefined
|
|
55
|
+
? file.readable
|
|
56
|
+
: file.readable.pipeThrough(new ByteSliceStream(0, contentLength - 1));
|
|
57
|
+
}
|
|
58
|
+
return Response.raw(body, {
|
|
59
|
+
headers: {
|
|
60
|
+
...headers,
|
|
61
|
+
"content-type": headers["content-type"] ?? contentType(extname(path)) ?? "application/octet-stream",
|
|
62
|
+
"content-length": contentLength.toString()
|
|
63
|
+
},
|
|
64
|
+
status,
|
|
65
|
+
statusText
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
fileWebResponse(file, status, statusText, headers, _options) {
|
|
69
|
+
return Response.raw(file, {
|
|
70
|
+
headers: {
|
|
71
|
+
...headers,
|
|
72
|
+
"content-type": file.type,
|
|
73
|
+
"content-length": file.size.toString()
|
|
74
|
+
},
|
|
75
|
+
status,
|
|
76
|
+
statusText
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
/**
|
|
81
|
+
* Provides the Deno `HttpPlatform` together with its filesystem and strong ETag
|
|
82
|
+
* services.
|
|
83
|
+
*
|
|
84
|
+
* @category layers
|
|
85
|
+
* @since 4.0.0
|
|
86
|
+
*/
|
|
87
|
+
export const layer = Layer.effect(Platform.HttpPlatform)(make).pipe(Layer.provide(DenoFileSystem.layer), Layer.provide(Etag.layer));
|
|
88
|
+
//# sourceMappingURL=DenoHttpPlatform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DenoHttpPlatform.js","sourceRoot":"","sources":["../src/DenoHttpPlatform.ts"],"names":[],"mappings":"AAAA;;;;;;;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AAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAC1B,CAAA"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native Deno implementation of the Effect `HttpServer`.
|
|
3
|
+
*
|
|
4
|
+
* @since 4.0.0
|
|
5
|
+
*/
|
|
6
|
+
import * as Config from "effect/Config";
|
|
7
|
+
import type { ConfigError } from "effect/Config";
|
|
8
|
+
import * as Duration from "effect/Duration";
|
|
9
|
+
import * as Effect from "effect/Effect";
|
|
10
|
+
import type * as FileSystem from "effect/FileSystem";
|
|
11
|
+
import * as Layer from "effect/Layer";
|
|
12
|
+
import type * as Path from "effect/Path";
|
|
13
|
+
import * as Scope from "effect/Scope";
|
|
14
|
+
import * as Etag from "effect/unstable/http/Etag";
|
|
15
|
+
import type { HttpClient } from "effect/unstable/http/HttpClient";
|
|
16
|
+
import type { HttpPlatform } from "effect/unstable/http/HttpPlatform";
|
|
17
|
+
import * as Server from "effect/unstable/http/HttpServer";
|
|
18
|
+
import * as ServerRequest from "effect/unstable/http/HttpServerRequest";
|
|
19
|
+
import type * as ServerResponse from "effect/unstable/http/HttpServerResponse";
|
|
20
|
+
import * as DenoServices from "./DenoServices.ts";
|
|
21
|
+
/**
|
|
22
|
+
* Native Deno TCP, TLS, or Unix serve options managed by the scoped server.
|
|
23
|
+
*
|
|
24
|
+
* **Details**
|
|
25
|
+
*
|
|
26
|
+
* `signal` and `onError` are omitted because the scope and Effect HTTP handler
|
|
27
|
+
* own server and failure lifecycles. Server constructors additionally accept
|
|
28
|
+
* WebSocket settings that apply to every upgrade; `protocol` therefore cannot
|
|
29
|
+
* vary per request.
|
|
30
|
+
*
|
|
31
|
+
* @category options
|
|
32
|
+
* @since 4.0.0
|
|
33
|
+
*/
|
|
34
|
+
export type ServeOptions = (Omit<Deno.ServeTcpOptions, "signal" | "onError"> & Partial<Deno.TlsCertifiedKeyPem>) | Omit<Deno.ServeUnixOptions, "signal" | "onError">;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a scoped native Deno HTTP server.
|
|
37
|
+
*
|
|
38
|
+
* @category constructors
|
|
39
|
+
* @since 4.0.0
|
|
40
|
+
*/
|
|
41
|
+
export declare const make: (options: ServeOptions & {
|
|
42
|
+
readonly disablePreemptiveShutdown?: boolean | undefined;
|
|
43
|
+
readonly gracefulShutdownTimeout?: Duration.Input | undefined;
|
|
44
|
+
readonly websocket?: Deno.UpgradeWebSocketOptions | undefined;
|
|
45
|
+
}) => Effect.Effect<{
|
|
46
|
+
readonly serve: {
|
|
47
|
+
<E, R>(effect: Effect.Effect<ServerResponse.HttpServerResponse, E, R>): Effect.Effect<void, never, Exclude<R, ServerRequest.HttpServerRequest> | Scope.Scope>;
|
|
48
|
+
<E, R, App extends Effect.Effect<ServerResponse.HttpServerResponse, any, any>>(effect: Effect.Effect<ServerResponse.HttpServerResponse, E, R>, middleware: import("effect/unstable/http/HttpMiddleware").HttpMiddleware.Applied<App, E, R>): Effect.Effect<void, never, Exclude<R, ServerRequest.HttpServerRequest> | Scope.Scope>;
|
|
49
|
+
};
|
|
50
|
+
readonly address: Server.Address;
|
|
51
|
+
}, never, Scope.Scope>;
|
|
52
|
+
/**
|
|
53
|
+
* Provides only the native Deno HTTP server.
|
|
54
|
+
*
|
|
55
|
+
* @category layers
|
|
56
|
+
* @since 4.0.0
|
|
57
|
+
*/
|
|
58
|
+
export declare const layerServer: (options: ServeOptions & {
|
|
59
|
+
readonly disablePreemptiveShutdown?: boolean | undefined;
|
|
60
|
+
readonly gracefulShutdownTimeout?: Duration.Input | undefined;
|
|
61
|
+
readonly websocket?: Deno.UpgradeWebSocketOptions | undefined;
|
|
62
|
+
}) => Layer.Layer<Server.HttpServer>;
|
|
63
|
+
/**
|
|
64
|
+
* Provides Deno HTTP platform services and the standard Deno service set.
|
|
65
|
+
*
|
|
66
|
+
* @category layers
|
|
67
|
+
* @since 4.0.0
|
|
68
|
+
*/
|
|
69
|
+
export declare const layerHttpServices: Layer.Layer<HttpPlatform | Etag.Generator | DenoServices.DenoServices>;
|
|
70
|
+
/**
|
|
71
|
+
* Provides a native Deno HTTP server together with Deno HTTP services.
|
|
72
|
+
*
|
|
73
|
+
* @category layers
|
|
74
|
+
* @since 4.0.0
|
|
75
|
+
*/
|
|
76
|
+
export declare const layer: (options: ServeOptions & {
|
|
77
|
+
readonly disablePreemptiveShutdown?: boolean | undefined;
|
|
78
|
+
readonly gracefulShutdownTimeout?: Duration.Input | undefined;
|
|
79
|
+
readonly websocket?: Deno.UpgradeWebSocketOptions | undefined;
|
|
80
|
+
}) => Layer.Layer<Server.HttpServer | HttpPlatform | Etag.Generator | DenoServices.DenoServices>;
|
|
81
|
+
/**
|
|
82
|
+
* Starts a Deno HTTP server on an ephemeral loopback port for tests.
|
|
83
|
+
*
|
|
84
|
+
* @category testing
|
|
85
|
+
* @since 4.0.0
|
|
86
|
+
*/
|
|
87
|
+
export declare const layerTest: Layer.Layer<Server.HttpServer | HttpPlatform | FileSystem.FileSystem | Etag.Generator | Path.Path | HttpClient>;
|
|
88
|
+
/**
|
|
89
|
+
* Creates the Deno HTTP server and support-services layer from configurable options.
|
|
90
|
+
*
|
|
91
|
+
* @category layers
|
|
92
|
+
* @since 4.0.0
|
|
93
|
+
*/
|
|
94
|
+
export declare const layerConfig: (options: Config.Wrap<ServeOptions & {
|
|
95
|
+
readonly disablePreemptiveShutdown?: boolean | undefined;
|
|
96
|
+
readonly gracefulShutdownTimeout?: Duration.Input | undefined;
|
|
97
|
+
readonly websocket?: Deno.UpgradeWebSocketOptions | undefined;
|
|
98
|
+
}>) => Layer.Layer<Server.HttpServer | HttpPlatform | FileSystem.FileSystem | Etag.Generator | Path.Path, ConfigError>;
|
|
99
|
+
//# sourceMappingURL=DenoHttpServer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DenoHttpServer.d.ts","sourceRoot":"","sources":["../src/DenoHttpServer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KA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S,CAAC,EAAE,IAAI,CAAC,uBAAuB,GAAG,SAAS,CAAA;CAC9D,CACF,KACA,KAAK,CAAC,KAAK,CACZ,MAAM,CAAC,UAAU,GAAG,YAAY,GAAG,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,IAAI,EACrF,WAAW,CAKV,CAAA"}
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native Deno implementation of the Effect `HttpServer`.
|
|
3
|
+
*
|
|
4
|
+
* @since 4.0.0
|
|
5
|
+
*/
|
|
6
|
+
import * as Config from "effect/Config";
|
|
7
|
+
import * as Context from "effect/Context";
|
|
8
|
+
import * as Duration from "effect/Duration";
|
|
9
|
+
import * as Effect from "effect/Effect";
|
|
10
|
+
import * as Fiber from "effect/Fiber";
|
|
11
|
+
import { flow } from "effect/Function";
|
|
12
|
+
import * as Inspectable from "effect/Inspectable";
|
|
13
|
+
import * as Layer from "effect/Layer";
|
|
14
|
+
import * as Option from "effect/Option";
|
|
15
|
+
import * as Scope from "effect/Scope";
|
|
16
|
+
import * as Stream from "effect/Stream";
|
|
17
|
+
import * as Cookies from "effect/unstable/http/Cookies";
|
|
18
|
+
import * as Etag from "effect/unstable/http/Etag";
|
|
19
|
+
import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient";
|
|
20
|
+
import * as Headers from "effect/unstable/http/Headers";
|
|
21
|
+
import * as HttpEffect from "effect/unstable/http/HttpEffect";
|
|
22
|
+
import * as IncomingMessage from "effect/unstable/http/HttpIncomingMessage";
|
|
23
|
+
import * as Server from "effect/unstable/http/HttpServer";
|
|
24
|
+
import * as Error from "effect/unstable/http/HttpServerError";
|
|
25
|
+
import * as ServerRequest from "effect/unstable/http/HttpServerRequest";
|
|
26
|
+
import * as UrlParams from "effect/unstable/http/UrlParams";
|
|
27
|
+
import * as Socket from "effect/unstable/socket/Socket";
|
|
28
|
+
import * as Platform from "./DenoHttpPlatform.js";
|
|
29
|
+
import * as DenoMultipart from "./DenoMultipart.js";
|
|
30
|
+
import * as DenoServices from "./DenoServices.js";
|
|
31
|
+
/**
|
|
32
|
+
* Creates a scoped native Deno HTTP server.
|
|
33
|
+
*
|
|
34
|
+
* @category constructors
|
|
35
|
+
* @since 4.0.0
|
|
36
|
+
*/
|
|
37
|
+
export const make = Effect.fnUntraced(function* (options) {
|
|
38
|
+
const scope = yield* Effect.scope;
|
|
39
|
+
const notFound = (_request, _info) => Promise.resolve(new Response("not found", { status: 404 }));
|
|
40
|
+
const handlerStack = [notFound];
|
|
41
|
+
let currentHandler = notFound;
|
|
42
|
+
const { disablePreemptiveShutdown, gracefulShutdownTimeout, websocket, ...serveOptions } = options;
|
|
43
|
+
const server = Deno.serve(serveOptions, (request, info) => currentHandler(request, info));
|
|
44
|
+
const shutdown = yield* Effect.promise(() => server.shutdown()).pipe(Effect.cached);
|
|
45
|
+
const preemptiveShutdown = disablePreemptiveShutdown ? Effect.void : Effect.timeoutOrElse(shutdown, {
|
|
46
|
+
duration: gracefulShutdownTimeout ?? Duration.seconds(20),
|
|
47
|
+
orElse: () => Effect.void
|
|
48
|
+
});
|
|
49
|
+
yield* Scope.addFinalizer(scope, shutdown);
|
|
50
|
+
const serverAddress = server.addr;
|
|
51
|
+
const address = serverAddress.transport === "unix"
|
|
52
|
+
? { _tag: "UnixAddress", path: serverAddress.path }
|
|
53
|
+
: {
|
|
54
|
+
_tag: "TcpAddress",
|
|
55
|
+
port: serverAddress.port,
|
|
56
|
+
hostname: serverAddress.hostname
|
|
57
|
+
};
|
|
58
|
+
return Server.make({
|
|
59
|
+
address,
|
|
60
|
+
serve: Effect.fnUntraced(function* (httpApp, middleware) {
|
|
61
|
+
const parent = yield* Effect.fiber;
|
|
62
|
+
const services = parent.context;
|
|
63
|
+
const serveScope = Context.getUnsafe(services, Scope.Scope);
|
|
64
|
+
const scope = Scope.forkUnsafe(serveScope, "parallel");
|
|
65
|
+
const httpEffect = HttpEffect.toHandled(httpApp, (request, response) => {
|
|
66
|
+
const denoRequest = request;
|
|
67
|
+
if (denoRequest.upgraded)
|
|
68
|
+
return cancelResponseBody(response.body);
|
|
69
|
+
return Effect.flatMap(makeResponse(request, response, services, scope), (response) => Effect.sync(() => denoRequest.resolve(response)));
|
|
70
|
+
}, middleware);
|
|
71
|
+
function handler(request, info) {
|
|
72
|
+
return new Promise((resolve) => {
|
|
73
|
+
const context = Context.add(services, ServerRequest.HttpServerRequest, new DenoServerRequest(request, info.remoteAddr, resolve, removeHost(request.url), websocket));
|
|
74
|
+
const fiber = Fiber.runIn(Effect.runForkWith(context)(httpEffect), scope);
|
|
75
|
+
request.signal.addEventListener("abort", () => {
|
|
76
|
+
fiber.interruptUnsafe(parent.id, Error.ClientAbort.annotation);
|
|
77
|
+
}, { once: true });
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
yield* Scope.addFinalizerExit(serveScope, () => {
|
|
81
|
+
const index = handlerStack.lastIndexOf(handler);
|
|
82
|
+
if (index !== -1)
|
|
83
|
+
handlerStack.splice(index, 1);
|
|
84
|
+
currentHandler = handlerStack[handlerStack.length - 1] ?? notFound;
|
|
85
|
+
return preemptiveShutdown;
|
|
86
|
+
});
|
|
87
|
+
handlerStack.push(handler);
|
|
88
|
+
currentHandler = handler;
|
|
89
|
+
})
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
const makeResponse = Effect.fnUntraced(function* (request, response, context, scope) {
|
|
93
|
+
const fields = {
|
|
94
|
+
headers: new globalThis.Headers(response.headers),
|
|
95
|
+
status: response.status
|
|
96
|
+
};
|
|
97
|
+
if (!Cookies.isEmpty(response.cookies)) {
|
|
98
|
+
for (const header of Cookies.toSetCookieHeaders(response.cookies)) {
|
|
99
|
+
fields.headers.append("set-cookie", header);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (response.statusText !== undefined)
|
|
103
|
+
fields.statusText = response.statusText;
|
|
104
|
+
if (request.method === "HEAD") {
|
|
105
|
+
yield* cancelResponseBody(response.body);
|
|
106
|
+
return new Response(undefined, fields);
|
|
107
|
+
}
|
|
108
|
+
response = HttpEffect.scopeTransferToStream(response);
|
|
109
|
+
const body = response.body;
|
|
110
|
+
switch (body._tag) {
|
|
111
|
+
case "Empty":
|
|
112
|
+
return new Response(undefined, fields);
|
|
113
|
+
case "Uint8Array":
|
|
114
|
+
case "Raw": {
|
|
115
|
+
if (body.body instanceof Response) {
|
|
116
|
+
for (const [key, value] of fields.headers.entries())
|
|
117
|
+
body.body.headers.set(key, value);
|
|
118
|
+
return body.body;
|
|
119
|
+
}
|
|
120
|
+
return new Response(body.body, fields);
|
|
121
|
+
}
|
|
122
|
+
case "FormData":
|
|
123
|
+
return new Response(body.formData, fields);
|
|
124
|
+
case "Stream":
|
|
125
|
+
return new Response(Stream.toReadableStreamWith(Stream.unwrap(Effect.withFiber((fiber) => {
|
|
126
|
+
Fiber.runIn(fiber, scope);
|
|
127
|
+
return Effect.succeed(body.stream);
|
|
128
|
+
})), context), fields);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
/**
|
|
132
|
+
* Provides only the native Deno HTTP server.
|
|
133
|
+
*
|
|
134
|
+
* @category layers
|
|
135
|
+
* @since 4.0.0
|
|
136
|
+
*/
|
|
137
|
+
export const layerServer = flow(make, Layer.effect(Server.HttpServer));
|
|
138
|
+
/**
|
|
139
|
+
* Provides Deno HTTP platform services and the standard Deno service set.
|
|
140
|
+
*
|
|
141
|
+
* @category layers
|
|
142
|
+
* @since 4.0.0
|
|
143
|
+
*/
|
|
144
|
+
export const layerHttpServices = Layer.mergeAll(Platform.layer, Etag.layerWeak, DenoServices.layer);
|
|
145
|
+
/**
|
|
146
|
+
* Provides a native Deno HTTP server together with Deno HTTP services.
|
|
147
|
+
*
|
|
148
|
+
* @category layers
|
|
149
|
+
* @since 4.0.0
|
|
150
|
+
*/
|
|
151
|
+
export const layer = (options) => Layer.mergeAll(layerServer(options), layerHttpServices);
|
|
152
|
+
/**
|
|
153
|
+
* Starts a Deno HTTP server on an ephemeral loopback port for tests.
|
|
154
|
+
*
|
|
155
|
+
* @category testing
|
|
156
|
+
* @since 4.0.0
|
|
157
|
+
*/
|
|
158
|
+
export const layerTest = Server.layerTestClient.pipe(Layer.provide(FetchHttpClient.layer.pipe(Layer.provide(Layer.succeed(FetchHttpClient.RequestInit)({ keepalive: false })))), Layer.provideMerge(layer({ hostname: "127.0.0.1", port: 0, onListen: () => { } })));
|
|
159
|
+
/**
|
|
160
|
+
* Creates the Deno HTTP server and support-services layer from configurable options.
|
|
161
|
+
*
|
|
162
|
+
* @category layers
|
|
163
|
+
* @since 4.0.0
|
|
164
|
+
*/
|
|
165
|
+
export const layerConfig = (options) => Layer.mergeAll(Layer.effect(Server.HttpServer)(Effect.flatMap(Config.unwrap(options), make)), layerHttpServices);
|
|
166
|
+
class DenoServerRequest extends Inspectable.Class {
|
|
167
|
+
[ServerRequest.TypeId];
|
|
168
|
+
[IncomingMessage.TypeId];
|
|
169
|
+
source;
|
|
170
|
+
remoteAddr;
|
|
171
|
+
url;
|
|
172
|
+
websocketOptions;
|
|
173
|
+
resolve;
|
|
174
|
+
upgraded = false;
|
|
175
|
+
headersOverride;
|
|
176
|
+
remoteAddressOverride;
|
|
177
|
+
constructor(source, remoteAddr, resolve, url, websocketOptions, headersOverride, remoteAddressOverride) {
|
|
178
|
+
super();
|
|
179
|
+
this[ServerRequest.TypeId] = ServerRequest.TypeId;
|
|
180
|
+
this[IncomingMessage.TypeId] = IncomingMessage.TypeId;
|
|
181
|
+
this.source = source;
|
|
182
|
+
this.remoteAddr = remoteAddr;
|
|
183
|
+
this.resolve = resolve;
|
|
184
|
+
this.url = url;
|
|
185
|
+
this.websocketOptions = websocketOptions;
|
|
186
|
+
this.headersOverride = headersOverride;
|
|
187
|
+
this.remoteAddressOverride = remoteAddressOverride;
|
|
188
|
+
}
|
|
189
|
+
toJSON() {
|
|
190
|
+
return IncomingMessage.inspect(this, {
|
|
191
|
+
_id: "HttpServerRequest",
|
|
192
|
+
method: this.method,
|
|
193
|
+
url: this.originalUrl
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
modify(options) {
|
|
197
|
+
return new DenoServerRequest(this.source, this.remoteAddr, this.resolve, options.url ?? this.url, this.websocketOptions, options.headers ?? this.headersOverride, "remoteAddress" in options ? options.remoteAddress : this.remoteAddressOverride);
|
|
198
|
+
}
|
|
199
|
+
get method() {
|
|
200
|
+
return this.source.method.toUpperCase();
|
|
201
|
+
}
|
|
202
|
+
get originalUrl() {
|
|
203
|
+
return this.source.url;
|
|
204
|
+
}
|
|
205
|
+
get remoteAddress() {
|
|
206
|
+
return this.remoteAddressOverride ?? (this.remoteAddr.transport === "tcp"
|
|
207
|
+
? Option.some(this.remoteAddr.hostname)
|
|
208
|
+
: Option.none());
|
|
209
|
+
}
|
|
210
|
+
get headers() {
|
|
211
|
+
this.headersOverride ??= Headers.fromInput(this.source.headers);
|
|
212
|
+
return this.headersOverride;
|
|
213
|
+
}
|
|
214
|
+
cachedCookies;
|
|
215
|
+
get cookies() {
|
|
216
|
+
return this.cachedCookies ??= Cookies.parseHeader(this.headers.cookie ?? "");
|
|
217
|
+
}
|
|
218
|
+
get stream() {
|
|
219
|
+
return this.source.body
|
|
220
|
+
? Stream.fromReadableStream({
|
|
221
|
+
evaluate: () => this.source.body ?? emptyReadableStream,
|
|
222
|
+
onError: (cause) => new Error.HttpServerError({
|
|
223
|
+
reason: new Error.RequestParseError({ request: this, cause })
|
|
224
|
+
})
|
|
225
|
+
})
|
|
226
|
+
: Stream.fail(new Error.HttpServerError({
|
|
227
|
+
reason: new Error.RequestParseError({
|
|
228
|
+
request: this,
|
|
229
|
+
description: "can not create stream from empty body"
|
|
230
|
+
})
|
|
231
|
+
}));
|
|
232
|
+
}
|
|
233
|
+
textEffect;
|
|
234
|
+
get text() {
|
|
235
|
+
return this.textEffect ??= Effect.runSync(Effect.cached(Effect.tryPromise({
|
|
236
|
+
try: () => this.source.text(),
|
|
237
|
+
catch: (cause) => new Error.HttpServerError({
|
|
238
|
+
reason: new Error.RequestParseError({ request: this, cause })
|
|
239
|
+
})
|
|
240
|
+
})));
|
|
241
|
+
}
|
|
242
|
+
get json() {
|
|
243
|
+
return Effect.flatMap(this.text, (_) => Effect.try({
|
|
244
|
+
try: () => JSON.parse(_),
|
|
245
|
+
catch: (cause) => new Error.HttpServerError({
|
|
246
|
+
reason: new Error.RequestParseError({ request: this, cause })
|
|
247
|
+
})
|
|
248
|
+
}));
|
|
249
|
+
}
|
|
250
|
+
get urlParamsBody() {
|
|
251
|
+
return Effect.flatMap(this.text, (_) => Effect.try({
|
|
252
|
+
try: () => UrlParams.fromInput(new URLSearchParams(_)),
|
|
253
|
+
catch: (cause) => new Error.HttpServerError({
|
|
254
|
+
reason: new Error.RequestParseError({ request: this, cause })
|
|
255
|
+
})
|
|
256
|
+
}));
|
|
257
|
+
}
|
|
258
|
+
multipartEffect;
|
|
259
|
+
get multipart() {
|
|
260
|
+
return this.multipartEffect ??= Effect.runSync(Effect.cached(DenoMultipart.persisted(this.source)));
|
|
261
|
+
}
|
|
262
|
+
get multipartStream() {
|
|
263
|
+
return DenoMultipart.stream(this.source);
|
|
264
|
+
}
|
|
265
|
+
arrayBufferEffect;
|
|
266
|
+
get arrayBuffer() {
|
|
267
|
+
if (this.arrayBufferEffect)
|
|
268
|
+
return this.arrayBufferEffect;
|
|
269
|
+
this.arrayBufferEffect = Effect.runSync(Effect.cached(Effect.tryPromise({
|
|
270
|
+
try: () => this.source.arrayBuffer(),
|
|
271
|
+
catch: (cause) => new Error.HttpServerError({
|
|
272
|
+
reason: new Error.RequestParseError({ request: this, cause })
|
|
273
|
+
})
|
|
274
|
+
})));
|
|
275
|
+
this.textEffect = Effect.map(this.arrayBufferEffect, (_) => new TextDecoder().decode(_));
|
|
276
|
+
return this.arrayBufferEffect;
|
|
277
|
+
}
|
|
278
|
+
get upgrade() {
|
|
279
|
+
return Effect.flatMap(Effect.try({
|
|
280
|
+
try: () => Deno.upgradeWebSocket(this.source, this.websocketOptions),
|
|
281
|
+
catch: (cause) => new Error.HttpServerError({
|
|
282
|
+
reason: new Error.RequestParseError({
|
|
283
|
+
request: this,
|
|
284
|
+
cause,
|
|
285
|
+
description: "Not an upgradeable ServerRequest"
|
|
286
|
+
})
|
|
287
|
+
})
|
|
288
|
+
}), (upgrade) => {
|
|
289
|
+
const buffered = [];
|
|
290
|
+
const buffer = (event) => buffered.push(event);
|
|
291
|
+
upgrade.socket.addEventListener("message", buffer);
|
|
292
|
+
this.upgraded = true;
|
|
293
|
+
this.resolve(upgrade.response);
|
|
294
|
+
return Effect.callback((resume) => {
|
|
295
|
+
const cleanup = () => {
|
|
296
|
+
upgrade.socket.removeEventListener("open", onOpen);
|
|
297
|
+
upgrade.socket.removeEventListener("error", onFailure);
|
|
298
|
+
upgrade.socket.removeEventListener("close", onFailure);
|
|
299
|
+
};
|
|
300
|
+
const onFailure = (cause) => {
|
|
301
|
+
cleanup();
|
|
302
|
+
upgrade.socket.removeEventListener("message", buffer);
|
|
303
|
+
buffered.length = 0;
|
|
304
|
+
resume(Effect.fail(new Error.HttpServerError({
|
|
305
|
+
reason: new Error.RequestParseError({
|
|
306
|
+
request: this,
|
|
307
|
+
cause,
|
|
308
|
+
description: "WebSocket upgrade failed before open"
|
|
309
|
+
})
|
|
310
|
+
})));
|
|
311
|
+
};
|
|
312
|
+
const onOpen = () => {
|
|
313
|
+
cleanup();
|
|
314
|
+
resume(Socket.fromWebSocket(Effect.acquireRelease(Effect.succeed(upgrade.socket), (socket) => Effect.sync(() => socket.close(1000))), {
|
|
315
|
+
onInitialRun: (socket) => {
|
|
316
|
+
socket.removeEventListener("message", buffer);
|
|
317
|
+
return buffered.splice(0);
|
|
318
|
+
}
|
|
319
|
+
}));
|
|
320
|
+
};
|
|
321
|
+
upgrade.socket.addEventListener("open", onOpen, { once: true });
|
|
322
|
+
upgrade.socket.addEventListener("error", onFailure, { once: true });
|
|
323
|
+
upgrade.socket.addEventListener("close", onFailure, { once: true });
|
|
324
|
+
return Effect.sync(() => {
|
|
325
|
+
cleanup();
|
|
326
|
+
upgrade.socket.removeEventListener("message", buffer);
|
|
327
|
+
buffered.length = 0;
|
|
328
|
+
upgrade.socket.close();
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
const cancelResponseBody = (body) => {
|
|
335
|
+
const stream = body.body;
|
|
336
|
+
if ((body._tag === "Raw" || body._tag === "Uint8Array") && stream instanceof ReadableStream) {
|
|
337
|
+
return Effect.ignoreCause(Effect.promise(() => stream.cancel()));
|
|
338
|
+
}
|
|
339
|
+
return Effect.void;
|
|
340
|
+
};
|
|
341
|
+
const emptyReadableStream = new ReadableStream({
|
|
342
|
+
start(controller) {
|
|
343
|
+
controller.enqueue(new Uint8Array());
|
|
344
|
+
controller.close();
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
const removeHost = (url) => {
|
|
348
|
+
if (url[0] === "/")
|
|
349
|
+
return url;
|
|
350
|
+
const index = url.indexOf("/", url.indexOf("//") + 2);
|
|
351
|
+
return index === -1 ? "/" : url.slice(index);
|
|
352
|
+
};
|
|
353
|
+
//# sourceMappingURL=DenoHttpServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DenoHttpServer.js","sourceRoot":"","sources":["../src/DenoHttpServer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACtC,OAAO,KAAK,WAAW,MAAM,oBAAoB,CAAA;AACjD,OAAO,KAAK,KAAK,MAAM,cAAc,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AC,CAAA;AAEF,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,EAAE;IACjC,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG;QAAE,OAAO,GAAG,CAAA;IAC9B,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;IACrD,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;AAC9C,CAAC,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Accessor for the web-standard request behind a Deno HTTP server request.
|
|
3
|
+
*
|
|
4
|
+
* Unlike Bun's accessor, this function has no route-pattern generic because
|
|
5
|
+
* `Deno.serve` always receives a standard `Request`. Connection information is
|
|
6
|
+
* intentionally kept internal to `DenoHttpServer`.
|
|
7
|
+
*
|
|
8
|
+
* @since 4.0.0
|
|
9
|
+
*/
|
|
10
|
+
import type { HttpServerRequest } from "effect/unstable/http/HttpServerRequest";
|
|
11
|
+
/**
|
|
12
|
+
* Returns the underlying web-standard `Request` from an Effect `HttpServerRequest`.
|
|
13
|
+
*
|
|
14
|
+
* @category accessors
|
|
15
|
+
* @since 4.0.0
|
|
16
|
+
*/
|
|
17
|
+
export declare const toDenoServerRequest: (self: HttpServerRequest) => Request;
|
|
18
|
+
//# sourceMappingURL=DenoHttpServerRequest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DenoHttpServerRequest.d.ts","sourceRoot":"","sources":["../src/DenoHttpServerRequest.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAA;AAE/E;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,SAAU,iBAAiB,KAAG,OAA+B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DenoHttpServerRequest.js","sourceRoot":"","sources":["../src/DenoHttpServerRequest.ts"],"names":[],"mappings":"AAWA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAuB,EAAW,EAAE,CAAE,IAAY,CAAC,MAAM,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deno-backed `KeyValueStore` layers using Web Storage APIs.
|
|
3
|
+
*
|
|
4
|
+
* @since 4.0.0
|
|
5
|
+
*/
|
|
6
|
+
import type * as Layer from "effect/Layer";
|
|
7
|
+
import * as KeyValueStore from "effect/unstable/persistence/KeyValueStore";
|
|
8
|
+
/**
|
|
9
|
+
* Creates a `KeyValueStore` layer backed by `localStorage`, with values stored between sessions.
|
|
10
|
+
*
|
|
11
|
+
* @category layers
|
|
12
|
+
* @since 4.0.0
|
|
13
|
+
*/
|
|
14
|
+
export declare const layerLocalStorage: Layer.Layer<KeyValueStore.KeyValueStore>;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a `KeyValueStore` layer backed by `sessionStorage`, with values stored only for the current session.
|
|
17
|
+
*
|
|
18
|
+
* @category layers
|
|
19
|
+
* @since 4.0.0
|
|
20
|
+
*/
|
|
21
|
+
export declare const layerSessionStorage: Layer.Layer<KeyValueStore.KeyValueStore>;
|
|
22
|
+
//# sourceMappingURL=DenoKeyValueStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DenoKeyValueStore.d.ts","sourceRoot":"","sources":["../src/DenoKeyValueStore.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,aAAa,MAAM,2CAA2C,CAAA;AAE1E;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,aAAa,CAEtE,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,aAAa,CAExE,CAAA"}
|