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,219 +0,0 @@
|
|
|
1
|
-
import * as t from "bun:test"
|
|
2
|
-
import * as Effect from "effect/Effect"
|
|
3
|
-
import * as Route from "../Route.ts"
|
|
4
|
-
import * as Router from "../Router.ts"
|
|
5
|
-
import * as TestHttpClient from "../testing/TestHttpClient.ts"
|
|
6
|
-
import * as BunHttpServer from "./BunHttpServer.ts"
|
|
7
|
-
import * as BunRoute from "./BunRoute.ts"
|
|
8
|
-
|
|
9
|
-
t.describe("BunRoute proxy with Bun.serve", () => {
|
|
10
|
-
t.test("BunRoute proxy returns same content as direct bundle access", async () => {
|
|
11
|
-
const bunRoute = BunRoute.html(() => import("../../static/TestPage.html"))
|
|
12
|
-
|
|
13
|
-
const router = Router.mount("/test", bunRoute)
|
|
14
|
-
|
|
15
|
-
await Effect.runPromise(
|
|
16
|
-
Effect
|
|
17
|
-
.gen(function*() {
|
|
18
|
-
const bunServer = yield* BunHttpServer.BunHttpServer
|
|
19
|
-
|
|
20
|
-
const routes = yield* BunRoute.routesFromRouter(router)
|
|
21
|
-
bunServer.addRoutes(routes)
|
|
22
|
-
|
|
23
|
-
const internalPath = Object.keys(routes).find((k) =>
|
|
24
|
-
k.includes(".BunRoute-")
|
|
25
|
-
)
|
|
26
|
-
t.expect(internalPath).toBeDefined()
|
|
27
|
-
|
|
28
|
-
const proxyHandler = routes["/test"]
|
|
29
|
-
t.expect(typeof proxyHandler).toBe("function")
|
|
30
|
-
|
|
31
|
-
const internalBundle = routes[internalPath!]
|
|
32
|
-
t.expect(internalBundle).toHaveProperty("index")
|
|
33
|
-
|
|
34
|
-
const baseUrl =
|
|
35
|
-
`http://${bunServer.server.hostname}:${bunServer.server.port}`
|
|
36
|
-
const client = TestHttpClient.make<never, never>(
|
|
37
|
-
(req) => fetch(req),
|
|
38
|
-
{
|
|
39
|
-
baseUrl,
|
|
40
|
-
},
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
const directResponse = yield* client.get(internalPath!)
|
|
44
|
-
const proxyResponse = yield* client.get("/test")
|
|
45
|
-
|
|
46
|
-
t.expect(proxyResponse.status).toBe(directResponse.status)
|
|
47
|
-
|
|
48
|
-
const directText = yield* directResponse.text
|
|
49
|
-
const proxyText = yield* proxyResponse.text
|
|
50
|
-
|
|
51
|
-
t.expect(proxyText).toBe(directText)
|
|
52
|
-
t.expect(proxyText).toContain("Test Page Content")
|
|
53
|
-
})
|
|
54
|
-
.pipe(
|
|
55
|
-
Effect.scoped,
|
|
56
|
-
Effect.provide(BunHttpServer.layer({ port: 0 })),
|
|
57
|
-
),
|
|
58
|
-
)
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
t.test("multiple BunRoutes each get unique internal paths", async () => {
|
|
62
|
-
const bunRoute1 = BunRoute.html(() => import("../../static/TestPage.html"))
|
|
63
|
-
const bunRoute2 = BunRoute.html(() =>
|
|
64
|
-
import("../../static/AnotherPage.html")
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
const router = Router
|
|
68
|
-
.mount("/page1", bunRoute1)
|
|
69
|
-
.mount("/page2", bunRoute2)
|
|
70
|
-
|
|
71
|
-
await Effect.runPromise(
|
|
72
|
-
Effect
|
|
73
|
-
.gen(function*() {
|
|
74
|
-
const bunServer = yield* BunHttpServer.BunHttpServer
|
|
75
|
-
const routes = yield* BunRoute.routesFromRouter(router)
|
|
76
|
-
bunServer.addRoutes(routes)
|
|
77
|
-
|
|
78
|
-
const internalPaths = Object.keys(routes).filter((k) =>
|
|
79
|
-
k.includes(".BunRoute-")
|
|
80
|
-
)
|
|
81
|
-
t.expect(internalPaths).toHaveLength(2)
|
|
82
|
-
|
|
83
|
-
const nonces = internalPaths.map((p) => {
|
|
84
|
-
const match = p.match(/\.BunRoute-([a-z0-9]+)/)
|
|
85
|
-
return match?.[1]
|
|
86
|
-
})
|
|
87
|
-
t.expect(nonces[0]).not.toBe(nonces[1])
|
|
88
|
-
|
|
89
|
-
const baseUrl =
|
|
90
|
-
`http://${bunServer.server.hostname}:${bunServer.server.port}`
|
|
91
|
-
const client = TestHttpClient.make<never, never>(
|
|
92
|
-
(req) => fetch(req),
|
|
93
|
-
{
|
|
94
|
-
baseUrl,
|
|
95
|
-
},
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
const response1 = yield* client.get("/page1")
|
|
99
|
-
const response2 = yield* client.get("/page2")
|
|
100
|
-
|
|
101
|
-
const text1 = yield* response1.text
|
|
102
|
-
const text2 = yield* response2.text
|
|
103
|
-
|
|
104
|
-
t.expect(text1).toContain("Test Page Content")
|
|
105
|
-
t.expect(text2).toContain("Another Page Content")
|
|
106
|
-
})
|
|
107
|
-
.pipe(
|
|
108
|
-
Effect.scoped,
|
|
109
|
-
Effect.provide(BunHttpServer.layer({ port: 0 })),
|
|
110
|
-
),
|
|
111
|
-
)
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
t.test("proxy preserves request headers", async () => {
|
|
115
|
-
const bunRoute = BunRoute.html(() => import("../../static/TestPage.html"))
|
|
116
|
-
|
|
117
|
-
const router = Router.mount("/headers-test", bunRoute)
|
|
118
|
-
|
|
119
|
-
await Effect.runPromise(
|
|
120
|
-
Effect
|
|
121
|
-
.gen(function*() {
|
|
122
|
-
const bunServer = yield* BunHttpServer.BunHttpServer
|
|
123
|
-
|
|
124
|
-
const routes = yield* BunRoute.routesFromRouter(router)
|
|
125
|
-
bunServer.addRoutes(routes)
|
|
126
|
-
|
|
127
|
-
const baseUrl =
|
|
128
|
-
`http://${bunServer.server.hostname}:${bunServer.server.port}`
|
|
129
|
-
const client = TestHttpClient.make<never, never>(
|
|
130
|
-
(req) => fetch(req),
|
|
131
|
-
{
|
|
132
|
-
baseUrl,
|
|
133
|
-
},
|
|
134
|
-
)
|
|
135
|
-
|
|
136
|
-
const response = yield* client.get("/headers-test", {
|
|
137
|
-
headers: {
|
|
138
|
-
"Accept": "text/html",
|
|
139
|
-
"X-Custom-Header": "test-value",
|
|
140
|
-
},
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
t.expect(response.status).toBe(200)
|
|
144
|
-
const text = yield* response.text
|
|
145
|
-
t.expect(text).toContain("Test Page Content")
|
|
146
|
-
})
|
|
147
|
-
.pipe(
|
|
148
|
-
Effect.scoped,
|
|
149
|
-
Effect.provide(BunHttpServer.layer({ port: 0 })),
|
|
150
|
-
),
|
|
151
|
-
)
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
t.test("mixed BunRoute and regular routes work together", async () => {
|
|
155
|
-
const bunRoute = BunRoute.html(() => import("../../static/TestPage.html"))
|
|
156
|
-
|
|
157
|
-
const router = Router
|
|
158
|
-
.mount("/html", bunRoute)
|
|
159
|
-
.mount("/api", Route.text("Hello from text route"))
|
|
160
|
-
|
|
161
|
-
await Effect.runPromise(
|
|
162
|
-
Effect
|
|
163
|
-
.gen(function*() {
|
|
164
|
-
const bunServer = yield* BunHttpServer.BunHttpServer
|
|
165
|
-
const routes = yield* BunRoute.routesFromRouter(router)
|
|
166
|
-
bunServer.addRoutes(routes)
|
|
167
|
-
|
|
168
|
-
const baseUrl =
|
|
169
|
-
`http://${bunServer.server.hostname}:${bunServer.server.port}`
|
|
170
|
-
const client = TestHttpClient.make<never, never>(
|
|
171
|
-
(req) => fetch(req),
|
|
172
|
-
{
|
|
173
|
-
baseUrl,
|
|
174
|
-
},
|
|
175
|
-
)
|
|
176
|
-
|
|
177
|
-
const htmlResponse = yield* client.get("/html")
|
|
178
|
-
const apiResponse = yield* client.get("/api")
|
|
179
|
-
|
|
180
|
-
const htmlText = yield* htmlResponse.text
|
|
181
|
-
const apiText = yield* apiResponse.text
|
|
182
|
-
|
|
183
|
-
t.expect(htmlText).toContain("Test Page Content")
|
|
184
|
-
t.expect(apiText).toBe("Hello from text route")
|
|
185
|
-
})
|
|
186
|
-
.pipe(
|
|
187
|
-
Effect.scoped,
|
|
188
|
-
Effect.provide(BunHttpServer.layer({ port: 0 })),
|
|
189
|
-
),
|
|
190
|
-
)
|
|
191
|
-
})
|
|
192
|
-
|
|
193
|
-
t.test("nonce is different across separate BunRoute instances", async () => {
|
|
194
|
-
const bunRoute1 = BunRoute.html(() => import("../../static/TestPage.html"))
|
|
195
|
-
const bunRoute2 = BunRoute.html(() => import("../../static/TestPage.html"))
|
|
196
|
-
|
|
197
|
-
const router = Router
|
|
198
|
-
.mount("/test1", bunRoute1)
|
|
199
|
-
.mount("/test2", bunRoute2)
|
|
200
|
-
|
|
201
|
-
await Effect.runPromise(
|
|
202
|
-
Effect
|
|
203
|
-
.gen(function*() {
|
|
204
|
-
const routes = yield* BunRoute.routesFromRouter(router)
|
|
205
|
-
|
|
206
|
-
const internalPaths = Object.keys(routes).filter((k) =>
|
|
207
|
-
k.includes(".BunRoute-")
|
|
208
|
-
)
|
|
209
|
-
|
|
210
|
-
t.expect(internalPaths).toHaveLength(2)
|
|
211
|
-
t.expect(internalPaths[0]).not.toBe(internalPaths[1])
|
|
212
|
-
})
|
|
213
|
-
.pipe(
|
|
214
|
-
Effect.scoped,
|
|
215
|
-
Effect.provide(BunHttpServer.layer({ port: 0 })),
|
|
216
|
-
),
|
|
217
|
-
)
|
|
218
|
-
})
|
|
219
|
-
})
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|