@effect/platform 0.18.4 → 0.18.6
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/Command/dist/effect-platform-Command.esm.js +12 -200
- package/CommandExecutor/dist/effect-platform-CommandExecutor.esm.js +9 -71
- package/Effectify/dist/effect-platform-Effectify.esm.js +2 -23
- package/Error/dist/effect-platform-Error.esm.js +2 -54
- package/FileSystem/dist/effect-platform-FileSystem.esm.js +10 -177
- package/Http/Body/dist/effect-platform-Http-Body.esm.js +13 -151
- package/Http/Client/dist/effect-platform-Http-Client.cjs.dev.js +2 -2
- package/Http/Client/dist/effect-platform-Http-Client.cjs.prod.js +2 -2
- package/Http/Client/dist/effect-platform-Http-Client.esm.js +28 -164
- package/Http/ClientError/dist/effect-platform-Http-ClientError.esm.js +3 -48
- package/Http/ClientRequest/dist/effect-platform-Http-ClientRequest.esm.js +20 -241
- package/Http/ClientResponse/dist/effect-platform-Http-ClientResponse.cjs.dev.js +3 -2
- package/Http/ClientResponse/dist/effect-platform-Http-ClientResponse.cjs.mjs +2 -1
- package/Http/ClientResponse/dist/effect-platform-Http-ClientResponse.cjs.prod.js +3 -2
- package/Http/ClientResponse/dist/effect-platform-Http-ClientResponse.esm.js +22 -35
- package/Http/Etag/dist/effect-platform-Http-Etag.esm.js +17 -1
- package/Http/FormData/dist/effect-platform-Http-FormData.esm.js +17 -155
- package/Http/Headers/dist/effect-platform-Http-Headers.esm.js +4 -74
- package/Http/IncomingMessage/dist/effect-platform-Http-IncomingMessage.esm.js +6 -1
- package/Http/Middleware/dist/effect-platform-Http-Middleware.cjs.dev.js +3 -3
- package/Http/Middleware/dist/effect-platform-Http-Middleware.cjs.prod.js +3 -3
- package/Http/Middleware/dist/effect-platform-Http-Middleware.esm.js +30 -52
- package/Http/Platform/dist/effect-platform-Http-Platform.esm.js +56 -1
- package/Http/Router/dist/effect-platform-Http-Router.esm.js +25 -224
- package/Http/Server/dist/effect-platform-Http-Server.esm.js +18 -1
- package/Http/ServerError/dist/effect-platform-Http-ServerError.esm.js +2 -70
- package/Http/ServerRequest/dist/effect-platform-Http-ServerRequest.esm.js +20 -65
- package/Http/ServerResponse/dist/effect-platform-Http-ServerResponse.cjs.dev.js +2 -2
- package/Http/ServerResponse/dist/effect-platform-Http-ServerResponse.cjs.prod.js +2 -2
- package/Http/ServerResponse/dist/effect-platform-Http-ServerResponse.esm.js +21 -126
- package/Http/UrlParams/dist/effect-platform-Http-UrlParams.esm.js +4 -101
- package/HttpClient/dist/effect-platform-HttpClient.cjs.dev.js +3 -3
- package/HttpClient/dist/effect-platform-HttpClient.cjs.prod.js +3 -3
- package/HttpClient/dist/effect-platform-HttpClient.esm.js +32 -18
- package/HttpServer/dist/effect-platform-HttpServer.cjs.dev.js +2 -3
- package/HttpServer/dist/effect-platform-HttpServer.cjs.prod.js +2 -3
- package/HttpServer/dist/effect-platform-HttpServer.esm.js +35 -24
- package/KeyValueStore/dist/effect-platform-KeyValueStore.esm.js +15 -78
- package/Path/dist/effect-platform-Path.esm.js +8 -33
- package/Runtime/dist/effect-platform-Runtime.esm.js +3 -26
- package/dist/App-687366d8.esm.js +5 -0
- package/dist/Body-ec1353f9.esm.js +170 -0
- package/dist/{Client-15671ed6.cjs.dev.js → Client-440a1019.cjs.dev.js} +1 -1
- package/dist/Client-4659bda7.esm.js +346 -0
- package/dist/{Client-6b3e3de8.cjs.prod.js → Client-7b851481.cjs.prod.js} +1 -1
- package/dist/ClientError-98b5da8c.esm.js +55 -0
- package/dist/ClientRequest-fc429335.esm.js +281 -0
- package/dist/{ClientResponse-a1d64ab8.cjs.dev.js → ClientResponse-1476704c.cjs.dev.js} +9 -1
- package/dist/ClientResponse-4524e99e.esm.js +53 -0
- package/dist/{ClientResponse-8f65511e.cjs.prod.js → ClientResponse-fe4e69c8.cjs.prod.js} +9 -1
- package/dist/Command-d8ab0c8d.esm.js +403 -0
- package/dist/CommandExecutor-5807b66b.esm.js +80 -0
- package/dist/Effectify-e5a9d266.esm.js +43 -0
- package/dist/Error-3099667c.esm.js +75 -0
- package/dist/FileSystem-7e31dccd.esm.js +271 -0
- package/dist/FormData-f54de878.esm.js +270 -0
- package/dist/Headers-58b56a08.esm.js +85 -0
- package/dist/{HttpClient-cefc7da9.cjs.dev.js → HttpClient-4d23b1f5.cjs.dev.js} +2 -2
- package/dist/{HttpClient-d3c69877.cjs.prod.js → HttpClient-88775b8e.cjs.prod.js} +2 -2
- package/dist/HttpClient-9ca6050c.esm.js +24 -0
- package/dist/{HttpServer-5b9d992e.cjs.dev.js → HttpServer-16159c3a.cjs.dev.js} +2 -2
- package/dist/HttpServer-50f8df76.esm.js +30 -0
- package/dist/{HttpServer-60325fb0.cjs.prod.js → HttpServer-93c0fbb3.cjs.prod.js} +2 -2
- package/{internal/keyValueStore.esm.js → dist/KeyValueStore-2f9a70bf.esm.js} +102 -15
- package/dist/Middleware-240f91f6.esm.js +105 -0
- package/dist/{Middleware-8e7cd600.cjs.dev.js → Middleware-e2edf820.cjs.dev.js} +1 -1
- package/dist/{Middleware-d4f1a1cd.cjs.prod.js → Middleware-f9a073d7.cjs.prod.js} +1 -1
- package/{internal/path.esm.js → dist/Path-46f84ba7.esm.js} +40 -4
- package/dist/Router-bf32317a.esm.js +454 -0
- package/dist/Runtime-7265fb98.esm.js +31 -0
- package/dist/ServerError-04ad5b57.esm.js +99 -0
- package/dist/ServerRequest-03161edc.esm.js +125 -0
- package/dist/ServerResponse-93038062.esm.js +259 -0
- package/dist/{ServerResponse-7d60c7d1.cjs.dev.js → ServerResponse-b63b7192.cjs.dev.js} +15 -4
- package/dist/{ServerResponse-830f1052.cjs.prod.js → ServerResponse-eae85b08.cjs.prod.js} +15 -4
- package/dist/UrlParams-1286c728.esm.js +114 -0
- package/{internal/http/body.esm.js → dist/body-20d78ec1.esm.js} +2 -2
- package/{internal/http/clientError.esm.js → dist/clientError-c4e1466c.esm.js} +1 -1
- package/{internal/http/clientRequest.esm.js → dist/clientRequest-1e9e0b0d.esm.js} +4 -4
- package/dist/{clientResponse-c58a116c.cjs.dev.js → clientResponse-79c84a64.cjs.dev.js} +10 -0
- package/{internal/http/clientResponse.esm.js → dist/clientResponse-8c2ec6a3.esm.js} +14 -5
- package/dist/{clientResponse-2c6a83f1.cjs.prod.js → clientResponse-f9c57e83.cjs.prod.js} +10 -0
- package/{internal/commandExecutor.esm.js → dist/commandExecutor-d6457489.esm.js} +1 -1
- package/dist/declarations/src/Http/ClientResponse.d.ts +8 -0
- package/dist/declarations/src/Http/ClientResponse.d.ts.map +1 -1
- package/dist/declarations/src/Http/ServerResponse.d.ts +1 -2
- package/dist/declarations/src/Http/ServerResponse.d.ts.map +1 -1
- package/dist/effect-platform.cjs.dev.js +8 -8
- package/dist/effect-platform.cjs.prod.js +8 -8
- package/dist/effect-platform.esm.js +58 -20
- package/package.json +1 -2
- package/src/Http/ClientResponse.ts +10 -0
- package/src/Http/ServerResponse.ts +1 -2
- package/src/internal/http/clientResponse.ts +16 -0
- package/src/internal/http/serverResponse.ts +18 -4
- package/internal/command.esm.js +0 -185
- package/internal/effectify.esm.js +0 -18
- package/internal/error.esm.js +0 -17
- package/internal/fileSystem.esm.js +0 -82
- package/internal/http/client.esm.js +0 -157
- package/internal/http/etag.esm.js +0 -19
- package/internal/http/formData.esm.js +0 -95
- package/internal/http/middleware.esm.js +0 -46
- package/internal/http/platform.esm.js +0 -52
- package/internal/http/router.esm.js +0 -199
- package/internal/http/server.esm.js +0 -20
- package/internal/http/serverError.esm.js +0 -23
- package/internal/http/serverRequest.esm.js +0 -50
- package/internal/http/serverResponse.esm.js +0 -105
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
import * as Schema from '@effect/schema/Schema';
|
|
2
|
+
import * as Chunk from 'effect/Chunk';
|
|
3
|
+
import * as Context from 'effect/Context';
|
|
4
|
+
import * as Effect from 'effect/Effect';
|
|
5
|
+
import * as Effectable from 'effect/Effectable';
|
|
6
|
+
import { dual } from 'effect/Function';
|
|
7
|
+
import * as Inspectable from 'effect/Inspectable';
|
|
8
|
+
import * as Option from 'effect/Option';
|
|
9
|
+
import FindMyWay from 'find-my-way';
|
|
10
|
+
import { R as RouteNotFound } from './ServerError-04ad5b57.esm.js';
|
|
11
|
+
import { a as ServerRequest } from './ServerRequest-03161edc.esm.js';
|
|
12
|
+
|
|
13
|
+
/** @internal */
|
|
14
|
+
const TypeId$1 = /*#__PURE__*/Symbol.for("@effect/platform/Http/Router");
|
|
15
|
+
|
|
16
|
+
/** @internal */
|
|
17
|
+
const RouteTypeId$1 = /*#__PURE__*/Symbol.for("@effect/platform/Http/Router/Route");
|
|
18
|
+
|
|
19
|
+
/** @internal */
|
|
20
|
+
const RouteContextTypeId$1 = /*#__PURE__*/Symbol.for("@effect/platform/Http/Router/RouteContext");
|
|
21
|
+
|
|
22
|
+
/** @internal */
|
|
23
|
+
const RouteContext$1 = /*#__PURE__*/Context.Tag("@effect/platform/Http/Router/RouteContext");
|
|
24
|
+
|
|
25
|
+
/** @internal */
|
|
26
|
+
const params$1 = /*#__PURE__*/Effect.map(RouteContext$1, _ => _.params);
|
|
27
|
+
|
|
28
|
+
/** @internal */
|
|
29
|
+
const searchParams$1 = /*#__PURE__*/Effect.map(RouteContext$1, _ => _.searchParams);
|
|
30
|
+
|
|
31
|
+
/** @internal */
|
|
32
|
+
const schemaParams$1 = schema => {
|
|
33
|
+
const parse = Schema.parse(schema);
|
|
34
|
+
return Effect.flatMap(RouteContext$1, _ => parse({
|
|
35
|
+
..._.searchParams,
|
|
36
|
+
..._.params
|
|
37
|
+
}));
|
|
38
|
+
};
|
|
39
|
+
class RouterImpl extends Effectable.Effectable {
|
|
40
|
+
constructor(routes, mounts) {
|
|
41
|
+
super();
|
|
42
|
+
this.routes = routes;
|
|
43
|
+
this.mounts = mounts;
|
|
44
|
+
this[TypeId$1] = TypeId$1;
|
|
45
|
+
}
|
|
46
|
+
commit() {
|
|
47
|
+
if (this.httpApp === undefined) {
|
|
48
|
+
this.httpApp = toHttpApp(this);
|
|
49
|
+
}
|
|
50
|
+
return this.httpApp;
|
|
51
|
+
}
|
|
52
|
+
toJSON() {
|
|
53
|
+
return {
|
|
54
|
+
_id: "Router",
|
|
55
|
+
routes: this.routes.toJSON(),
|
|
56
|
+
mounts: this.mounts.toJSON()
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
toString() {
|
|
60
|
+
return Inspectable.toString(this);
|
|
61
|
+
}
|
|
62
|
+
[Inspectable.NodeInspectSymbol]() {
|
|
63
|
+
return this.toJSON();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const toHttpApp = self => {
|
|
67
|
+
const router = FindMyWay();
|
|
68
|
+
const mounts = Chunk.toReadonlyArray(self.mounts);
|
|
69
|
+
const mountsLen = mounts.length;
|
|
70
|
+
Chunk.forEach(self.routes, route => {
|
|
71
|
+
function fn() {
|
|
72
|
+
return route;
|
|
73
|
+
}
|
|
74
|
+
if (route.method === "*") {
|
|
75
|
+
router.all(route.path, fn);
|
|
76
|
+
} else {
|
|
77
|
+
router.on(route.method, route.path, fn);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
return Effect.flatMap(ServerRequest, request => {
|
|
81
|
+
if (mountsLen > 0) {
|
|
82
|
+
for (let i = 0; i < mountsLen; i++) {
|
|
83
|
+
const [path, app] = mounts[i];
|
|
84
|
+
if (request.url.startsWith(path)) {
|
|
85
|
+
return Effect.provideService(app, ServerRequest, sliceRequestUrl(request, path));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
let result = router.find(request.method, request.url);
|
|
90
|
+
if (result === null && request.method === "HEAD") {
|
|
91
|
+
result = router.find("GET", request.url);
|
|
92
|
+
}
|
|
93
|
+
if (result === null) {
|
|
94
|
+
return Effect.fail(RouteNotFound({
|
|
95
|
+
request
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
const route = result.handler();
|
|
99
|
+
if (route.prefix._tag === "Some") {
|
|
100
|
+
request = sliceRequestUrl(request, route.prefix.value);
|
|
101
|
+
}
|
|
102
|
+
return Effect.mapInputContext(route.handler, context => Context.add(Context.add(context, ServerRequest, request), RouteContext$1, new RouteContextImpl(result.params, result.searchParams)));
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
function sliceRequestUrl(request, prefix) {
|
|
106
|
+
const prefexLen = prefix.length;
|
|
107
|
+
return request.modify({
|
|
108
|
+
url: request.url.length <= prefexLen ? "/" : request.url.slice(prefexLen)
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
class RouteImpl {
|
|
112
|
+
constructor(method, path, handler, prefix = Option.none()) {
|
|
113
|
+
this.method = method;
|
|
114
|
+
this.path = path;
|
|
115
|
+
this.handler = handler;
|
|
116
|
+
this.prefix = prefix;
|
|
117
|
+
this[RouteTypeId$1] = RouteTypeId$1;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
class RouteContextImpl {
|
|
121
|
+
constructor(params, searchParams) {
|
|
122
|
+
this.params = params;
|
|
123
|
+
this.searchParams = searchParams;
|
|
124
|
+
this[RouteContextTypeId$1] = RouteContextTypeId$1;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** @internal */
|
|
129
|
+
const empty$1 = /*#__PURE__*/new RouterImpl( /*#__PURE__*/Chunk.empty(), /*#__PURE__*/Chunk.empty());
|
|
130
|
+
|
|
131
|
+
/** @internal */
|
|
132
|
+
const fromIterable$1 = routes => new RouterImpl(Chunk.fromIterable(routes), Chunk.empty());
|
|
133
|
+
|
|
134
|
+
/** @internal */
|
|
135
|
+
const makeRoute$1 = (method, path, handler, prefix = Option.none()) => new RouteImpl(method, path, handler, prefix);
|
|
136
|
+
|
|
137
|
+
/** @internal */
|
|
138
|
+
const concat$1 = /*#__PURE__*/dual(2, (self, that) => new RouterImpl(Chunk.appendAll(self.routes, that.routes), self.mounts));
|
|
139
|
+
const removeTrailingSlash = path => path.endsWith("/") ? path.slice(0, -1) : path;
|
|
140
|
+
|
|
141
|
+
/** @internal */
|
|
142
|
+
const prefixAll$1 = /*#__PURE__*/dual(2, (self, prefix) => {
|
|
143
|
+
prefix = removeTrailingSlash(prefix);
|
|
144
|
+
return new RouterImpl(Chunk.map(self.routes, route => new RouteImpl(route.method, route.path === "/" ? prefix : prefix + route.path, route.handler, Option.orElse(Option.map(route.prefix, _ => prefix + _), () => Option.some(prefix)))), Chunk.map(self.mounts, ([path, app]) => [path === "/" ? prefix : prefix + path, app]));
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
/** @internal */
|
|
148
|
+
const mount$1 = /*#__PURE__*/dual(3, (self, path, that) => concat$1(self, prefixAll$1(that, path)));
|
|
149
|
+
|
|
150
|
+
/** @internal */
|
|
151
|
+
const mountApp$1 = /*#__PURE__*/dual(3, (self, path, that) => new RouterImpl(self.routes, Chunk.append(self.mounts, [removeTrailingSlash(path), that])));
|
|
152
|
+
|
|
153
|
+
/** @internal */
|
|
154
|
+
const route$1 = method => dual(3, (self, path, handler) => new RouterImpl(Chunk.append(self.routes, new RouteImpl(method, path, handler)), self.mounts));
|
|
155
|
+
|
|
156
|
+
/** @internal */
|
|
157
|
+
const all$1 = /*#__PURE__*/route$1("*");
|
|
158
|
+
|
|
159
|
+
/** @internal */
|
|
160
|
+
const get$1 = /*#__PURE__*/route$1("GET");
|
|
161
|
+
|
|
162
|
+
/** @internal */
|
|
163
|
+
const post$1 = /*#__PURE__*/route$1("POST");
|
|
164
|
+
|
|
165
|
+
/** @internal */
|
|
166
|
+
const put$1 = /*#__PURE__*/route$1("PUT");
|
|
167
|
+
|
|
168
|
+
/** @internal */
|
|
169
|
+
const patch$1 = /*#__PURE__*/route$1("PATCH");
|
|
170
|
+
|
|
171
|
+
/** @internal */
|
|
172
|
+
const del$1 = /*#__PURE__*/route$1("DELETE");
|
|
173
|
+
|
|
174
|
+
/** @internal */
|
|
175
|
+
const head$1 = /*#__PURE__*/route$1("HEAD");
|
|
176
|
+
|
|
177
|
+
/** @internal */
|
|
178
|
+
const options$1 = /*#__PURE__*/route$1("OPTIONS");
|
|
179
|
+
|
|
180
|
+
/** @internal */
|
|
181
|
+
const use$1 = /*#__PURE__*/dual(2, (self, f) => new RouterImpl(Chunk.map(self.routes, route => new RouteImpl(route.method, route.path, f(route.handler), route.prefix)), Chunk.map(self.mounts, ([path, app]) => [path, f(app)])));
|
|
182
|
+
|
|
183
|
+
/** @internal */
|
|
184
|
+
const catchAll$1 = /*#__PURE__*/dual(2, (self, f) => use$1(self, Effect.catchAll(f)));
|
|
185
|
+
|
|
186
|
+
/** @internal */
|
|
187
|
+
const catchAllCause$1 = /*#__PURE__*/dual(2, (self, f) => use$1(self, Effect.catchAllCause(f)));
|
|
188
|
+
|
|
189
|
+
/** @internal */
|
|
190
|
+
const catchTag$1 = /*#__PURE__*/dual(3, (self, k, f) => use$1(self, Effect.catchTag(k, f)));
|
|
191
|
+
|
|
192
|
+
/** @internal */
|
|
193
|
+
const catchTags$1 = /*#__PURE__*/dual(2, (self, cases) => use$1(self, Effect.catchTags(cases)));
|
|
194
|
+
const provideService$1 = /*#__PURE__*/dual(3, (self, tag, service) => use$1(self, Effect.provideService(tag, service)));
|
|
195
|
+
|
|
196
|
+
/* @internal */
|
|
197
|
+
const provideServiceEffect$1 = /*#__PURE__*/dual(3, (self, tag, effect) => use$1(self, Effect.provideServiceEffect(tag, effect)));
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* @since 1.0.0
|
|
201
|
+
*/
|
|
202
|
+
/**
|
|
203
|
+
* @since 1.0.0
|
|
204
|
+
* @category type ids
|
|
205
|
+
*/
|
|
206
|
+
const TypeId = TypeId$1;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* @since 1.0.0
|
|
210
|
+
* @category type ids
|
|
211
|
+
*/
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* @since 1.0.0
|
|
215
|
+
* @category models
|
|
216
|
+
*/
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* @since 1.0.0
|
|
220
|
+
*/
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* @since 1.0.0
|
|
224
|
+
* @category type ids
|
|
225
|
+
*/
|
|
226
|
+
const RouteTypeId = RouteTypeId$1;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* @since 1.0.0
|
|
230
|
+
* @category type ids
|
|
231
|
+
*/
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* @since 1.0.0
|
|
235
|
+
* @category models
|
|
236
|
+
*/
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* @since 1.0.0
|
|
240
|
+
*/
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* @since 1.0.0
|
|
244
|
+
* @category type ids
|
|
245
|
+
*/
|
|
246
|
+
const RouteContextTypeId = RouteContextTypeId$1;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* @since 1.0.0
|
|
250
|
+
* @category type ids
|
|
251
|
+
*/
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* @since 1.0.0
|
|
255
|
+
* @category models
|
|
256
|
+
*/
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* @since 1.0.0
|
|
260
|
+
* @category route context
|
|
261
|
+
*/
|
|
262
|
+
const RouteContext = RouteContext$1;
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* @since 1.0.0
|
|
266
|
+
* @category route context
|
|
267
|
+
*/
|
|
268
|
+
const params = params$1;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* @since 1.0.0
|
|
272
|
+
* @category route context
|
|
273
|
+
*/
|
|
274
|
+
const searchParams = searchParams$1;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* @since 1.0.0
|
|
278
|
+
* @category route context
|
|
279
|
+
*/
|
|
280
|
+
const schemaParams = schemaParams$1;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* @since 1.0.0
|
|
284
|
+
* @category constructors
|
|
285
|
+
*/
|
|
286
|
+
const empty = empty$1;
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* @since 1.0.0
|
|
290
|
+
* @category constructors
|
|
291
|
+
*/
|
|
292
|
+
const fromIterable = fromIterable$1;
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* @since 1.0.0
|
|
296
|
+
* @category constructors
|
|
297
|
+
*/
|
|
298
|
+
const makeRoute = makeRoute$1;
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* @since 1.0.0
|
|
302
|
+
* @category combinators
|
|
303
|
+
*/
|
|
304
|
+
const prefixAll = prefixAll$1;
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* @since 1.0.0
|
|
308
|
+
* @category combinators
|
|
309
|
+
*/
|
|
310
|
+
const concat = concat$1;
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* @since 1.0.0
|
|
314
|
+
* @category routing
|
|
315
|
+
*/
|
|
316
|
+
const mount = mount$1;
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* @since 1.0.0
|
|
320
|
+
* @category routing
|
|
321
|
+
*/
|
|
322
|
+
const mountApp = mountApp$1;
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* @since 1.0.0
|
|
326
|
+
* @category routing
|
|
327
|
+
*/
|
|
328
|
+
const route = route$1;
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* @since 1.0.0
|
|
332
|
+
* @category routing
|
|
333
|
+
*/
|
|
334
|
+
const all = all$1;
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* @since 1.0.0
|
|
338
|
+
* @category routing
|
|
339
|
+
*/
|
|
340
|
+
const get = get$1;
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* @since 1.0.0
|
|
344
|
+
* @category routing
|
|
345
|
+
*/
|
|
346
|
+
const post = post$1;
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* @since 1.0.0
|
|
350
|
+
* @category routing
|
|
351
|
+
*/
|
|
352
|
+
const patch = patch$1;
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* @since 1.0.0
|
|
356
|
+
* @category routing
|
|
357
|
+
*/
|
|
358
|
+
const put = put$1;
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* @since 1.0.0
|
|
362
|
+
* @category routing
|
|
363
|
+
*/
|
|
364
|
+
const del = del$1;
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* @since 1.0.0
|
|
368
|
+
* @category routing
|
|
369
|
+
*/
|
|
370
|
+
const head = head$1;
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* @since 1.0.0
|
|
374
|
+
* @category routing
|
|
375
|
+
*/
|
|
376
|
+
const options = options$1;
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* @since 1.0.0
|
|
380
|
+
* @category combinators
|
|
381
|
+
*/
|
|
382
|
+
const use = use$1;
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* @since 1.0.0
|
|
386
|
+
* @category combinators
|
|
387
|
+
*/
|
|
388
|
+
const catchAll = catchAll$1;
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* @since 1.0.0
|
|
392
|
+
* @category combinators
|
|
393
|
+
*/
|
|
394
|
+
const catchAllCause = catchAllCause$1;
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* @since 1.0.0
|
|
398
|
+
* @category combinators
|
|
399
|
+
*/
|
|
400
|
+
const catchTag = catchTag$1;
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* @since 1.0.0
|
|
404
|
+
* @category combinators
|
|
405
|
+
*/
|
|
406
|
+
const catchTags = catchTags$1;
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* @since 1.0.0
|
|
410
|
+
* @category combinators
|
|
411
|
+
*/
|
|
412
|
+
const provideService = provideService$1;
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* @since 1.0.0
|
|
416
|
+
* @category combinators
|
|
417
|
+
*/
|
|
418
|
+
const provideServiceEffect = provideServiceEffect$1;
|
|
419
|
+
|
|
420
|
+
var Router = /*#__PURE__*/Object.freeze({
|
|
421
|
+
__proto__: null,
|
|
422
|
+
TypeId: TypeId,
|
|
423
|
+
RouteTypeId: RouteTypeId,
|
|
424
|
+
RouteContextTypeId: RouteContextTypeId,
|
|
425
|
+
RouteContext: RouteContext,
|
|
426
|
+
params: params,
|
|
427
|
+
searchParams: searchParams,
|
|
428
|
+
schemaParams: schemaParams,
|
|
429
|
+
empty: empty,
|
|
430
|
+
fromIterable: fromIterable,
|
|
431
|
+
makeRoute: makeRoute,
|
|
432
|
+
prefixAll: prefixAll,
|
|
433
|
+
concat: concat,
|
|
434
|
+
mount: mount,
|
|
435
|
+
mountApp: mountApp,
|
|
436
|
+
route: route,
|
|
437
|
+
all: all,
|
|
438
|
+
get: get,
|
|
439
|
+
post: post,
|
|
440
|
+
patch: patch,
|
|
441
|
+
put: put,
|
|
442
|
+
del: del,
|
|
443
|
+
head: head,
|
|
444
|
+
options: options,
|
|
445
|
+
use: use,
|
|
446
|
+
catchAll: catchAll,
|
|
447
|
+
catchAllCause: catchAllCause,
|
|
448
|
+
catchTag: catchTag,
|
|
449
|
+
catchTags: catchTags,
|
|
450
|
+
provideService: provideService,
|
|
451
|
+
provideServiceEffect: provideServiceEffect
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
export { catchTags as A, provideService as B, provideServiceEffect as C, Router as R, TypeId as T, RouteTypeId as a, RouteContextTypeId as b, RouteContext as c, schemaParams as d, empty as e, fromIterable as f, prefixAll as g, concat as h, mount as i, mountApp as j, all as k, get as l, makeRoute as m, post as n, patch as o, params as p, put as q, route as r, searchParams as s, del as t, head as u, options as v, use as w, catchAll as x, catchAllCause as y, catchTag as z };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as Cause from 'effect/Cause';
|
|
2
|
+
import * as Exit from 'effect/Exit';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @since 1.0.0
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @category model
|
|
10
|
+
* @since 1.0.0
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @category teardown
|
|
15
|
+
* @since 1.0.0
|
|
16
|
+
*/
|
|
17
|
+
const defaultTeardown = (exit, onExit) => {
|
|
18
|
+
onExit(Exit.isFailure(exit) && !Cause.isInterruptedOnly(exit.cause) ? 1 : 0);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @category model
|
|
23
|
+
* @since 1.0.0
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
var Runtime = /*#__PURE__*/Object.freeze({
|
|
27
|
+
__proto__: null,
|
|
28
|
+
defaultTeardown: defaultTeardown
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export { Runtime as R, defaultTeardown as d };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import * as Data from 'effect/Data';
|
|
2
|
+
|
|
3
|
+
/** @internal */
|
|
4
|
+
const TypeId$1 = /*#__PURE__*/Symbol.for("@effect/platform/Http/Error");
|
|
5
|
+
const make = tag => props => Data.struct({
|
|
6
|
+
[TypeId$1]: TypeId$1,
|
|
7
|
+
_tag: tag,
|
|
8
|
+
...props
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
/** @internal */
|
|
12
|
+
const requestError = /*#__PURE__*/make("RequestError");
|
|
13
|
+
|
|
14
|
+
/** @internal */
|
|
15
|
+
const responseError = /*#__PURE__*/make("ResponseError");
|
|
16
|
+
|
|
17
|
+
/** @internal */
|
|
18
|
+
const routeNotFound = /*#__PURE__*/make("RouteNotFound");
|
|
19
|
+
|
|
20
|
+
/** @internal */
|
|
21
|
+
const serveError = /*#__PURE__*/make("ServeError");
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @since 1.0.0
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* @since 1.0.0
|
|
28
|
+
* @category type id
|
|
29
|
+
*/
|
|
30
|
+
const TypeId = TypeId$1;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @since 1.0.0
|
|
34
|
+
* @category type id
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @since 1.0.0
|
|
39
|
+
* @category error
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @since 1.0.0
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @since 1.0.0
|
|
48
|
+
* @category error
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @since 1.0.0
|
|
53
|
+
* @category error
|
|
54
|
+
*/
|
|
55
|
+
const RequestError = requestError;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @since 1.0.0
|
|
59
|
+
* @category error
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @since 1.0.0
|
|
64
|
+
* @category error
|
|
65
|
+
*/
|
|
66
|
+
const RouteNotFound = routeNotFound;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @since 1.0.0
|
|
70
|
+
* @category error
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @since 1.0.0
|
|
75
|
+
* @category error
|
|
76
|
+
*/
|
|
77
|
+
const ResponseError = responseError;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @since 1.0.0
|
|
81
|
+
* @category error
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @since 1.0.0
|
|
86
|
+
* @category error
|
|
87
|
+
*/
|
|
88
|
+
const ServeError = serveError;
|
|
89
|
+
|
|
90
|
+
var ServerError = /*#__PURE__*/Object.freeze({
|
|
91
|
+
__proto__: null,
|
|
92
|
+
TypeId: TypeId,
|
|
93
|
+
RequestError: RequestError,
|
|
94
|
+
RouteNotFound: RouteNotFound,
|
|
95
|
+
ResponseError: ResponseError,
|
|
96
|
+
ServeError: ServeError
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
export { RouteNotFound as R, ServerError as S, TypeId as T, RequestError as a, ResponseError as b, ServeError as c };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import * as Context from 'effect/Context';
|
|
2
|
+
import * as Effect from 'effect/Effect';
|
|
3
|
+
import { t as toRecord, s as schemaRecord, a as schemaJson } from './FormData-f54de878.esm.js';
|
|
4
|
+
import { schemaHeaders as schemaHeaders$2, schemaBodyJson as schemaBodyJson$2, schemaBodyUrlParams as schemaBodyUrlParams$2, maxBodySize } from '../Http/IncomingMessage/dist/effect-platform-Http-IncomingMessage.esm.js';
|
|
5
|
+
import { a as RequestError } from './ServerError-04ad5b57.esm.js';
|
|
6
|
+
|
|
7
|
+
/** @internal */
|
|
8
|
+
const TypeId$1 = /*#__PURE__*/Symbol.for("@effect/platform/Http/ServerRequest");
|
|
9
|
+
|
|
10
|
+
/** @internal */
|
|
11
|
+
const serverRequestTag = /*#__PURE__*/Context.Tag(TypeId$1);
|
|
12
|
+
|
|
13
|
+
/** @internal */
|
|
14
|
+
const formDataRecord$1 = /*#__PURE__*/Effect.map( /*#__PURE__*/Effect.flatMap(serverRequestTag, request => request.formData), toRecord);
|
|
15
|
+
|
|
16
|
+
/** @internal */
|
|
17
|
+
const schemaHeaders$1 = schema => {
|
|
18
|
+
const parse = schemaHeaders$2(schema);
|
|
19
|
+
return Effect.flatMap(serverRequestTag, parse);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** @internal */
|
|
23
|
+
const schemaBodyJson$1 = schema => {
|
|
24
|
+
const parse = schemaBodyJson$2(schema);
|
|
25
|
+
return Effect.flatMap(serverRequestTag, parse);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/** @internal */
|
|
29
|
+
const schemaBodyUrlParams$1 = schema => {
|
|
30
|
+
const parse = schemaBodyUrlParams$2(schema);
|
|
31
|
+
return Effect.flatMap(serverRequestTag, parse);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/** @internal */
|
|
35
|
+
const schemaFormData$1 = schema => {
|
|
36
|
+
const parse = schemaRecord(schema);
|
|
37
|
+
return Effect.flatMap(Effect.flatMap(serverRequestTag, request => request.formData), parse);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** @internal */
|
|
41
|
+
const schemaFormDataJson$1 = schema => {
|
|
42
|
+
const parse = schemaJson(schema);
|
|
43
|
+
return field => Effect.flatMap(serverRequestTag, request => Effect.flatMap(request.formData, formData => Effect.catchTag(parse(formData, field), "FormDataError", error => Effect.fail(RequestError({
|
|
44
|
+
reason: "Decode",
|
|
45
|
+
request,
|
|
46
|
+
error: error.error
|
|
47
|
+
})))));
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @since 1.0.0
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @since 1.0.0
|
|
56
|
+
* @category type ids
|
|
57
|
+
*/
|
|
58
|
+
const TypeId = TypeId$1;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @since 1.0.0
|
|
62
|
+
* @category type ids
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @since 1.0.0
|
|
67
|
+
* @category models
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @since 1.0.0
|
|
72
|
+
* @category context
|
|
73
|
+
*/
|
|
74
|
+
const ServerRequest = serverRequestTag;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @since 1.0.0
|
|
78
|
+
* @category accessors
|
|
79
|
+
*/
|
|
80
|
+
const formDataRecord = formDataRecord$1;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* @since 1.0.0
|
|
84
|
+
* @category schema
|
|
85
|
+
*/
|
|
86
|
+
const schemaHeaders = schemaHeaders$1;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @since 1.0.0
|
|
90
|
+
* @category schema
|
|
91
|
+
*/
|
|
92
|
+
const schemaBodyJson = schemaBodyJson$1;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @since 1.0.0
|
|
96
|
+
* @category schema
|
|
97
|
+
*/
|
|
98
|
+
const schemaBodyUrlParams = schemaBodyUrlParams$1;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @since 1.0.0
|
|
102
|
+
* @category schema
|
|
103
|
+
*/
|
|
104
|
+
const schemaFormData = schemaFormData$1;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @since 1.0.0
|
|
108
|
+
* @category schema
|
|
109
|
+
*/
|
|
110
|
+
const schemaFormDataJson = schemaFormDataJson$1;
|
|
111
|
+
|
|
112
|
+
var ServerRequest$1 = /*#__PURE__*/Object.freeze({
|
|
113
|
+
__proto__: null,
|
|
114
|
+
TypeId: TypeId,
|
|
115
|
+
ServerRequest: ServerRequest,
|
|
116
|
+
formDataRecord: formDataRecord,
|
|
117
|
+
schemaHeaders: schemaHeaders,
|
|
118
|
+
schemaBodyJson: schemaBodyJson,
|
|
119
|
+
schemaBodyUrlParams: schemaBodyUrlParams,
|
|
120
|
+
schemaFormData: schemaFormData,
|
|
121
|
+
schemaFormDataJson: schemaFormDataJson,
|
|
122
|
+
maxBodySize: maxBodySize
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
export { ServerRequest$1 as S, TypeId as T, ServerRequest as a, schemaBodyJson as b, schemaBodyUrlParams as c, schemaFormData as d, schemaFormDataJson as e, formDataRecord as f, schemaHeaders as s };
|