@maiyunnet/kebab 3.2.9 → 3.2.11
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/index.d.ts +1 -1
- package/index.js +1 -1
- package/lib/fs.js +3 -2
- package/lib/s3.d.ts +1 -1
- package/lib/ws.js +5 -4
- package/package.json +7 -7
- package/sys/child.js +15 -10
- package/sys/mod.d.ts +1 -0
- package/sys/mod.js +5 -6
- package/sys/route.js +28 -22
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* --- 本文件用来定义每个目录实体地址的常量 ---
|
|
7
7
|
*/
|
|
8
8
|
/** --- 当前系统版本号 --- */
|
|
9
|
-
export const VER = '3.2.
|
|
9
|
+
export const VER = '3.2.11';
|
|
10
10
|
// --- 服务端用的路径 ---
|
|
11
11
|
const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
|
|
12
12
|
/** --- /xxx/xxx --- */
|
package/lib/fs.js
CHANGED
|
@@ -426,9 +426,10 @@ export function createWriteStream(path, options) {
|
|
|
426
426
|
export async function readToResponse(path, req, res, stat) {
|
|
427
427
|
stat ??= await stats(path);
|
|
428
428
|
if (!stat) {
|
|
429
|
-
|
|
429
|
+
const content = '<h1>404 Not found</h1><hr>Kebab';
|
|
430
|
+
res.setHeader('content-length', Buffer.byteLength(content));
|
|
430
431
|
res.writeHead(404);
|
|
431
|
-
res.end(
|
|
432
|
+
res.end(content);
|
|
432
433
|
return;
|
|
433
434
|
}
|
|
434
435
|
// --- 判断缓存以及 MIME 和编码 ---
|
package/lib/s3.d.ts
CHANGED
|
@@ -60,7 +60,7 @@ export declare class S3 {
|
|
|
60
60
|
* @param key 对象路径
|
|
61
61
|
* @param bucket bucket 名
|
|
62
62
|
*/
|
|
63
|
-
getObject(key: string, bucket?: string): Promise<
|
|
63
|
+
getObject(key: string, bucket?: string): Promise<any>;
|
|
64
64
|
/**
|
|
65
65
|
* --- 删除对象 ---
|
|
66
66
|
* @param key 对象路径
|
package/lib/ws.js
CHANGED
|
@@ -107,7 +107,7 @@ export class Socket {
|
|
|
107
107
|
'auth': opt.mproxy?.auth ?? ''
|
|
108
108
|
}) : uri.path;
|
|
109
109
|
const cli = ca ?
|
|
110
|
-
|
|
110
|
+
liws.createSecureClient({
|
|
111
111
|
'hostname': (typeof hosts === 'string' ? hosts : hosts[host]) || host,
|
|
112
112
|
'port': port,
|
|
113
113
|
'path': path,
|
|
@@ -116,20 +116,21 @@ export class Socket {
|
|
|
116
116
|
'connectTimeout': timeout * 1000,
|
|
117
117
|
'frameReceiveMode': mode,
|
|
118
118
|
'localAddress': local,
|
|
119
|
-
'ca': ca
|
|
119
|
+
'ca': ca,
|
|
120
120
|
}) :
|
|
121
|
-
|
|
121
|
+
liws.createClient({
|
|
122
122
|
'hostname': (typeof hosts === 'string' ? hosts : hosts[host]) || host,
|
|
123
123
|
'port': port,
|
|
124
124
|
'path': path,
|
|
125
125
|
'headers': headers,
|
|
126
126
|
'connectTimeout': timeout * 1000,
|
|
127
127
|
'frameReceiveMode': mode,
|
|
128
|
-
'localAddress': local
|
|
128
|
+
'localAddress': local,
|
|
129
129
|
});
|
|
130
130
|
cli.setMasking(masking);
|
|
131
131
|
this._ws = cli;
|
|
132
132
|
this._bindEvent();
|
|
133
|
+
await cli.connect();
|
|
133
134
|
return this;
|
|
134
135
|
}
|
|
135
136
|
catch {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maiyunnet/kebab",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.11",
|
|
4
4
|
"description": "Simple, easy-to-use, and fully-featured Node.js framework that is ready-to-use out of the box.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -19,24 +19,24 @@
|
|
|
19
19
|
"#kebab/*": "./*"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@aws-sdk/client-s3": "^3.
|
|
23
|
-
"@aws-sdk/lib-storage": "^3.
|
|
22
|
+
"@aws-sdk/client-s3": "^3.908.0",
|
|
23
|
+
"@aws-sdk/lib-storage": "^3.908.0",
|
|
24
24
|
"@litert/http-client": "^1.1.2",
|
|
25
25
|
"@litert/mime": "^0.1.3",
|
|
26
26
|
"@litert/redis": "^3.0.5",
|
|
27
|
-
"@litert/websocket": "^0.2.
|
|
27
|
+
"@litert/websocket": "^0.2.6",
|
|
28
28
|
"@types/ssh2": "^1.15.5",
|
|
29
29
|
"ejs": "^3.1.10",
|
|
30
30
|
"jszip": "^3.10.1",
|
|
31
|
-
"mysql2": "^3.15.
|
|
31
|
+
"mysql2": "^3.15.2",
|
|
32
32
|
"ssh2": "^1.17.0",
|
|
33
33
|
"svg-captcha": "^1.4.0",
|
|
34
|
-
"tencentcloud-sdk-nodejs": "^4.1.
|
|
34
|
+
"tencentcloud-sdk-nodejs": "^4.1.128"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@litert/eslint-plugin-rules": "^0.3.1",
|
|
38
38
|
"@types/ejs": "^3.1.5",
|
|
39
|
-
"@types/node": "^24.7.
|
|
39
|
+
"@types/node": "^24.7.2",
|
|
40
40
|
"tsc-alias": "^1.8.16",
|
|
41
41
|
"typescript": "^5.9.3"
|
|
42
42
|
}
|
package/sys/child.js
CHANGED
|
@@ -206,9 +206,10 @@ async function requestHandler(req, res, https) {
|
|
|
206
206
|
// --- 已经开始输出的,需要用户自行处理 ---
|
|
207
207
|
return;
|
|
208
208
|
}
|
|
209
|
-
|
|
209
|
+
const content = '<h1>504 Gateway Timeout</h1><hr>Kebab';
|
|
210
|
+
res.setHeader('content-length', Buffer.byteLength(content));
|
|
210
211
|
res.writeHead(504);
|
|
211
|
-
res.end(
|
|
212
|
+
res.end(content);
|
|
212
213
|
}
|
|
213
214
|
};
|
|
214
215
|
timer.timer = setTimeout(timer.callback, timer.timeout);
|
|
@@ -257,10 +258,11 @@ async function requestHandler(req, res, https) {
|
|
|
257
258
|
/** --- 'abc' / 'def.json' --- */
|
|
258
259
|
let stat = await lFs.stats(vhost.real + now + item);
|
|
259
260
|
if (!stat) {
|
|
261
|
+
const content = '<h1>404 Not found</h1><hr>Kebab';
|
|
260
262
|
res.setHeader('content-type', 'text/html; charset=utf-8');
|
|
261
|
-
res.setHeader('content-length',
|
|
263
|
+
res.setHeader('content-length', Buffer.byteLength(content));
|
|
262
264
|
res.writeHead(404);
|
|
263
|
-
res.end(
|
|
265
|
+
res.end(content);
|
|
264
266
|
return;
|
|
265
267
|
}
|
|
266
268
|
if (stat.isDirectory()) {
|
|
@@ -292,10 +294,11 @@ async function requestHandler(req, res, https) {
|
|
|
292
294
|
'cookie': {},
|
|
293
295
|
'headers': {}
|
|
294
296
|
}, '[CHILD][requestHandler][E0]' + lText.stringifyJson(e.stack).slice(1, -1), '-error');
|
|
297
|
+
const content = '<h1>500 Server Error</h1><hr>Kebabb';
|
|
295
298
|
res.setHeader('content-type', 'text/html; charset=utf-8');
|
|
296
|
-
res.setHeader('content-length',
|
|
299
|
+
res.setHeader('content-length', Buffer.byteLength(content));
|
|
297
300
|
res.writeHead(500);
|
|
298
|
-
res.end(
|
|
301
|
+
res.end(content);
|
|
299
302
|
return;
|
|
300
303
|
}
|
|
301
304
|
}
|
|
@@ -330,10 +333,11 @@ async function requestHandler(req, res, https) {
|
|
|
330
333
|
}
|
|
331
334
|
catch (e) {
|
|
332
335
|
lCore.log({}, '[CHILD][requestHandler][E1]' + lText.stringifyJson(e.stack).slice(1, -1), '-error');
|
|
336
|
+
const content = '<h1>500 Server Error</h1><hr>Kebabb';
|
|
333
337
|
res.setHeader('content-type', 'text/html; charset=utf-8');
|
|
334
|
-
res.setHeader('content-length',
|
|
338
|
+
res.setHeader('content-length', Buffer.byteLength(content));
|
|
335
339
|
res.writeHead(500);
|
|
336
|
-
res.end(
|
|
340
|
+
res.end(content);
|
|
337
341
|
return;
|
|
338
342
|
}
|
|
339
343
|
}
|
|
@@ -348,10 +352,11 @@ async function requestHandler(req, res, https) {
|
|
|
348
352
|
return;
|
|
349
353
|
}
|
|
350
354
|
}
|
|
355
|
+
const content = '<h1>403 Forbidden</h1><hr>Kebab';
|
|
351
356
|
res.setHeader('content-type', 'text/html; charset=utf-8');
|
|
352
|
-
res.setHeader('content-length',
|
|
357
|
+
res.setHeader('content-length', Buffer.byteLength(content));
|
|
353
358
|
res.writeHead(403);
|
|
354
|
-
res.end(
|
|
359
|
+
res.end(content);
|
|
355
360
|
}
|
|
356
361
|
/**
|
|
357
362
|
* --- WebSocket 响应 handler ---
|
package/sys/mod.d.ts
CHANGED
package/sys/mod.js
CHANGED
|
@@ -115,11 +115,9 @@ class Mod {
|
|
|
115
115
|
}
|
|
116
116
|
/** --- 是否有 select --- */
|
|
117
117
|
const select = opt.select ?? (opt.where ? '*' : '');
|
|
118
|
-
|
|
119
|
-
this.
|
|
120
|
-
|
|
121
|
-
(opt.alias ? ' ' + opt.alias : ''));
|
|
122
|
-
}
|
|
118
|
+
this._sql.select(select, this.constructor._$table +
|
|
119
|
+
(this._index !== null ? ('_' + this._index[0]) : '') +
|
|
120
|
+
(opt.alias ? ' ' + opt.alias : ''));
|
|
123
121
|
if (opt.where !== undefined) {
|
|
124
122
|
if (this.constructor._soft && !opt.raw) {
|
|
125
123
|
if (typeof opt.where === 'string') {
|
|
@@ -417,7 +415,8 @@ class Mod {
|
|
|
417
415
|
'where': s,
|
|
418
416
|
'raw': opt.raw,
|
|
419
417
|
'index': opt.index,
|
|
420
|
-
'contain': opt.contain
|
|
418
|
+
'contain': opt.contain,
|
|
419
|
+
'alias': opt.alias,
|
|
421
420
|
});
|
|
422
421
|
}
|
|
423
422
|
/**
|
package/sys/route.js
CHANGED
|
@@ -36,9 +36,11 @@ export async function run(data) {
|
|
|
36
36
|
const configContent = await lFs.getContent(data.rootPath + 'kebab.json', 'utf8');
|
|
37
37
|
if (!configContent) {
|
|
38
38
|
if (data.res) {
|
|
39
|
-
|
|
39
|
+
const content = '<h1>500 File kebab.json can not be read</h1><hr>Kebab';
|
|
40
|
+
data.res.setHeader('content-type', 'text/html; charset=utf-8');
|
|
41
|
+
data.res.setHeader('content-length', Buffer.byteLength(content));
|
|
40
42
|
data.res.writeHead(500);
|
|
41
|
-
data.res.end(
|
|
43
|
+
data.res.end(content);
|
|
42
44
|
}
|
|
43
45
|
else {
|
|
44
46
|
data.socket?.destroy();
|
|
@@ -179,7 +181,6 @@ export async function run(data) {
|
|
|
179
181
|
}
|
|
180
182
|
// --- 若文件名为保留的 middle 将不允许进行 ---
|
|
181
183
|
if (pathLeft.startsWith('middle')) {
|
|
182
|
-
const text = '[Error] Controller not found, path: ' + path + '.';
|
|
183
184
|
if (data.res) {
|
|
184
185
|
if (config.route['#404']) {
|
|
185
186
|
data.res.setHeader('location', lText.urlResolve(config.const.urlBase, config.route['#404']));
|
|
@@ -187,10 +188,11 @@ export async function run(data) {
|
|
|
187
188
|
data.res.end('');
|
|
188
189
|
return true;
|
|
189
190
|
}
|
|
191
|
+
const content = '[Error] Controller not found, path: ' + path + '.';
|
|
190
192
|
data.res.setHeader('content-type', 'text/html; charset=utf-8');
|
|
191
|
-
data.res.setHeader('content-length', Buffer.byteLength(
|
|
193
|
+
data.res.setHeader('content-length', Buffer.byteLength(content));
|
|
192
194
|
data.res.writeHead(404);
|
|
193
|
-
data.res.end(
|
|
195
|
+
data.res.end(content);
|
|
194
196
|
}
|
|
195
197
|
else {
|
|
196
198
|
data.socket?.destroy();
|
|
@@ -410,10 +412,11 @@ export async function run(data) {
|
|
|
410
412
|
}
|
|
411
413
|
catch (e) {
|
|
412
414
|
lCore.log(middle, '(E03)' + lText.stringifyJson(e.stack).slice(1, -1), '-error');
|
|
415
|
+
const content = '<h1>500 Server Error</h1><hr>Kebab';
|
|
413
416
|
data.res.setHeader('content-type', 'text/html; charset=utf-8');
|
|
414
|
-
data.res.setHeader('content-length',
|
|
417
|
+
data.res.setHeader('content-length', Buffer.byteLength(content));
|
|
415
418
|
data.res.writeHead(500);
|
|
416
|
-
data.res.end(
|
|
419
|
+
data.res.end(content);
|
|
417
420
|
return true;
|
|
418
421
|
}
|
|
419
422
|
let cacheTTL = middle.getPrototype('_cacheTTL');
|
|
@@ -425,10 +428,11 @@ export async function run(data) {
|
|
|
425
428
|
}
|
|
426
429
|
catch (e) {
|
|
427
430
|
lCore.log(middle, '(E05)' + lText.stringifyJson(e.stack).slice(1, -1), '-error');
|
|
431
|
+
const content = '<h1>500 Server Error</h1><hr>Kebab';
|
|
428
432
|
data.res.setHeader('content-type', 'text/html; charset=utf-8');
|
|
429
|
-
data.res.setHeader('content-length',
|
|
433
|
+
data.res.setHeader('content-length', Buffer.byteLength(content));
|
|
430
434
|
data.res.writeHead(500);
|
|
431
|
-
data.res.end(
|
|
435
|
+
data.res.end(content);
|
|
432
436
|
return true;
|
|
433
437
|
}
|
|
434
438
|
cacheTTL = middle.getPrototype('_cacheTTL');
|
|
@@ -438,17 +442,17 @@ export async function run(data) {
|
|
|
438
442
|
const filePath = config.const.ctrPath + pathLeft + '.js';
|
|
439
443
|
if (!await lFs.isFile(filePath)) {
|
|
440
444
|
// --- 指定的控制器不存在 ---
|
|
441
|
-
const text = '[Error] Controller not found, path: ' + path + '.';
|
|
442
445
|
if (config.route['#404']) {
|
|
443
446
|
data.res.setHeader('location', lText.urlResolve(config.const.urlBase, config.route['#404']));
|
|
444
447
|
data.res.writeHead(302);
|
|
445
448
|
data.res.end('');
|
|
446
449
|
return true;
|
|
447
450
|
}
|
|
451
|
+
const content = '[Error] Controller not found, path: ' + path + '.';
|
|
448
452
|
data.res.setHeader('content-type', 'text/html; charset=utf-8');
|
|
449
|
-
data.res.setHeader('content-length', Buffer.byteLength(
|
|
453
|
+
data.res.setHeader('content-length', Buffer.byteLength(content));
|
|
450
454
|
data.res.writeHead(404);
|
|
451
|
-
data.res.end(
|
|
455
|
+
data.res.end(content);
|
|
452
456
|
return true;
|
|
453
457
|
}
|
|
454
458
|
// --- 加载控制器文件 ---
|
|
@@ -491,11 +495,11 @@ export async function run(data) {
|
|
|
491
495
|
data.res.end('');
|
|
492
496
|
return true;
|
|
493
497
|
}
|
|
494
|
-
const
|
|
498
|
+
const content = '[Error] Action not found, path: ' + path + '.';
|
|
495
499
|
data.res.setHeader('content-type', 'text/html; charset=utf-8');
|
|
496
|
-
data.res.setHeader('content-length', Buffer.byteLength(
|
|
500
|
+
data.res.setHeader('content-length', Buffer.byteLength(content));
|
|
497
501
|
data.res.writeHead(404);
|
|
498
|
-
data.res.end(
|
|
502
|
+
data.res.end(content);
|
|
499
503
|
return true;
|
|
500
504
|
}
|
|
501
505
|
pathRight = pathRight.replace(/-([a-zA-Z0-9])/g, function (t, t1) {
|
|
@@ -508,11 +512,11 @@ export async function run(data) {
|
|
|
508
512
|
data.res.end('');
|
|
509
513
|
return true;
|
|
510
514
|
}
|
|
511
|
-
const
|
|
515
|
+
const content = '[Error] Action not found, path: ' + path + '.';
|
|
512
516
|
data.res.setHeader('content-type', 'text/html; charset=utf-8');
|
|
513
|
-
data.res.setHeader('content-length', Buffer.byteLength(
|
|
517
|
+
data.res.setHeader('content-length', Buffer.byteLength(content));
|
|
514
518
|
data.res.writeHead(404);
|
|
515
|
-
data.res.end(
|
|
519
|
+
data.res.end(content);
|
|
516
520
|
return true;
|
|
517
521
|
}
|
|
518
522
|
// --- 执行 onLoad 方法 ---
|
|
@@ -535,10 +539,11 @@ export async function run(data) {
|
|
|
535
539
|
}
|
|
536
540
|
catch (e) {
|
|
537
541
|
lCore.log(cctr, '(E05)' + lText.stringifyJson(e.stack).slice(1, -1), '-error');
|
|
542
|
+
const content = '<h1>500 Server Error</h1><hr>Kebab';
|
|
538
543
|
data.res.setHeader('content-type', 'text/html; charset=utf-8');
|
|
539
|
-
data.res.setHeader('content-length',
|
|
544
|
+
data.res.setHeader('content-length', Buffer.byteLength(content));
|
|
540
545
|
data.res.writeHead(500);
|
|
541
|
-
data.res.end(
|
|
546
|
+
data.res.end(content);
|
|
542
547
|
await waitCtr(cctr);
|
|
543
548
|
return true;
|
|
544
549
|
}
|
|
@@ -549,10 +554,11 @@ export async function run(data) {
|
|
|
549
554
|
}
|
|
550
555
|
catch (e) {
|
|
551
556
|
lCore.log(cctr, '(E04)' + lText.stringifyJson(e.stack).slice(1, -1), '-error');
|
|
557
|
+
const content = '<h1>500 Server Error</h1><hr>Kebab';
|
|
552
558
|
data.res.setHeader('content-type', 'text/html; charset=utf-8');
|
|
553
|
-
data.res.setHeader('content-length',
|
|
559
|
+
data.res.setHeader('content-length', Buffer.byteLength(content));
|
|
554
560
|
data.res.writeHead(500);
|
|
555
|
-
data.res.end(
|
|
561
|
+
data.res.end(content);
|
|
556
562
|
await waitCtr(cctr);
|
|
557
563
|
return true;
|
|
558
564
|
}
|