@bool-ts/core 2.3.1 → 2.3.3
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 +3 -3
- package/dist/index.js.map +3 -3
- package/dist/interfaces/@types.d.ts +1 -0
- package/package.json +3 -3
- package/src/entities/application.ts +27 -21
- package/src/interfaces/@types.ts +1 -0
|
@@ -49,6 +49,7 @@ export type TApplicationOptions<AllowedMethods extends Array<THttpMethods> = Arr
|
|
|
49
49
|
port: number;
|
|
50
50
|
}> & Partial<{
|
|
51
51
|
config: Record<string | symbol, any> | (() => Record<string | symbol, any>);
|
|
52
|
+
idleTimeoutInSeconds: number;
|
|
52
53
|
prefix: string;
|
|
53
54
|
debug: boolean;
|
|
54
55
|
log: Partial<{
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"@bool-ts/date-time": "^1.0.0",
|
|
8
8
|
"qs": "^6.14.1",
|
|
9
9
|
"reflect-metadata": "^0.2.2",
|
|
10
|
-
"zod": "^4.3.
|
|
10
|
+
"zod": "^4.3.6"
|
|
11
11
|
},
|
|
12
12
|
"description": "Core package for BoolTS framework",
|
|
13
13
|
"devDependencies": {
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "tsc --emitDeclarationOnly && bun run app.build.ts",
|
|
43
|
-
"test:server": "bun --hot run __test/server/index.ts",
|
|
43
|
+
"test:server": "bun --hot run __test/server/booljs/index.ts",
|
|
44
44
|
"test:socket": "bun --hot run __test/client/socket.ts"
|
|
45
45
|
},
|
|
46
46
|
"types": "./dist/index.d.ts",
|
|
47
|
-
"version": "2.3.
|
|
47
|
+
"version": "2.3.3"
|
|
48
48
|
}
|
|
@@ -119,10 +119,10 @@ export class Application<TRootClass extends Object = Object> {
|
|
|
119
119
|
allowOrigins: !this.options.cors?.origins
|
|
120
120
|
? ["*"]
|
|
121
121
|
: typeof this.options.cors.origins !== "string"
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
? this.options.cors.origins.includes("*") || this.options.cors.origins.length < 1
|
|
123
|
+
? ["*"]
|
|
124
|
+
: this.options.cors.origins
|
|
125
|
+
: [this.options.cors.origins !== "*" ? this.options.cors.origins : "*"],
|
|
126
126
|
allowMethods: this.options.cors?.methods || httpMethods,
|
|
127
127
|
allowCredentials: !this.options.cors?.credentials ? false : true,
|
|
128
128
|
allowHeaders:
|
|
@@ -231,6 +231,11 @@ export class Application<TRootClass extends Object = Object> {
|
|
|
231
231
|
public async listen() {
|
|
232
232
|
const server = serve<TWebSocketUpgradeData>({
|
|
233
233
|
port: this.options.port,
|
|
234
|
+
idleTimeout:
|
|
235
|
+
typeof this.options.idleTimeoutInSeconds !== "number" ||
|
|
236
|
+
this.options.idleTimeoutInSeconds <= 0
|
|
237
|
+
? undefined
|
|
238
|
+
: this.options.idleTimeoutInSeconds,
|
|
234
239
|
fetch: this.#rootFetch.bind(this),
|
|
235
240
|
websocket: await this.#rootWebSocket.bind(this)()
|
|
236
241
|
});
|
|
@@ -291,8 +296,8 @@ export class Application<TRootClass extends Object = Object> {
|
|
|
291
296
|
value: allowOrigins.includes("*")
|
|
292
297
|
? "*"
|
|
293
298
|
: !allowOrigins.includes(origin)
|
|
294
|
-
|
|
295
|
-
|
|
299
|
+
? allowOrigins[0]
|
|
300
|
+
: origin
|
|
296
301
|
},
|
|
297
302
|
{ key: "Access-Control-Allow-Methods", value: allowMethods.join(", ") },
|
|
298
303
|
{ key: "Access-Control-Allow-Headers", value: allowHeaders.join(", ") }
|
|
@@ -399,7 +404,7 @@ export class Application<TRootClass extends Object = Object> {
|
|
|
399
404
|
const convertedResponseStatus = ansiText(
|
|
400
405
|
` ${inferedResponseStatus} (${inferStatusText(inferedResponseStatus)}) `,
|
|
401
406
|
(() => {
|
|
402
|
-
|
|
407
|
+
if (inferedResponseStatus >= 100 && inferedResponseStatus < 200)
|
|
403
408
|
return {
|
|
404
409
|
color: "white",
|
|
405
410
|
backgroundColor: "cyan"
|
|
@@ -865,6 +870,7 @@ export class Application<TRootClass extends Object = Object> {
|
|
|
865
870
|
.set(responseBodyArgsKey, undefined);
|
|
866
871
|
} else {
|
|
867
872
|
context.set(routeModelArgsKey, routeResult.model);
|
|
873
|
+
context.set(paramsArgsKey, routeResult.parameters);
|
|
868
874
|
|
|
869
875
|
const authResult = await this.#pipesEnforcer({
|
|
870
876
|
type: "GUARDS",
|
|
@@ -1002,12 +1008,12 @@ export class Application<TRootClass extends Object = Object> {
|
|
|
1002
1008
|
? typeof containerConfig !== "object"
|
|
1003
1009
|
? undefined
|
|
1004
1010
|
: "key" in containerConfig &&
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
+
"value" in containerConfig &&
|
|
1012
|
+
typeof containerConfig.key === "symbol"
|
|
1013
|
+
? typeof containerConfig.value !== "function"
|
|
1014
|
+
? containerConfig.value
|
|
1015
|
+
: await containerConfig.value()
|
|
1016
|
+
: containerConfig
|
|
1011
1017
|
: await containerConfig())
|
|
1012
1018
|
}
|
|
1013
1019
|
});
|
|
@@ -1304,12 +1310,12 @@ export class Application<TRootClass extends Object = Object> {
|
|
|
1304
1310
|
? typeof moduleConfig !== "object"
|
|
1305
1311
|
? undefined
|
|
1306
1312
|
: "key" in moduleConfig &&
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
+
"value" in moduleConfig &&
|
|
1314
|
+
typeof moduleConfig.key === "symbol"
|
|
1315
|
+
? typeof moduleConfig.value !== "function"
|
|
1316
|
+
? moduleConfig.value
|
|
1317
|
+
: await moduleConfig.value()
|
|
1318
|
+
: moduleConfig
|
|
1313
1319
|
: await moduleConfig())
|
|
1314
1320
|
}
|
|
1315
1321
|
});
|
|
@@ -2255,8 +2261,8 @@ export class Application<TRootClass extends Object = Object> {
|
|
|
2255
2261
|
!data
|
|
2256
2262
|
? undefined
|
|
2257
2263
|
: data instanceof ReadableStream
|
|
2258
|
-
|
|
2259
|
-
|
|
2264
|
+
? data
|
|
2265
|
+
: JSON.stringify(data),
|
|
2260
2266
|
{
|
|
2261
2267
|
status: inferedStatus,
|
|
2262
2268
|
statusText: inferedStatusText,
|
package/src/interfaces/@types.ts
CHANGED
|
@@ -94,6 +94,7 @@ export type TApplicationOptions<AllowedMethods extends Array<THttpMethods> = Arr
|
|
|
94
94
|
}> &
|
|
95
95
|
Partial<{
|
|
96
96
|
config: Record<string | symbol, any> | (() => Record<string | symbol, any>);
|
|
97
|
+
idleTimeoutInSeconds: number;
|
|
97
98
|
prefix: string;
|
|
98
99
|
debug: boolean;
|
|
99
100
|
log: Partial<{
|