effect-start 0.17.2 → 0.19.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/dist/Development.d.ts +7 -2
- package/dist/Development.js +12 -6
- package/dist/PlatformRuntime.d.ts +4 -0
- package/dist/PlatformRuntime.js +9 -0
- package/dist/Route.d.ts +6 -2
- package/dist/Route.js +22 -0
- package/dist/RouteHttp.d.ts +1 -1
- package/dist/RouteHttp.js +12 -19
- package/dist/RouteMount.d.ts +2 -1
- package/dist/Start.d.ts +1 -5
- package/dist/Start.js +1 -8
- package/dist/Unique.d.ts +50 -0
- package/dist/Unique.js +187 -0
- package/dist/bun/BunHttpServer.js +5 -6
- package/dist/bun/BunRoute.d.ts +1 -1
- package/dist/bun/BunRoute.js +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/node/Effectify.d.ts +209 -0
- package/dist/node/Effectify.js +19 -0
- package/dist/node/FileSystem.d.ts +3 -5
- package/dist/node/FileSystem.js +42 -62
- package/dist/node/PlatformError.d.ts +46 -0
- package/dist/node/PlatformError.js +43 -0
- package/dist/testing/TestLogger.js +1 -1
- package/package.json +10 -5
- package/src/Development.ts +13 -18
- package/src/PlatformRuntime.ts +11 -0
- package/src/Route.ts +31 -2
- package/src/RouteHttp.ts +15 -31
- package/src/RouteMount.ts +1 -1
- package/src/Start.ts +1 -15
- package/src/Unique.ts +232 -0
- package/src/bun/BunHttpServer.ts +6 -9
- package/src/bun/BunRoute.ts +3 -3
- package/src/index.ts +1 -0
- package/src/node/Effectify.ts +262 -0
- package/src/node/FileSystem.ts +59 -97
- package/src/node/PlatformError.ts +102 -0
- package/src/testing/TestLogger.ts +1 -1
- package/dist/Random.d.ts +0 -5
- package/dist/Random.js +0 -49
- package/src/Commander.test.ts +0 -1639
- package/src/ContentNegotiation.test.ts +0 -603
- package/src/Development.test.ts +0 -119
- package/src/Entity.test.ts +0 -592
- package/src/FileRouterPattern.test.ts +0 -147
- package/src/FileRouter_files.test.ts +0 -64
- package/src/FileRouter_path.test.ts +0 -145
- package/src/FileRouter_tree.test.ts +0 -132
- package/src/Http.test.ts +0 -319
- package/src/HttpAppExtra.test.ts +0 -103
- package/src/HttpUtils.test.ts +0 -85
- package/src/PathPattern.test.ts +0 -648
- package/src/Random.ts +0 -59
- package/src/RouteBody.test.ts +0 -232
- package/src/RouteHook.test.ts +0 -40
- package/src/RouteHttp.test.ts +0 -2909
- package/src/RouteMount.test.ts +0 -481
- package/src/RouteSchema.test.ts +0 -427
- package/src/RouteSse.test.ts +0 -249
- package/src/RouteTree.test.ts +0 -494
- package/src/RouteTrie.test.ts +0 -322
- package/src/RouterPattern.test.ts +0 -676
- package/src/Values.test.ts +0 -263
- package/src/bun/BunBundle.test.ts +0 -268
- package/src/bun/BunBundle_imports.test.ts +0 -48
- package/src/bun/BunHttpServer.test.ts +0 -251
- package/src/bun/BunImportTrackerPlugin.test.ts +0 -77
- package/src/bun/BunRoute.test.ts +0 -162
- package/src/bundler/BundleHttp.test.ts +0 -132
- package/src/effect/HttpRouter.test.ts +0 -548
- package/src/experimental/EncryptedCookies.test.ts +0 -488
- package/src/hyper/HyperHtml.test.ts +0 -209
- package/src/hyper/HyperRoute.test.tsx +0 -197
- package/src/middlewares/BasicAuthMiddleware.test.ts +0 -84
- package/src/testing/TestHttpClient.test.ts +0 -83
- package/src/testing/TestLogger.test.ts +0 -51
- package/src/x/datastar/Datastar.test.ts +0 -266
- package/src/x/tailwind/TailwindPlugin.test.ts +0 -333
package/src/RouteTrie.test.ts
DELETED
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
import * as test from "bun:test"
|
|
2
|
-
import * as Route from "./Route.ts"
|
|
3
|
-
import * as RouteMount from "./RouteMount.ts"
|
|
4
|
-
import * as RouteTrie from "./RouteTrie.ts"
|
|
5
|
-
|
|
6
|
-
test.describe(RouteTrie.make, () => {
|
|
7
|
-
test.it("creates trie from route set", () => {
|
|
8
|
-
const routes = Route
|
|
9
|
-
.add("/about", Route.get(Route.text("About")))
|
|
10
|
-
|
|
11
|
-
const trie = RouteTrie.make(routes)
|
|
12
|
-
|
|
13
|
-
test
|
|
14
|
-
.expect(trie.methods["GET"])
|
|
15
|
-
.toBeDefined()
|
|
16
|
-
})
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
test.describe(RouteTrie.lookup, () => {
|
|
20
|
-
test.it("matches exact static path", () => {
|
|
21
|
-
const routes = Route
|
|
22
|
-
.add("/about", Route.get(Route.text("About")))
|
|
23
|
-
const trie = RouteTrie.make(routes)
|
|
24
|
-
|
|
25
|
-
const results = RouteTrie.lookup(trie, "GET", "/about")
|
|
26
|
-
|
|
27
|
-
test
|
|
28
|
-
.expect(results.length)
|
|
29
|
-
.toBe(1)
|
|
30
|
-
test
|
|
31
|
-
.expect(results[0].params)
|
|
32
|
-
.toEqual({})
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
test.it("returns empty for non-matching path", () => {
|
|
36
|
-
const routes = Route
|
|
37
|
-
.add("/about", Route.get(Route.text("About")))
|
|
38
|
-
const trie = RouteTrie.make(routes)
|
|
39
|
-
|
|
40
|
-
const results = RouteTrie.lookup(trie, "GET", "/contact")
|
|
41
|
-
|
|
42
|
-
test
|
|
43
|
-
.expect(results.length)
|
|
44
|
-
.toBe(0)
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
test.it("matches path with single param", () => {
|
|
48
|
-
const routes = Route
|
|
49
|
-
.add("/users/:id", Route.get(Route.text("User")))
|
|
50
|
-
const trie = RouteTrie.make(routes)
|
|
51
|
-
|
|
52
|
-
const results = RouteTrie.lookup(trie, "GET", "/users/123")
|
|
53
|
-
|
|
54
|
-
test
|
|
55
|
-
.expect(results.length)
|
|
56
|
-
.toBe(1)
|
|
57
|
-
test
|
|
58
|
-
.expect(results[0].params)
|
|
59
|
-
.toEqual({ id: "123" })
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
test.it("matches path with multiple params", () => {
|
|
63
|
-
const routes = Route
|
|
64
|
-
.add("/users/:userId/posts/:postId", Route.get(Route.text("Post")))
|
|
65
|
-
const trie = RouteTrie.make(routes)
|
|
66
|
-
|
|
67
|
-
const results = RouteTrie.lookup(trie, "GET", "/users/42/posts/7")
|
|
68
|
-
|
|
69
|
-
test
|
|
70
|
-
.expect(results.length)
|
|
71
|
-
.toBe(1)
|
|
72
|
-
test
|
|
73
|
-
.expect(results[0].params)
|
|
74
|
-
.toEqual({
|
|
75
|
-
userId: "42",
|
|
76
|
-
postId: "7",
|
|
77
|
-
})
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
test.it("matches path with optional param present", () => {
|
|
81
|
-
const routes = Route
|
|
82
|
-
.add("/files/:name?", Route.get(Route.text("File")))
|
|
83
|
-
const trie = RouteTrie.make(routes)
|
|
84
|
-
|
|
85
|
-
const results = RouteTrie.lookup(trie, "GET", "/files/readme")
|
|
86
|
-
|
|
87
|
-
test
|
|
88
|
-
.expect(results.length)
|
|
89
|
-
.toBe(1)
|
|
90
|
-
test
|
|
91
|
-
.expect(results[0].params)
|
|
92
|
-
.toEqual({ name: "readme" })
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
test.it("matches path with optional param absent", () => {
|
|
96
|
-
const routes = Route
|
|
97
|
-
.add("/files/:name?", Route.get(Route.text("File")))
|
|
98
|
-
const trie = RouteTrie.make(routes)
|
|
99
|
-
|
|
100
|
-
const results = RouteTrie.lookup(trie, "GET", "/files")
|
|
101
|
-
|
|
102
|
-
test
|
|
103
|
-
.expect(results.length)
|
|
104
|
-
.toBe(1)
|
|
105
|
-
test
|
|
106
|
-
.expect(results[0].params)
|
|
107
|
-
.toEqual({})
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
test.it("matches path with optional wildcard param", () => {
|
|
111
|
-
const routes = Route
|
|
112
|
-
.add("/docs/:path*", Route.get(Route.text("Docs")))
|
|
113
|
-
const trie = RouteTrie.make(routes)
|
|
114
|
-
|
|
115
|
-
const results = RouteTrie.lookup(trie, "GET", "/docs/api/users/create")
|
|
116
|
-
|
|
117
|
-
test
|
|
118
|
-
.expect(results.length)
|
|
119
|
-
.toBe(1)
|
|
120
|
-
test
|
|
121
|
-
.expect(results[0].params)
|
|
122
|
-
.toEqual({
|
|
123
|
-
path: "api/users/create",
|
|
124
|
-
})
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
test.it("matches path with optional wildcard when empty", () => {
|
|
128
|
-
const routes = Route
|
|
129
|
-
.add("/docs/:path*", Route.get(Route.text("Docs")))
|
|
130
|
-
const trie = RouteTrie.make(routes)
|
|
131
|
-
|
|
132
|
-
const results = RouteTrie.lookup(trie, "GET", "/docs")
|
|
133
|
-
|
|
134
|
-
test
|
|
135
|
-
.expect(results.length)
|
|
136
|
-
.toBe(1)
|
|
137
|
-
test
|
|
138
|
-
.expect(results[0].params)
|
|
139
|
-
.toEqual({})
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
test.it("matches path with required wildcard param", () => {
|
|
143
|
-
const routes = Route
|
|
144
|
-
.add("/docs/:path+", Route.get(Route.text("Docs")))
|
|
145
|
-
const trie = RouteTrie.make(routes)
|
|
146
|
-
|
|
147
|
-
const results = RouteTrie.lookup(trie, "GET", "/docs/api/users/create")
|
|
148
|
-
|
|
149
|
-
test
|
|
150
|
-
.expect(results.length)
|
|
151
|
-
.toBe(1)
|
|
152
|
-
test
|
|
153
|
-
.expect(results[0].params)
|
|
154
|
-
.toEqual({
|
|
155
|
-
path: "api/users/create",
|
|
156
|
-
})
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
test.it("does not match required wildcard when empty", () => {
|
|
160
|
-
const routes = Route
|
|
161
|
-
.add("/docs/:path+", Route.get(Route.text("Docs")))
|
|
162
|
-
const trie = RouteTrie.make(routes)
|
|
163
|
-
|
|
164
|
-
const results = RouteTrie.lookup(trie, "GET", "/docs")
|
|
165
|
-
|
|
166
|
-
test
|
|
167
|
-
.expect(results.length)
|
|
168
|
-
.toBe(0)
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
test.it("required wildcard beats optional wildcard in priority", () => {
|
|
172
|
-
const routes = Route
|
|
173
|
-
.add("/files/:path*", Route.get(Route.text("Optional")))
|
|
174
|
-
.add("/files/:path+", Route.get(Route.text("Required")))
|
|
175
|
-
const trie = RouteTrie.make(routes)
|
|
176
|
-
|
|
177
|
-
const multiResults = RouteTrie.lookup(trie, "GET", "/files/a/b/c")
|
|
178
|
-
|
|
179
|
-
test
|
|
180
|
-
.expect(multiResults.length)
|
|
181
|
-
.toBe(2)
|
|
182
|
-
test
|
|
183
|
-
.expect(multiResults[0].params)
|
|
184
|
-
.toEqual({ path: "a/b/c" })
|
|
185
|
-
test
|
|
186
|
-
.expect(multiResults[1].params)
|
|
187
|
-
.toEqual({ path: "a/b/c" })
|
|
188
|
-
})
|
|
189
|
-
|
|
190
|
-
test.it("optional wildcard matches when required cannot", () => {
|
|
191
|
-
const routes = Route
|
|
192
|
-
.add("/files/:path*", Route.get(Route.text("Optional")))
|
|
193
|
-
.add("/files/:path+", Route.get(Route.text("Required")))
|
|
194
|
-
const trie = RouteTrie.make(routes)
|
|
195
|
-
|
|
196
|
-
const emptyResults = RouteTrie.lookup(trie, "GET", "/files")
|
|
197
|
-
|
|
198
|
-
test
|
|
199
|
-
.expect(emptyResults.length)
|
|
200
|
-
.toBe(1)
|
|
201
|
-
test
|
|
202
|
-
.expect(emptyResults[0].params)
|
|
203
|
-
.toEqual({})
|
|
204
|
-
})
|
|
205
|
-
|
|
206
|
-
test.it("prioritizes static over param routes", () => {
|
|
207
|
-
const routes = Route
|
|
208
|
-
.add("/users/:id", Route.get(Route.text("User by ID")))
|
|
209
|
-
.add("/users/me", Route.get(Route.text("Current user")))
|
|
210
|
-
const trie = RouteTrie.make(routes)
|
|
211
|
-
|
|
212
|
-
const results = RouteTrie.lookup(trie, "GET", "/users/me")
|
|
213
|
-
|
|
214
|
-
test
|
|
215
|
-
.expect(results.length)
|
|
216
|
-
.toBe(2)
|
|
217
|
-
test
|
|
218
|
-
.expect(results[0].params)
|
|
219
|
-
.toEqual({})
|
|
220
|
-
test
|
|
221
|
-
.expect(results[1].params)
|
|
222
|
-
.toEqual({ id: "me" })
|
|
223
|
-
})
|
|
224
|
-
|
|
225
|
-
test.it("matches nested mounted routes", () => {
|
|
226
|
-
const routes = Route
|
|
227
|
-
.add(
|
|
228
|
-
"/admin",
|
|
229
|
-
Route
|
|
230
|
-
.add("/users", Route.get(Route.text("Admin users")))
|
|
231
|
-
.add("/settings", Route.get(Route.text("Admin settings"))),
|
|
232
|
-
)
|
|
233
|
-
const trie = RouteTrie.make(routes)
|
|
234
|
-
|
|
235
|
-
const results = RouteTrie.lookup(trie, "GET", "/admin/users")
|
|
236
|
-
|
|
237
|
-
test
|
|
238
|
-
.expect(results.length)
|
|
239
|
-
.toBe(1)
|
|
240
|
-
})
|
|
241
|
-
|
|
242
|
-
test.it("normalizes paths with trailing slashes", () => {
|
|
243
|
-
const routes = Route
|
|
244
|
-
.add("/about", Route.get(Route.text("About")))
|
|
245
|
-
const trie = RouteTrie.make(routes)
|
|
246
|
-
|
|
247
|
-
const results = RouteTrie.lookup(trie, "GET", "/about/")
|
|
248
|
-
|
|
249
|
-
test
|
|
250
|
-
.expect(results.length)
|
|
251
|
-
.toBe(1)
|
|
252
|
-
test
|
|
253
|
-
.expect(results[0].params)
|
|
254
|
-
.toEqual({})
|
|
255
|
-
})
|
|
256
|
-
|
|
257
|
-
test.it("matches root path", () => {
|
|
258
|
-
const routes = Route
|
|
259
|
-
.add("/", Route.get(Route.text("Home")))
|
|
260
|
-
const trie = RouteTrie.make(routes)
|
|
261
|
-
|
|
262
|
-
const results = RouteTrie.lookup(trie, "GET", "/")
|
|
263
|
-
|
|
264
|
-
test
|
|
265
|
-
.expect(results.length)
|
|
266
|
-
.toBe(1)
|
|
267
|
-
test
|
|
268
|
-
.expect(results[0].params)
|
|
269
|
-
.toEqual({})
|
|
270
|
-
})
|
|
271
|
-
|
|
272
|
-
test.it("matches method-specific routes", () => {
|
|
273
|
-
const routes = Route
|
|
274
|
-
.add("/users", Route.get(Route.text("List users")))
|
|
275
|
-
.add("/users", Route.post(Route.text("Create user")))
|
|
276
|
-
const trie = RouteTrie.make(routes)
|
|
277
|
-
|
|
278
|
-
const getResults = RouteTrie.lookup(trie, "GET", "/users")
|
|
279
|
-
const postResults = RouteTrie.lookup(trie, "POST", "/users")
|
|
280
|
-
|
|
281
|
-
test
|
|
282
|
-
.expect(getResults.length)
|
|
283
|
-
.toBe(1)
|
|
284
|
-
test
|
|
285
|
-
.expect(postResults.length)
|
|
286
|
-
.toBe(1)
|
|
287
|
-
})
|
|
288
|
-
|
|
289
|
-
test.it("matches wildcard method routes", () => {
|
|
290
|
-
const routes = Route
|
|
291
|
-
.add("/health", Route.use(Route.text("OK")))
|
|
292
|
-
const trie = RouteTrie.make(routes)
|
|
293
|
-
|
|
294
|
-
const getResults = RouteTrie.lookup(trie, "GET", "/health")
|
|
295
|
-
const postResults = RouteTrie.lookup(trie, "POST", "/health")
|
|
296
|
-
|
|
297
|
-
test
|
|
298
|
-
.expect(getResults.length)
|
|
299
|
-
.toBe(1)
|
|
300
|
-
test
|
|
301
|
-
.expect(postResults.length)
|
|
302
|
-
.toBe(1)
|
|
303
|
-
})
|
|
304
|
-
|
|
305
|
-
test.it("returns multiple matches for content negotiation", () => {
|
|
306
|
-
const routes = Route
|
|
307
|
-
.add(
|
|
308
|
-
"/page",
|
|
309
|
-
Route.get(
|
|
310
|
-
Route.text("Plain text"),
|
|
311
|
-
Route.html("<p>HTML</p>"),
|
|
312
|
-
),
|
|
313
|
-
)
|
|
314
|
-
const trie = RouteTrie.make(routes)
|
|
315
|
-
|
|
316
|
-
const results = RouteTrie.lookup(trie, "GET", "/page")
|
|
317
|
-
|
|
318
|
-
test
|
|
319
|
-
.expect(results.length)
|
|
320
|
-
.toBe(2)
|
|
321
|
-
})
|
|
322
|
-
})
|