@bool-ts/core 2.0.4 → 2.1.1
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/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/package.json +4 -4
- package/src/decorators/webSocket.ts +6 -2
- package/src/entities/application.ts +39 -33
package/package.json
CHANGED
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
"@bool-ts/date-time": "^1.0.0",
|
|
8
8
|
"qs": "^6.14.0",
|
|
9
9
|
"reflect-metadata": "^0.2.2",
|
|
10
|
-
"zod": "^4.1
|
|
10
|
+
"zod": "^4.2.1"
|
|
11
11
|
},
|
|
12
12
|
"description": "Core package for BoolTS framework",
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"@types/bun": "latest",
|
|
15
15
|
"@types/qs": "^6.14.0",
|
|
16
|
-
"typescript": "^5.9.
|
|
16
|
+
"typescript": "^5.9.3"
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
19
|
"./dist",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"test": "bun --hot run __test/index.ts"
|
|
44
44
|
},
|
|
45
45
|
"types": "./dist/index.d.ts",
|
|
46
|
-
"version": "2.
|
|
47
|
-
}
|
|
46
|
+
"version": "2.1.1"
|
|
47
|
+
}
|
|
@@ -29,10 +29,14 @@ export type TWebSocketMetadata = Required<{
|
|
|
29
29
|
|
|
30
30
|
const upgradeHandlerSymbol = Symbol("__bool:webSocket.upgrade__");
|
|
31
31
|
|
|
32
|
-
const upgradeHandler = (
|
|
32
|
+
const upgradeHandler = (
|
|
33
|
+
server: Server<TWebSocketUpgradeData>,
|
|
34
|
+
request: Request,
|
|
35
|
+
query: Record<string, unknown>
|
|
36
|
+
) => {
|
|
33
37
|
const url = new URL(request.url);
|
|
34
38
|
|
|
35
|
-
return server.upgrade
|
|
39
|
+
return server.upgrade(request, {
|
|
36
40
|
data: {
|
|
37
41
|
method: request.method.toUpperCase(),
|
|
38
42
|
pathname: url.pathname,
|
|
@@ -280,7 +280,7 @@ export class Application<TRootClass extends Object = Object> {
|
|
|
280
280
|
|
|
281
281
|
const { resolutedContainer, resolutedModules, webSocketsMap } = await this.preLaunch();
|
|
282
282
|
|
|
283
|
-
const server = Bun.serve<TWebSocketUpgradeData
|
|
283
|
+
const server = Bun.serve<TWebSocketUpgradeData>({
|
|
284
284
|
port: this.options.port,
|
|
285
285
|
fetch: async (request, server) => {
|
|
286
286
|
const start = performance.now(),
|
|
@@ -985,33 +985,38 @@ export class Application<TRootClass extends Object = Object> {
|
|
|
985
985
|
|
|
986
986
|
//#region [Configuration(s)]
|
|
987
987
|
const { config } = Object.freeze({
|
|
988
|
-
config:
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
typeof moduleConfig
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
988
|
+
config: !moduleConfig
|
|
989
|
+
? undefined
|
|
990
|
+
: {
|
|
991
|
+
...(typeof options.config !== "function"
|
|
992
|
+
? options.config
|
|
993
|
+
: await options.config()),
|
|
994
|
+
...(typeof moduleConfig !== "function"
|
|
995
|
+
? typeof moduleConfig !== "object"
|
|
996
|
+
? undefined
|
|
997
|
+
: "key" in moduleConfig &&
|
|
998
|
+
"value" in moduleConfig &&
|
|
999
|
+
typeof moduleConfig.key === "symbol"
|
|
1000
|
+
? typeof moduleConfig.value !== "function"
|
|
1001
|
+
? moduleConfig.value
|
|
1002
|
+
: await moduleConfig.value()
|
|
1003
|
+
: moduleConfig
|
|
1004
|
+
: await moduleConfig())
|
|
1005
|
+
}
|
|
1002
1006
|
});
|
|
1003
1007
|
//#endregion
|
|
1004
1008
|
|
|
1005
1009
|
//#region [Register config like an injection]
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1010
|
+
config &&
|
|
1011
|
+
injector.set(
|
|
1012
|
+
moduleConfig &&
|
|
1013
|
+
"key" in moduleConfig &&
|
|
1014
|
+
"value" in moduleConfig &&
|
|
1015
|
+
typeof moduleConfig.key === "symbol"
|
|
1016
|
+
? moduleConfig.key
|
|
1017
|
+
: configKey,
|
|
1018
|
+
config
|
|
1019
|
+
);
|
|
1015
1020
|
//#endregion
|
|
1016
1021
|
|
|
1017
1022
|
//#region [Run loader(s)]
|
|
@@ -1471,12 +1476,11 @@ export class Application<TRootClass extends Object = Object> {
|
|
|
1471
1476
|
data instanceof ReadableStream
|
|
1472
1477
|
) {
|
|
1473
1478
|
return this.finalizeResponse(
|
|
1474
|
-
new Response(
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
)
|
|
1479
|
+
new Response(data as BodyInit, {
|
|
1480
|
+
status: status,
|
|
1481
|
+
statusText: statusText,
|
|
1482
|
+
headers: headers
|
|
1483
|
+
})
|
|
1480
1484
|
);
|
|
1481
1485
|
}
|
|
1482
1486
|
|
|
@@ -1543,8 +1547,10 @@ export class Application<TRootClass extends Object = Object> {
|
|
|
1543
1547
|
}
|
|
1544
1548
|
|
|
1545
1549
|
const httpServer =
|
|
1546
|
-
context.get<Server | null | undefined>(
|
|
1547
|
-
|
|
1550
|
+
context.get<Server<TWebSocketUpgradeData> | null | undefined>(
|
|
1551
|
+
httpServerArgsKey,
|
|
1552
|
+
contextOptions
|
|
1553
|
+
) || undefined,
|
|
1548
1554
|
request =
|
|
1549
1555
|
context.get<Request | null | undefined>(requestArgsKey, contextOptions) ||
|
|
1550
1556
|
undefined,
|
|
@@ -2178,7 +2184,7 @@ export class Application<TRootClass extends Object = Object> {
|
|
|
2178
2184
|
private async webSocketFetcher(
|
|
2179
2185
|
bun: Required<{
|
|
2180
2186
|
request: Request;
|
|
2181
|
-
server: Server
|
|
2187
|
+
server: Server<TWebSocketUpgradeData>;
|
|
2182
2188
|
}>,
|
|
2183
2189
|
bool: Required<{
|
|
2184
2190
|
responseHeaders: Headers;
|