@maiyunnet/kebab 3.2.11 → 3.2.12

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 CHANGED
@@ -5,7 +5,7 @@
5
5
  * --- 本文件用来定义每个目录实体地址的常量 ---
6
6
  */
7
7
  /** --- 当前系统版本号 --- */
8
- export declare const VER = "3.2.11";
8
+ export declare const VER = "3.2.12";
9
9
  /** --- 框架根目录,以 / 结尾 --- */
10
10
  export declare const ROOT_PATH: string;
11
11
  export declare const LIB_PATH: string;
package/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * --- 本文件用来定义每个目录实体地址的常量 ---
7
7
  */
8
8
  /** --- 当前系统版本号 --- */
9
- export const VER = '3.2.11';
9
+ export const VER = '3.2.12';
10
10
  // --- 服务端用的路径 ---
11
11
  const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
12
12
  /** --- /xxx/xxx --- */
package/lib/core.js CHANGED
@@ -360,6 +360,9 @@ export async function passThroughAppend(passThrough, data, end = true) {
360
360
  for (const item of data) {
361
361
  if (item instanceof stream.Readable || item instanceof lResponse.Response) {
362
362
  const stm = item instanceof stream.Readable ? item : item.getStream();
363
+ if (!stm) {
364
+ continue;
365
+ }
363
366
  // --- 读取流、Net 库 Response 对象 ---
364
367
  stm.pipe(passThrough, {
365
368
  'end': false
@@ -27,9 +27,9 @@ export declare class Response {
27
27
  /**
28
28
  * --- 获取响应读取流对象 ---
29
29
  */
30
- getStream(): stream.Readable;
30
+ getStream(): stream.Readable | null;
31
31
  /**
32
32
  * --- 获取原生响应读取流对象 ---
33
33
  */
34
- getRawStream(): stream.Readable;
34
+ getRawStream(): stream.Readable | null;
35
35
  }
@@ -29,12 +29,12 @@ export class Response {
29
29
  * --- 获取响应读取流对象 ---
30
30
  */
31
31
  getStream() {
32
- return this._req.getStream();
32
+ return this._req ? this._req.getStream() : null;
33
33
  }
34
34
  /**
35
35
  * --- 获取原生响应读取流对象 ---
36
36
  */
37
37
  getRawStream() {
38
- return this._req.getRawStream();
38
+ return this._req ? this._req.getRawStream() : null;
39
39
  }
40
40
  }
package/lib/net.js CHANGED
@@ -494,6 +494,10 @@ export async function mproxy(ctr, auth, opt = {}) {
494
494
  ...opt,
495
495
  headers
496
496
  });
497
+ const stream = rres.getRawStream();
498
+ if (!stream) {
499
+ return -3;
500
+ }
497
501
  if (rres.error) {
498
502
  return -2;
499
503
  }
@@ -502,7 +506,7 @@ export async function mproxy(ctr, auth, opt = {}) {
502
506
  }
503
507
  res.writeHead(rres.headers?.['http-code'] ?? 200);
504
508
  await new Promise((resolve) => {
505
- rres.getRawStream().pipe(res).on('finish', () => {
509
+ stream.pipe(res).on('finish', () => {
506
510
  resolve();
507
511
  });
508
512
  });
@@ -554,6 +558,10 @@ export async function rproxy(ctr, route, opt = {}) {
554
558
  ...opt,
555
559
  headers
556
560
  });
561
+ const stream = rres.getRawStream();
562
+ if (!stream) {
563
+ return false;
564
+ }
557
565
  if (rres.error) {
558
566
  return false;
559
567
  }
@@ -562,7 +570,7 @@ export async function rproxy(ctr, route, opt = {}) {
562
570
  }
563
571
  res.writeHead(rres.headers?.['http-code'] ?? 200);
564
572
  await new Promise((resolve) => {
565
- rres.getRawStream().pipe(res).on('finish', () => {
573
+ stream.pipe(res).on('finish', () => {
566
574
  resolve();
567
575
  });
568
576
  });
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<any>;
63
+ getObject(key: string, bucket?: string): Promise<false | (stream.Readable & import("@smithy/types").SdkStreamMixin) | (Blob & import("@smithy/types").SdkStreamMixin) | (ReadableStream<any> & import("@smithy/types").SdkStreamMixin) | undefined>;
64
64
  /**
65
65
  * --- 删除对象 ---
66
66
  * @param key 对象路径
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maiyunnet/kebab",
3
- "version": "3.2.11",
3
+ "version": "3.2.12",
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": [
package/sys/route.js CHANGED
@@ -579,12 +579,7 @@ export async function run(data) {
579
579
  // --- 已经自行输出过 writeHead,可能自行处理了内容,如 pipe,则不再 writeHead ---
580
580
  }
581
581
  else {
582
- if (data.res.getHeader('location')) {
583
- data.res.writeHead(302);
584
- }
585
- else {
586
- data.res.writeHead(httpCode);
587
- }
582
+ data.res.writeHead(data.res.getHeader('location') ? 302 : httpCode);
588
583
  }
589
584
  if (!data.res.writableEnded) {
590
585
  // --- 如果当前还没结束,则强制关闭连接,一切 pipe 请自行在方法中 await,否则会被中断 ---
@@ -623,6 +618,11 @@ export async function run(data) {
623
618
  else if (rtn instanceof stream.Readable || rtn instanceof lResponse.Response) {
624
619
  // --- 返回的是流,那就以管道的形式输出 ---
625
620
  const stm = rtn instanceof stream.Readable ? rtn : rtn.getStream();
621
+ if (!stm) {
622
+ data.res.end('');
623
+ await waitCtr(cctr ?? middle);
624
+ return true;
625
+ }
626
626
  /** --- 当前的压缩对象 --- */
627
627
  let compress = null;
628
628
  if (!data.res.headersSent) {