ismx-nexo-node-app 0.4.191 → 0.4.192

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.
@@ -37,6 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
38
  const Service_1 = require("../api/Service");
39
39
  const Business_1 = __importDefault(require("./Business"));
40
+ const node_http_1 = require("node:http");
40
41
  class BusinessServer extends Business_1.default {
41
42
  constructor() {
42
43
  super();
@@ -162,7 +163,10 @@ class BusinessServer extends Business_1.default {
162
163
  socket.set(header, value);
163
164
  });
164
165
  if (response.pipe)
165
- this.readable.fromWeb(response.pipe).pipe(socket);
166
+ if (response.pipe instanceof node_http_1.IncomingMessage)
167
+ response.pipe.pipe(socket);
168
+ else
169
+ this.readable.fromWeb(response.pipe).pipe(socket);
166
170
  else
167
171
  socket.send(response === null || response === void 0 ? void 0 : response.content);
168
172
  try {
@@ -1,3 +1,4 @@
1
+ import { IncomingMessage } from "node:http";
1
2
  export interface HttpRequest<T = any> {
2
3
  id?: string;
3
4
  url?: string;
@@ -30,7 +31,7 @@ export declare class HttpResponse<T = any> {
30
31
  headers?: {
31
32
  [key: string]: string;
32
33
  };
33
- pipe?: ReadableStream;
34
+ pipe?: ReadableStream | IncomingMessage;
34
35
  static ok<T = any>(content: T): HttpResponse<any>;
35
36
  static ko<T = any>(httpCode: number, content: T): HttpResponse<any>;
36
37
  static do<T = any>(httpCode: number, content: T): HttpResponse<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ismx-nexo-node-app",
3
- "version": "0.4.191",
3
+ "version": "0.4.192",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "rm -rf ./dist && npx tsc",
@@ -1,3 +1,5 @@
1
+ import {IncomingMessage} from "node:http";
2
+
1
3
  export interface HttpRequest<T = any> {
2
4
  id?: string,
3
5
  url?: string,
@@ -24,7 +26,7 @@ export class HttpResponse<T = any> {
24
26
  content: T = null!;
25
27
  httpCode?: number;
26
28
  headers?: { [key: string]: string };
27
- pipe?: ReadableStream;
29
+ pipe?: ReadableStream | IncomingMessage;
28
30
 
29
31
  static ok<T=any>(content: T) {
30
32
  let response = new HttpResponse();
@@ -1,5 +1,6 @@
1
1
  import Service, {HttpRequest, HttpResponse} from "../api/Service";
2
2
  import Business from "./Business";
3
+ import {IncomingMessage} from "node:http";
3
4
 
4
5
  export default class BusinessServer extends Business
5
6
  {
@@ -130,7 +131,9 @@ export default class BusinessServer extends Business
130
131
  Object.entries(response.headers ?? {}).forEach(([header, value]) => {
131
132
  socket.set(header, value);
132
133
  });
133
- if (response.pipe) this.readable.fromWeb(response.pipe).pipe(socket);
134
+ if (response.pipe)
135
+ if (response.pipe instanceof IncomingMessage) response.pipe.pipe(socket);
136
+ else this.readable.fromWeb(response.pipe).pipe(socket);
134
137
  else socket.send(response?.content);
135
138
 
136
139
  try { this.onEnd?.(request, response); } catch(e) { }