effect-start 0.15.0 → 0.16.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/package.json +1 -1
- package/src/ContentNegotiation.test.ts +103 -0
- package/src/ContentNegotiation.ts +10 -3
- package/src/Entity.test.ts +592 -0
- package/src/Entity.ts +362 -0
- package/src/Http.test.ts +315 -20
- package/src/Http.ts +153 -11
- package/src/PathPattern.ts +3 -1
- package/src/Route.ts +22 -10
- package/src/RouteBody.test.ts +81 -29
- package/src/RouteBody.ts +122 -35
- package/src/RouteHook.ts +15 -14
- package/src/RouteHttp.test.ts +2546 -83
- package/src/RouteHttp.ts +321 -113
- package/src/RouteHttpTracer.ts +92 -0
- package/src/RouteMount.test.ts +23 -10
- package/src/RouteMount.ts +161 -4
- package/src/RouteSchema.test.ts +346 -0
- package/src/RouteSchema.ts +386 -7
- package/src/RouteTree.test.ts +233 -85
- package/src/RouteTree.ts +98 -44
- package/src/StreamExtra.ts +21 -1
- package/src/Values.test.ts +263 -0
- package/src/Values.ts +60 -0
- package/src/bun/BunHttpServer.ts +23 -7
- package/src/bun/BunRoute.test.ts +162 -0
- package/src/bun/BunRoute.ts +146 -105
- package/src/index.ts +1 -0
- package/src/testing/TestLogger.test.ts +0 -3
- package/src/testing/TestLogger.ts +15 -9
package/src/RouteHook.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect"
|
|
2
2
|
import type * as Utils from "effect/Utils"
|
|
3
|
+
import * as Entity from "./Entity.ts"
|
|
3
4
|
import * as Route from "./Route.ts"
|
|
4
5
|
|
|
5
6
|
export type FilterResult<BOut, E, R> =
|
|
@@ -11,9 +12,9 @@ export type FilterHandlerInput<BIn, BOut, E, R> =
|
|
|
11
12
|
| ((context: BIn) =>
|
|
12
13
|
| FilterResult<BOut, E, R>
|
|
13
14
|
| Generator<
|
|
14
|
-
Utils.YieldWrap<Effect.Effect<
|
|
15
|
+
Utils.YieldWrap<Effect.Effect<unknown, E, R>>,
|
|
15
16
|
{ context: BOut },
|
|
16
|
-
|
|
17
|
+
unknown
|
|
17
18
|
>)
|
|
18
19
|
|
|
19
20
|
export function filter<
|
|
@@ -34,26 +35,26 @@ export function filter<
|
|
|
34
35
|
): Route.RouteSet.RouteSet<
|
|
35
36
|
D,
|
|
36
37
|
SB,
|
|
37
|
-
[
|
|
38
|
+
[
|
|
39
|
+
...P,
|
|
40
|
+
Route.Route.Route<{}, BOut, unknown, E, R>,
|
|
41
|
+
]
|
|
38
42
|
> {
|
|
39
43
|
const route = Route.make<
|
|
40
44
|
{},
|
|
41
45
|
BOut,
|
|
42
|
-
|
|
46
|
+
unknown,
|
|
43
47
|
E,
|
|
44
48
|
R
|
|
45
|
-
>((context: BOut, next) =>
|
|
49
|
+
>((context: BOut, next: (ctx?: Partial<BOut>) => Entity.Entity<unknown>) =>
|
|
46
50
|
Effect.gen(function*() {
|
|
47
51
|
const filterResult = yield* normalized(context as unknown as BIn)
|
|
48
52
|
|
|
49
|
-
|
|
50
|
-
filterResult
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
: context,
|
|
56
|
-
)
|
|
53
|
+
const mergedContext = filterResult
|
|
54
|
+
? { ...context, ...filterResult.context }
|
|
55
|
+
: context
|
|
56
|
+
|
|
57
|
+
return yield* Entity.resolve(next(mergedContext as Partial<BOut>))
|
|
57
58
|
})
|
|
58
59
|
)
|
|
59
60
|
|
|
@@ -61,7 +62,7 @@ export function filter<
|
|
|
61
62
|
[
|
|
62
63
|
...Route.items(self),
|
|
63
64
|
route,
|
|
64
|
-
] as [...P, Route.Route.Route<{}, BOut,
|
|
65
|
+
] as [...P, Route.Route.Route<{}, BOut, unknown, E, R>],
|
|
65
66
|
Route.descriptor(self),
|
|
66
67
|
)
|
|
67
68
|
}
|