@bool-ts/core 2.3.1 → 2.3.2
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 +3 -3
- package/dist/interfaces/@types.d.ts +1 -0
- package/package.json +2 -2
- package/src/entities/application.ts +26 -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": {
|
|
@@ -44,5 +44,5 @@
|
|
|
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.2"
|
|
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"
|
|
@@ -1002,12 +1007,12 @@ export class Application<TRootClass extends Object = Object> {
|
|
|
1002
1007
|
? typeof containerConfig !== "object"
|
|
1003
1008
|
? undefined
|
|
1004
1009
|
: "key" in containerConfig &&
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1010
|
+
"value" in containerConfig &&
|
|
1011
|
+
typeof containerConfig.key === "symbol"
|
|
1012
|
+
? typeof containerConfig.value !== "function"
|
|
1013
|
+
? containerConfig.value
|
|
1014
|
+
: await containerConfig.value()
|
|
1015
|
+
: containerConfig
|
|
1011
1016
|
: await containerConfig())
|
|
1012
1017
|
}
|
|
1013
1018
|
});
|
|
@@ -1304,12 +1309,12 @@ export class Application<TRootClass extends Object = Object> {
|
|
|
1304
1309
|
? typeof moduleConfig !== "object"
|
|
1305
1310
|
? undefined
|
|
1306
1311
|
: "key" in moduleConfig &&
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1312
|
+
"value" in moduleConfig &&
|
|
1313
|
+
typeof moduleConfig.key === "symbol"
|
|
1314
|
+
? typeof moduleConfig.value !== "function"
|
|
1315
|
+
? moduleConfig.value
|
|
1316
|
+
: await moduleConfig.value()
|
|
1317
|
+
: moduleConfig
|
|
1313
1318
|
: await moduleConfig())
|
|
1314
1319
|
}
|
|
1315
1320
|
});
|
|
@@ -2255,8 +2260,8 @@ export class Application<TRootClass extends Object = Object> {
|
|
|
2255
2260
|
!data
|
|
2256
2261
|
? undefined
|
|
2257
2262
|
: data instanceof ReadableStream
|
|
2258
|
-
|
|
2259
|
-
|
|
2263
|
+
? data
|
|
2264
|
+
: JSON.stringify(data),
|
|
2260
2265
|
{
|
|
2261
2266
|
status: inferedStatus,
|
|
2262
2267
|
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<{
|