effect-start 0.14.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 +8 -9
- package/src/Commander.test.ts +507 -245
- package/src/ContentNegotiation.test.ts +603 -0
- package/src/ContentNegotiation.ts +542 -0
- package/src/Entity.test.ts +592 -0
- package/src/Entity.ts +362 -0
- package/src/FileRouter.ts +16 -12
- package/src/{FileRouterCodegen.test.ts → FileRouterCodegen.todo.ts} +384 -219
- package/src/FileRouterCodegen.ts +6 -6
- package/src/FileRouterPattern.test.ts +93 -62
- package/src/FileRouter_files.test.ts +5 -5
- package/src/FileRouter_path.test.ts +121 -69
- package/src/FileRouter_tree.test.ts +62 -56
- package/src/FileSystemExtra.test.ts +46 -30
- package/src/Http.test.ts +319 -0
- package/src/Http.ts +167 -0
- package/src/HttpAppExtra.test.ts +39 -20
- package/src/HttpAppExtra.ts +0 -1
- package/src/HttpUtils.test.ts +35 -18
- package/src/HttpUtils.ts +2 -0
- package/src/PathPattern.test.ts +648 -0
- package/src/PathPattern.ts +485 -0
- package/src/Route.ts +266 -1069
- package/src/RouteBody.test.ts +234 -0
- package/src/RouteBody.ts +193 -0
- package/src/RouteHook.test.ts +40 -0
- package/src/RouteHook.ts +106 -0
- package/src/RouteHttp.test.ts +2906 -0
- package/src/RouteHttp.ts +427 -0
- package/src/RouteHttpTracer.ts +92 -0
- package/src/RouteMount.test.ts +481 -0
- package/src/RouteMount.ts +470 -0
- package/src/RouteSchema.test.ts +427 -0
- package/src/RouteSchema.ts +423 -0
- package/src/RouteTree.test.ts +494 -0
- package/src/RouteTree.ts +219 -0
- package/src/RouteTrie.test.ts +322 -0
- package/src/RouteTrie.ts +224 -0
- package/src/RouterPattern.test.ts +569 -548
- package/src/RouterPattern.ts +7 -7
- package/src/Start.ts +3 -3
- package/src/StreamExtra.ts +21 -1
- package/src/TuplePathPattern.ts +64 -0
- package/src/Values.test.ts +263 -0
- package/src/Values.ts +76 -0
- package/src/bun/BunBundle.test.ts +36 -42
- package/src/bun/BunBundle.ts +2 -2
- package/src/bun/BunBundle_imports.test.ts +4 -6
- package/src/bun/BunHttpServer.test.ts +183 -6
- package/src/bun/BunHttpServer.ts +72 -32
- package/src/bun/BunHttpServer_web.ts +18 -6
- package/src/bun/BunImportTrackerPlugin.test.ts +3 -3
- package/src/bun/BunRoute.test.ts +124 -442
- package/src/bun/BunRoute.ts +146 -286
- package/src/{BundleHttp.test.ts → bundler/BundleHttp.test.ts} +34 -60
- package/src/{BundleHttp.ts → bundler/BundleHttp.ts} +1 -2
- package/src/client/index.ts +1 -1
- package/src/{Effect_HttpRouter.test.ts → effect/HttpRouter.test.ts} +69 -90
- package/src/experimental/EncryptedCookies.test.ts +125 -64
- package/src/experimental/SseHttpResponse.ts +0 -1
- package/src/hyper/Hyper.ts +89 -0
- package/src/{HyperHtml.test.ts → hyper/HyperHtml.test.ts} +13 -13
- package/src/{HyperHtml.ts → hyper/HyperHtml.ts} +2 -2
- package/src/{jsx.d.ts → hyper/jsx.d.ts} +1 -1
- package/src/index.ts +3 -4
- package/src/middlewares/BasicAuthMiddleware.test.ts +29 -19
- package/src/{NodeFileSystem.ts → node/FileSystem.ts} +6 -2
- package/src/testing/TestHttpClient.test.ts +26 -26
- package/src/testing/TestLogger.test.ts +27 -14
- package/src/testing/TestLogger.ts +15 -9
- package/src/x/datastar/Datastar.test.ts +47 -48
- package/src/x/datastar/Datastar.ts +1 -1
- package/src/x/tailwind/TailwindPlugin.test.ts +56 -58
- package/src/x/tailwind/plugin.ts +1 -1
- package/src/FileHttpRouter.test.ts +0 -239
- package/src/FileHttpRouter.ts +0 -194
- package/src/Hyper.ts +0 -194
- package/src/Route.test.ts +0 -1370
- package/src/RouteRender.ts +0 -40
- package/src/Router.test.ts +0 -375
- package/src/Router.ts +0 -255
- package/src/bun/BunRoute_bundles.test.ts +0 -219
- /package/src/{Bundle.ts → bundler/Bundle.ts} +0 -0
- /package/src/{BundleFiles.ts → bundler/BundleFiles.ts} +0 -0
- /package/src/{HyperNode.ts → hyper/HyperNode.ts} +0 -0
- /package/src/{jsx-runtime.ts → hyper/jsx-runtime.ts} +0 -0
- /package/src/{NodeUtils.ts → node/Utils.ts} +0 -0
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This file tests `@effect/platform/HttpRouter`, not our code.
|
|
3
3
|
* Since Platform code is still unstable and we relay heavily on its
|
|
4
|
-
* chaining/fallback behavior in `BundleHttp`
|
|
4
|
+
* chaining/fallback behavior in `BundleHttp`
|
|
5
5
|
* We want to ensure the behavior doesn't change across versions.
|
|
6
6
|
*/
|
|
7
7
|
import * as HttpRouter from "@effect/platform/HttpRouter"
|
|
8
8
|
import * as HttpServerResponse from "@effect/platform/HttpServerResponse"
|
|
9
|
-
import * as
|
|
10
|
-
import {
|
|
11
|
-
|
|
9
|
+
import * as test from "bun:test"
|
|
10
|
+
import {
|
|
11
|
+
effectFn,
|
|
12
|
+
TestHttpClient,
|
|
13
|
+
} from "../testing"
|
|
12
14
|
|
|
13
15
|
const effect = effectFn()
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
test.it("Single app mounted on path", () =>
|
|
16
18
|
effect(function*() {
|
|
17
19
|
const app1 = HttpRouter.empty.pipe(
|
|
18
20
|
HttpRouter.get("/hello", HttpServerResponse.text("Hello from app1")),
|
|
@@ -25,16 +27,15 @@ t.it("Single app mounted on path", () =>
|
|
|
25
27
|
const client = TestHttpClient.make(router)
|
|
26
28
|
const response = yield* client.get("/api/hello")
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
test
|
|
29
31
|
.expect(response.status)
|
|
30
32
|
.toBe(200)
|
|
31
|
-
|
|
32
|
-
t
|
|
33
|
+
test
|
|
33
34
|
.expect(yield* response.text)
|
|
34
35
|
.toBe("Hello from app1")
|
|
35
36
|
}))
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
test.it(
|
|
38
39
|
"Multiple apps mounted on same path chain together",
|
|
39
40
|
() =>
|
|
40
41
|
effect(function*() {
|
|
@@ -55,27 +56,25 @@ t.it(
|
|
|
55
56
|
|
|
56
57
|
const response1 = yield* client.get("/api/hello")
|
|
57
58
|
|
|
58
|
-
|
|
59
|
+
test
|
|
59
60
|
.expect(response1.status)
|
|
60
61
|
.toBe(200)
|
|
61
|
-
|
|
62
|
-
t
|
|
62
|
+
test
|
|
63
63
|
.expect(yield* response1.text)
|
|
64
64
|
.toBe("Hello from app1")
|
|
65
65
|
|
|
66
66
|
const response2 = yield* client.get("/api/world")
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
test
|
|
69
69
|
.expect(response2.status)
|
|
70
70
|
.toBe(200)
|
|
71
|
-
|
|
72
|
-
t
|
|
71
|
+
test
|
|
73
72
|
.expect(yield* response2.text)
|
|
74
73
|
.toBe("World from app2")
|
|
75
74
|
}),
|
|
76
75
|
)
|
|
77
76
|
|
|
78
|
-
|
|
77
|
+
test.it(
|
|
79
78
|
"First app has no matching route - second app should be called",
|
|
80
79
|
() =>
|
|
81
80
|
effect(function*() {
|
|
@@ -95,17 +94,16 @@ t.it(
|
|
|
95
94
|
const client = TestHttpClient.make(router)
|
|
96
95
|
const response = yield* client.get("/api/missing")
|
|
97
96
|
|
|
98
|
-
|
|
97
|
+
test
|
|
99
98
|
.expect(response.status)
|
|
100
99
|
.toBe(200)
|
|
101
|
-
|
|
102
|
-
t
|
|
100
|
+
test
|
|
103
101
|
.expect(yield* response.text)
|
|
104
102
|
.toBe("Found in app2")
|
|
105
103
|
}),
|
|
106
104
|
)
|
|
107
105
|
|
|
108
|
-
|
|
106
|
+
test.it(
|
|
109
107
|
"First app has no matching route - second app should be called",
|
|
110
108
|
() =>
|
|
111
109
|
effect(function*() {
|
|
@@ -128,17 +126,16 @@ t.it(
|
|
|
128
126
|
const client = TestHttpClient.make(router)
|
|
129
127
|
const response = yield* client.get("/api/different")
|
|
130
128
|
|
|
131
|
-
|
|
129
|
+
test
|
|
132
130
|
.expect(response.status)
|
|
133
131
|
.toBe(200)
|
|
134
|
-
|
|
135
|
-
t
|
|
132
|
+
test
|
|
136
133
|
.expect(yield* response.text)
|
|
137
134
|
.toBe("Different route")
|
|
138
135
|
}),
|
|
139
136
|
)
|
|
140
137
|
|
|
141
|
-
|
|
138
|
+
test.it("Multiple mounts with different methods", () =>
|
|
142
139
|
effect(function*() {
|
|
143
140
|
const app1 = HttpRouter.empty.pipe(
|
|
144
141
|
HttpRouter.get("/data", HttpServerResponse.text("GET data")),
|
|
@@ -157,26 +154,24 @@ t.it("Multiple mounts with different methods", () =>
|
|
|
157
154
|
|
|
158
155
|
const getResponse = yield* client.get("/api/data")
|
|
159
156
|
|
|
160
|
-
|
|
157
|
+
test
|
|
161
158
|
.expect(getResponse.status)
|
|
162
159
|
.toBe(200)
|
|
163
|
-
|
|
164
|
-
t
|
|
160
|
+
test
|
|
165
161
|
.expect(yield* getResponse.text)
|
|
166
162
|
.toBe("GET data")
|
|
167
163
|
|
|
168
164
|
const postResponse = yield* client.post("/api/data")
|
|
169
165
|
|
|
170
|
-
|
|
166
|
+
test
|
|
171
167
|
.expect(postResponse.status)
|
|
172
168
|
.toBe(200)
|
|
173
|
-
|
|
174
|
-
t
|
|
169
|
+
test
|
|
175
170
|
.expect(yield* postResponse.text)
|
|
176
171
|
.toBe("POST data")
|
|
177
172
|
}))
|
|
178
173
|
|
|
179
|
-
|
|
174
|
+
test.it(
|
|
180
175
|
"Route chaining: RouteNotFound error chains to next router (root mount)",
|
|
181
176
|
() =>
|
|
182
177
|
effect(function*() {
|
|
@@ -202,17 +197,16 @@ t.it(
|
|
|
202
197
|
const client = TestHttpClient.make(router)
|
|
203
198
|
const response = yield* client.get("/admin/page")
|
|
204
199
|
|
|
205
|
-
|
|
200
|
+
test
|
|
206
201
|
.expect(response.status)
|
|
207
202
|
.toBe(200)
|
|
208
|
-
|
|
209
|
-
t
|
|
203
|
+
test
|
|
210
204
|
.expect(yield* response.text)
|
|
211
205
|
.toBe("Page from subApp2")
|
|
212
206
|
}),
|
|
213
207
|
)
|
|
214
208
|
|
|
215
|
-
|
|
209
|
+
test.it(
|
|
216
210
|
"Route chaining: explicit 404 response does not chain to next router (root mount)",
|
|
217
211
|
() =>
|
|
218
212
|
effect(function*() {
|
|
@@ -238,17 +232,16 @@ t.it(
|
|
|
238
232
|
const client = TestHttpClient.make(router)
|
|
239
233
|
const response = yield* client.get("/admin/page")
|
|
240
234
|
|
|
241
|
-
|
|
235
|
+
test
|
|
242
236
|
.expect(response.status)
|
|
243
237
|
.toBe(404)
|
|
244
|
-
|
|
245
|
-
t
|
|
238
|
+
test
|
|
246
239
|
.expect(yield* response.text)
|
|
247
240
|
.toBe("")
|
|
248
241
|
}),
|
|
249
242
|
)
|
|
250
243
|
|
|
251
|
-
|
|
244
|
+
test.it(
|
|
252
245
|
"Route conflicts: direct handlers win when defined before root mount",
|
|
253
246
|
() =>
|
|
254
247
|
effect(function*() {
|
|
@@ -279,37 +272,34 @@ t.it(
|
|
|
279
272
|
|
|
280
273
|
const settingsResponse = yield* client.get("/admin/settings")
|
|
281
274
|
|
|
282
|
-
|
|
275
|
+
test
|
|
283
276
|
.expect(settingsResponse.status)
|
|
284
277
|
.toBe(200)
|
|
285
|
-
|
|
286
|
-
t
|
|
278
|
+
test
|
|
287
279
|
.expect(yield* settingsResponse.text)
|
|
288
280
|
.toBe("Settings from direct handler")
|
|
289
281
|
|
|
290
282
|
const usersResponse = yield* client.get("/admin/users")
|
|
291
283
|
|
|
292
|
-
|
|
284
|
+
test
|
|
293
285
|
.expect(usersResponse.status)
|
|
294
286
|
.toBe(200)
|
|
295
|
-
|
|
296
|
-
t
|
|
287
|
+
test
|
|
297
288
|
.expect(yield* usersResponse.text)
|
|
298
289
|
.toBe("Users from direct handler")
|
|
299
290
|
|
|
300
291
|
const dashboardResponse = yield* client.get("/admin/dashboard")
|
|
301
292
|
|
|
302
|
-
|
|
293
|
+
test
|
|
303
294
|
.expect(dashboardResponse.status)
|
|
304
295
|
.toBe(200)
|
|
305
|
-
|
|
306
|
-
t
|
|
296
|
+
test
|
|
307
297
|
.expect(yield* dashboardResponse.text)
|
|
308
298
|
.toBe("Dashboard from subApp")
|
|
309
299
|
}),
|
|
310
300
|
)
|
|
311
301
|
|
|
312
|
-
|
|
302
|
+
test.it(
|
|
313
303
|
"Route conflicts: root mount wins when defined before direct handlers",
|
|
314
304
|
() =>
|
|
315
305
|
effect(function*() {
|
|
@@ -340,37 +330,34 @@ t.it(
|
|
|
340
330
|
|
|
341
331
|
const profileResponse = yield* client.get("/admin/profile")
|
|
342
332
|
|
|
343
|
-
|
|
333
|
+
test
|
|
344
334
|
.expect(profileResponse.status)
|
|
345
335
|
.toBe(200)
|
|
346
|
-
|
|
347
|
-
t
|
|
336
|
+
test
|
|
348
337
|
.expect(yield* profileResponse.text)
|
|
349
338
|
.toBe("Profile from subApp")
|
|
350
339
|
|
|
351
340
|
const usersResponse = yield* client.get("/admin/users")
|
|
352
341
|
|
|
353
|
-
|
|
342
|
+
test
|
|
354
343
|
.expect(usersResponse.status)
|
|
355
344
|
.toBe(200)
|
|
356
|
-
|
|
357
|
-
t
|
|
345
|
+
test
|
|
358
346
|
.expect(yield* usersResponse.text)
|
|
359
347
|
.toBe("Users from direct handler")
|
|
360
348
|
|
|
361
349
|
const dashboardResponse = yield* client.get("/admin/dashboard")
|
|
362
350
|
|
|
363
|
-
|
|
351
|
+
test
|
|
364
352
|
.expect(dashboardResponse.status)
|
|
365
353
|
.toBe(200)
|
|
366
|
-
|
|
367
|
-
t
|
|
354
|
+
test
|
|
368
355
|
.expect(yield* dashboardResponse.text)
|
|
369
356
|
.toBe("Dashboard from subApp")
|
|
370
357
|
}),
|
|
371
358
|
)
|
|
372
359
|
|
|
373
|
-
|
|
360
|
+
test.it(
|
|
374
361
|
"Route conflicts: mountApp does not chain with direct handlers defined before",
|
|
375
362
|
() =>
|
|
376
363
|
effect(function*() {
|
|
@@ -401,29 +388,28 @@ t.it(
|
|
|
401
388
|
|
|
402
389
|
const settingsResponse = yield* client.get("/admin/settings")
|
|
403
390
|
|
|
404
|
-
|
|
391
|
+
test
|
|
405
392
|
.expect(settingsResponse.status)
|
|
406
393
|
.toBe(404)
|
|
407
394
|
|
|
408
395
|
const usersResponse = yield* client.get("/admin/users")
|
|
409
396
|
|
|
410
|
-
|
|
397
|
+
test
|
|
411
398
|
.expect(usersResponse.status)
|
|
412
399
|
.toBe(404)
|
|
413
400
|
|
|
414
401
|
const dashboardResponse = yield* client.get("/admin/dashboard")
|
|
415
402
|
|
|
416
|
-
|
|
403
|
+
test
|
|
417
404
|
.expect(dashboardResponse.status)
|
|
418
405
|
.toBe(200)
|
|
419
|
-
|
|
420
|
-
t
|
|
406
|
+
test
|
|
421
407
|
.expect(yield* dashboardResponse.text)
|
|
422
408
|
.toBe("Dashboard from subApp")
|
|
423
409
|
}),
|
|
424
410
|
)
|
|
425
411
|
|
|
426
|
-
|
|
412
|
+
test.it(
|
|
427
413
|
"Route conflicts: mountApp does not chain with direct handlers defined after",
|
|
428
414
|
() =>
|
|
429
415
|
effect(function*() {
|
|
@@ -454,33 +440,31 @@ t.it(
|
|
|
454
440
|
|
|
455
441
|
const profileResponse = yield* client.get("/admin/profile")
|
|
456
442
|
|
|
457
|
-
|
|
443
|
+
test
|
|
458
444
|
.expect(profileResponse.status)
|
|
459
445
|
.toBe(200)
|
|
460
|
-
|
|
461
|
-
t
|
|
446
|
+
test
|
|
462
447
|
.expect(yield* profileResponse.text)
|
|
463
448
|
.toBe("Profile from subApp")
|
|
464
449
|
|
|
465
450
|
const settingsResponse = yield* client.get("/admin/settings")
|
|
466
451
|
|
|
467
|
-
|
|
452
|
+
test
|
|
468
453
|
.expect(settingsResponse.status)
|
|
469
454
|
.toBe(404)
|
|
470
455
|
|
|
471
456
|
const dashboardResponse = yield* client.get("/admin/dashboard")
|
|
472
457
|
|
|
473
|
-
|
|
458
|
+
test
|
|
474
459
|
.expect(dashboardResponse.status)
|
|
475
460
|
.toBe(200)
|
|
476
|
-
|
|
477
|
-
t
|
|
461
|
+
test
|
|
478
462
|
.expect(yield* dashboardResponse.text)
|
|
479
463
|
.toBe("Dashboard from subApp")
|
|
480
464
|
}),
|
|
481
465
|
)
|
|
482
466
|
|
|
483
|
-
|
|
467
|
+
test.it(
|
|
484
468
|
"Wildcard routes: single asterisk wildcard handler",
|
|
485
469
|
() =>
|
|
486
470
|
effect(function*() {
|
|
@@ -492,17 +476,16 @@ t.it(
|
|
|
492
476
|
|
|
493
477
|
const response = yield* client.get("/anything")
|
|
494
478
|
|
|
495
|
-
|
|
479
|
+
test
|
|
496
480
|
.expect(response.status)
|
|
497
481
|
.toBe(200)
|
|
498
|
-
|
|
499
|
-
t
|
|
482
|
+
test
|
|
500
483
|
.expect(yield* response.text)
|
|
501
484
|
.toBe("Wildcard handler")
|
|
502
485
|
}),
|
|
503
486
|
)
|
|
504
487
|
|
|
505
|
-
|
|
488
|
+
test.it(
|
|
506
489
|
"Wildcard routes: wildcard defined before literal route",
|
|
507
490
|
() =>
|
|
508
491
|
effect(function*() {
|
|
@@ -515,27 +498,25 @@ t.it(
|
|
|
515
498
|
|
|
516
499
|
const wildcardResponse = yield* client.get("/anything")
|
|
517
500
|
|
|
518
|
-
|
|
501
|
+
test
|
|
519
502
|
.expect(wildcardResponse.status)
|
|
520
503
|
.toBe(200)
|
|
521
|
-
|
|
522
|
-
t
|
|
504
|
+
test
|
|
523
505
|
.expect(yield* wildcardResponse.text)
|
|
524
506
|
.toBe("Wildcard handler")
|
|
525
507
|
|
|
526
508
|
const literalResponse = yield* client.get("/specific")
|
|
527
509
|
|
|
528
|
-
|
|
510
|
+
test
|
|
529
511
|
.expect(literalResponse.status)
|
|
530
512
|
.toBe(200)
|
|
531
|
-
|
|
532
|
-
t
|
|
513
|
+
test
|
|
533
514
|
.expect(yield* literalResponse.text)
|
|
534
515
|
.toBe("Literal handler")
|
|
535
516
|
}),
|
|
536
517
|
)
|
|
537
518
|
|
|
538
|
-
|
|
519
|
+
test.it(
|
|
539
520
|
"Wildcard routes: literal route defined before wildcard",
|
|
540
521
|
() =>
|
|
541
522
|
effect(function*() {
|
|
@@ -548,21 +529,19 @@ t.it(
|
|
|
548
529
|
|
|
549
530
|
const literalResponse = yield* client.get("/specific")
|
|
550
531
|
|
|
551
|
-
|
|
532
|
+
test
|
|
552
533
|
.expect(literalResponse.status)
|
|
553
534
|
.toBe(200)
|
|
554
|
-
|
|
555
|
-
t
|
|
535
|
+
test
|
|
556
536
|
.expect(yield* literalResponse.text)
|
|
557
537
|
.toBe("Literal handler")
|
|
558
538
|
|
|
559
539
|
const wildcardResponse = yield* client.get("/anything")
|
|
560
540
|
|
|
561
|
-
|
|
541
|
+
test
|
|
562
542
|
.expect(wildcardResponse.status)
|
|
563
543
|
.toBe(200)
|
|
564
|
-
|
|
565
|
-
t
|
|
544
|
+
test
|
|
566
545
|
.expect(yield* wildcardResponse.text)
|
|
567
546
|
.toBe("Wildcard handler")
|
|
568
547
|
}),
|