@domain.js/main 0.6.2 → 0.6.5

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.
@@ -25,6 +25,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.Router = void 0;
26
26
  const lodash_1 = __importDefault(require("lodash"));
27
27
  const errors = __importStar(require("restify-errors"));
28
+ const utils_1 = require("../utils");
28
29
  function Router(deps) {
29
30
  const { domain, apisRoute, utils, server, httpCodes = {}, makeProfileHook } = deps;
30
31
  const { ucwords, makeParams, makeProfile, outputCSV } = utils;
@@ -91,7 +92,7 @@ function Router(deps) {
91
92
  throw Error(`Missing domain method: ${methodPath}`);
92
93
  }
93
94
  const send = async (res, results, isEventStream = false) => {
94
- if (typeof results === "object" && "pipe" in results) {
95
+ if ((0, utils_1.isStream)(results)) {
95
96
  if (isEventStream) {
96
97
  res.setHeader("Content-Type", "text/event-stream");
97
98
  await new Promise((resolve) => {
@@ -101,4 +101,9 @@ export declare const waitFor: (test: () => boolean, intervalMS?: number) => Prom
101
101
  * @param files 读取到的文件路径存放地址
102
102
  */
103
103
  export declare const deepReaddir: (dir: string, exts: Set<string>, excludes?: Set<string>, files?: string[]) => string[];
104
+ /**
105
+ * 判断某个值是否为一个流
106
+ * @param stream 要判断的对象
107
+ */
108
+ export declare const isStream: (stream: any) => any;
104
109
  export {};
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
22
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.deepReaddir = exports.waitFor = exports.modifiyURL = exports.modifyURL = exports.inExpired = exports.tryCatchLog = exports.deepFreeze = exports.sleep = exports.lcfirst = exports.ucfirst = exports.nt2space = exports.randStr = exports.md5 = void 0;
25
+ exports.isStream = exports.deepReaddir = exports.waitFor = exports.modifiyURL = exports.modifyURL = exports.inExpired = exports.tryCatchLog = exports.deepFreeze = exports.sleep = exports.lcfirst = exports.ucfirst = exports.nt2space = exports.randStr = exports.md5 = void 0;
26
26
  const async_1 = __importDefault(require("async"));
27
27
  const crypto = __importStar(require("crypto"));
28
28
  const fs_1 = __importDefault(require("fs"));
@@ -205,3 +205,9 @@ const deepReaddir = (dir, exts, excludes = new Set(), files = []) => {
205
205
  return files;
206
206
  };
207
207
  exports.deepReaddir = deepReaddir;
208
+ /**
209
+ * 判断某个值是否为一个流
210
+ * @param stream 要判断的对象
211
+ */
212
+ const isStream = (stream) => stream && typeof stream === "object" && typeof stream.pipe === "function";
213
+ exports.isStream = isStream;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domain.js/main",
3
- "version": "0.6.2",
3
+ "version": "0.6.5",
4
4
  "description": "DDD framework",
5
5
  "main": "dist/index.js",
6
6
  "bin": {