@maiyunnet/kebab 3.2.19 → 3.2.21
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/net.d.ts +1 -0
- package/lib/net.js +1 -0
- package/lib/s3.js +5 -5
- package/package.json +1 -1
- package/sys/child.js +11 -6
- package/sys/ctr.js +1 -0
- package/www/example/ctr/test.d.ts +1 -0
- package/www/example/ctr/test.js +7 -0
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.21';
|
|
10
10
|
// --- 服务端用的路径 ---
|
|
11
11
|
const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
|
|
12
12
|
/** --- /xxx/xxx --- */
|
package/lib/net.d.ts
CHANGED
|
@@ -114,6 +114,7 @@ export interface IRequestOptions {
|
|
|
114
114
|
'type'?: 'form' | 'json';
|
|
115
115
|
/** --- 秒数 --- */
|
|
116
116
|
'timeout'?: number;
|
|
117
|
+
/** --- 追踪 location 次数,0 为不追踪,默认为 0 --- */
|
|
117
118
|
'follow'?: number;
|
|
118
119
|
/** --- 自定义 host 映射,如 {'www.maiyun.net': '127.0.0.1'},或全部映射到一个 host --- */
|
|
119
120
|
'hosts'?: Record<string, string> | string;
|
package/lib/net.js
CHANGED
|
@@ -99,6 +99,7 @@ export async function request(u, data, opt = {}) {
|
|
|
99
99
|
const method = opt.method ?? 'GET';
|
|
100
100
|
const type = opt.type ?? 'form';
|
|
101
101
|
const timeout = opt.timeout ?? 10;
|
|
102
|
+
/** --- 追踪 location 次数,0 为不追踪,默认为 0 --- */
|
|
102
103
|
const follow = opt.follow ?? 0;
|
|
103
104
|
const hosts = opt.hosts ?? {};
|
|
104
105
|
const save = opt.save;
|
package/lib/s3.js
CHANGED
|
@@ -27,11 +27,11 @@ export class S3 {
|
|
|
27
27
|
this._bucket = '';
|
|
28
28
|
this._ctr = ctr;
|
|
29
29
|
const config = ctr.getPrototype('_config');
|
|
30
|
-
const account = config.s3?.[ESERVICE[opt.service]]?.account ?? '';
|
|
31
|
-
const secretId = config.s3?.[ESERVICE[opt.service]]?.sid ?? '';
|
|
32
|
-
const secretKey = config.s3?.[ESERVICE[opt.service]]?.skey ?? '';
|
|
33
|
-
const region = config.s3?.[ESERVICE[opt.service]]?.region ?? '';
|
|
34
|
-
this._bucket = config.s3?.[ESERVICE[opt.service]]?.bucket ?? '';
|
|
30
|
+
const account = opt.account ?? config.s3?.[ESERVICE[opt.service]]?.account ?? '';
|
|
31
|
+
const secretId = opt.secretId ?? config.s3?.[ESERVICE[opt.service]]?.sid ?? '';
|
|
32
|
+
const secretKey = opt.secretKey ?? config.s3?.[ESERVICE[opt.service]]?.skey ?? '';
|
|
33
|
+
const region = opt.region ?? config.s3?.[ESERVICE[opt.service]]?.region ?? '';
|
|
34
|
+
this._bucket = opt.bucket ?? config.s3?.[ESERVICE[opt.service]]?.bucket ?? '';
|
|
35
35
|
let endpoint;
|
|
36
36
|
switch (opt.service) {
|
|
37
37
|
case ESERVICE.TENCENT: {
|
package/package.json
CHANGED
package/sys/child.js
CHANGED
|
@@ -202,6 +202,7 @@ async function requestHandler(req, res, https) {
|
|
|
202
202
|
'timeout': 30_000,
|
|
203
203
|
'callback': () => {
|
|
204
204
|
if (!req.socket.writable) {
|
|
205
|
+
// --- 用户连接已中断 ---
|
|
205
206
|
return;
|
|
206
207
|
}
|
|
207
208
|
if (res.headersSent) {
|
|
@@ -298,9 +299,11 @@ async function requestHandler(req, res, https) {
|
|
|
298
299
|
'headers': {}
|
|
299
300
|
}, '[CHILD][requestHandler][E0]' + lText.stringifyJson(e.stack).slice(1, -1), '-error');
|
|
300
301
|
const content = '<h1>500 Server Error</h1><hr>Kebab';
|
|
301
|
-
res.
|
|
302
|
-
|
|
303
|
-
|
|
302
|
+
if (!res.headersSent) {
|
|
303
|
+
res.setHeader('content-type', 'text/html; charset=utf-8');
|
|
304
|
+
res.setHeader('content-length', Buffer.byteLength(content));
|
|
305
|
+
lCore.writeHead(res, 500);
|
|
306
|
+
}
|
|
304
307
|
res.end(content);
|
|
305
308
|
return;
|
|
306
309
|
}
|
|
@@ -337,9 +340,11 @@ async function requestHandler(req, res, https) {
|
|
|
337
340
|
catch (e) {
|
|
338
341
|
lCore.log({}, '[CHILD][requestHandler][E1]' + lText.stringifyJson(e.stack).slice(1, -1), '-error');
|
|
339
342
|
const content = '<h1>500 Server Error</h1><hr>Kebab';
|
|
340
|
-
res.
|
|
341
|
-
|
|
342
|
-
|
|
343
|
+
if (!res.headersSent) {
|
|
344
|
+
res.setHeader('content-type', 'text/html; charset=utf-8');
|
|
345
|
+
res.setHeader('content-length', Buffer.byteLength(content));
|
|
346
|
+
lCore.writeHead(res, 500);
|
|
347
|
+
}
|
|
343
348
|
res.end(content);
|
|
344
349
|
return;
|
|
345
350
|
}
|
package/sys/ctr.js
CHANGED
|
@@ -26,6 +26,7 @@ export default class extends sCtr.Ctr {
|
|
|
26
26
|
ctrAsynctask(): any[];
|
|
27
27
|
ctrTimeoutLong(): Promise<any[]>;
|
|
28
28
|
ctrTimeoutShort(): Promise<any[]>;
|
|
29
|
+
ctr500(): Promise<void>;
|
|
29
30
|
modTest(): Promise<kebab.Json[] | string | boolean>;
|
|
30
31
|
modSplit(): Promise<string>;
|
|
31
32
|
modSplit1(): Promise<void>;
|
package/www/example/ctr/test.js
CHANGED
|
@@ -76,6 +76,7 @@ export default class extends sCtr.Ctr {
|
|
|
76
76
|
'<br>QS: ' + this._config.const.qs,
|
|
77
77
|
'<br>HTTPS: ' + (this._config.const.https ? 'true' : 'false'),
|
|
78
78
|
'<br>MOBILE: ' + (this._config.const.mobile ? 'true' : 'false'),
|
|
79
|
+
'<br>MINIPROGRAM: ' + (this._config.const.miniprogram) + ' (' + typeof this._config.const.miniprogram + ')',
|
|
79
80
|
'<br>Real IP: ' + lCore.ip(this),
|
|
80
81
|
'<br>Client IP: ' + lCore.realIP(this),
|
|
81
82
|
'<br><br>URL_BASE: ' + this._config.const.urlBase,
|
|
@@ -114,6 +115,7 @@ export default class extends sCtr.Ctr {
|
|
|
114
115
|
`<br><a href="${this._config.const.urlBase}test/ctr-asynctask">View "test/ctr-asynctask"</a>`,
|
|
115
116
|
`<br><a href="${this._config.const.urlBase}test/ctr-timeout-long">View "test/ctr-timeout-long"</a>`,
|
|
116
117
|
`<br><a href="${this._config.const.urlBase}test/ctr-timeout-short">View "test/ctr-timeout-short"</a>`,
|
|
118
|
+
`<br><a href="${this._config.const.urlBase}test/ctr-500">View "test/ctr-500"</a>`,
|
|
117
119
|
'<br><br><b>Middle:</b>',
|
|
118
120
|
`<br><br><a href="${this._config.const.urlBase}test/middle">View "test/middle"</a>`,
|
|
119
121
|
'<br><br><b>Model test:</b>',
|
|
@@ -536,6 +538,11 @@ Result:<pre id="result">Nothing.</pre>` + this._getEnd();
|
|
|
536
538
|
echo.push('5');
|
|
537
539
|
return [1, { 'list': echo }];
|
|
538
540
|
}
|
|
541
|
+
async ctr500() {
|
|
542
|
+
await lCore.sleep(100);
|
|
543
|
+
lCore.writeHead(this._res, 200);
|
|
544
|
+
lCore.debug('DEBUG', this._res.abc.def);
|
|
545
|
+
}
|
|
539
546
|
async modTest() {
|
|
540
547
|
const retur = [];
|
|
541
548
|
if (!(this._checkInput(this._get, {
|