@faasjs/http 0.0.2-beta.384 → 0.0.2-beta.387

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/dist/index.js CHANGED
@@ -19,24 +19,19 @@ var __spreadValues = (a, b) => {
19
19
  return a;
20
20
  };
21
21
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
23
22
  var __export = (target, all) => {
24
23
  for (var name in all)
25
24
  __defProp(target, name, { get: all[name], enumerable: true });
26
25
  };
27
- var __reExport = (target, module2, copyDefault, desc) => {
28
- if (module2 && typeof module2 === "object" || typeof module2 === "function") {
29
- for (let key of __getOwnPropNames(module2))
30
- if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
31
- __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
26
+ var __copyProps = (to, from, except, desc) => {
27
+ if (from && typeof from === "object" || typeof from === "function") {
28
+ for (let key of __getOwnPropNames(from))
29
+ if (!__hasOwnProp.call(to, key) && key !== except)
30
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
32
31
  }
33
- return target;
32
+ return to;
34
33
  };
35
- var __toCommonJS = /* @__PURE__ */ ((cache) => {
36
- return (module2, temp) => {
37
- return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
38
- };
39
- })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
34
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
40
35
 
41
36
  // src/index.ts
42
37
  var src_exports = {};
@@ -49,6 +44,7 @@ __export(src_exports, {
49
44
  Validator: () => Validator,
50
45
  useHttp: () => useHttp
51
46
  });
47
+ module.exports = __toCommonJS(src_exports);
52
48
  var import_func = require("@faasjs/func");
53
49
 
54
50
  // ../deep_merge/src/index.ts
@@ -327,7 +323,6 @@ var Validator = class {
327
323
  }
328
324
  if (rule.regexp && (rule.type === "string" || !rule.type) && !rule.regexp.test(value)) {
329
325
  const error = Error(`[${type}] ${baseKey}${key} must match ${rule.regexp}.`);
330
- console.log("--------->22222");
331
326
  if (config.onError) {
332
327
  const res = config.onError(`${type}.rule.regexp`, `${baseKey}${key}`, value);
333
328
  if (res)
@@ -500,7 +495,9 @@ var Http = class {
500
495
  "Content-Type": "application/json; charset=utf-8",
501
496
  "Cache-Control": "no-cache, no-store"
502
497
  }, this.cookie.headers(), this.response.headers);
503
- data.response = this.response;
498
+ data.response = __spreadValues(__spreadValues({}, data.response), this.response);
499
+ const originBody = data.response.body;
500
+ data.response.originBody = originBody;
504
501
  if (process.env.FaasMode === "local") {
505
502
  this.logger.debug("[onInvoke] Response: %j", data.response);
506
503
  return;
@@ -510,7 +507,6 @@ var Http = class {
510
507
  const acceptEncoding = this.headers["accept-encoding"] || this.headers["Accept-Encoding"];
511
508
  if (!acceptEncoding || !/(br|gzip|deflate)/.test(acceptEncoding))
512
509
  return;
513
- const originBody = data.response.body;
514
510
  try {
515
511
  if (acceptEncoding.includes("br")) {
516
512
  data.response.headers["Content-Encoding"] = "br";
@@ -524,7 +520,6 @@ var Http = class {
524
520
  } else
525
521
  throw Error("No matched compression.");
526
522
  data.response.isBase64Encoded = true;
527
- data.response.originBody = originBody;
528
523
  } catch (error) {
529
524
  console.error(error);
530
525
  data.response.body = originBody;
@@ -554,7 +549,6 @@ var Http = class {
554
549
  function useHttp(config) {
555
550
  return (0, import_func.usePlugin)(new Http(config));
556
551
  }
557
- module.exports = __toCommonJS(src_exports);
558
552
  // Annotate the CommonJS export names for ESM import in node:
559
553
  0 && (module.exports = {
560
554
  ContentType,
package/dist/index.mjs CHANGED
@@ -312,7 +312,6 @@ var Validator = class {
312
312
  }
313
313
  if (rule.regexp && (rule.type === "string" || !rule.type) && !rule.regexp.test(value)) {
314
314
  const error = Error(`[${type}] ${baseKey}${key} must match ${rule.regexp}.`);
315
- console.log("--------->22222");
316
315
  if (config.onError) {
317
316
  const res = config.onError(`${type}.rule.regexp`, `${baseKey}${key}`, value);
318
317
  if (res)
@@ -489,7 +488,9 @@ var Http = class {
489
488
  "Content-Type": "application/json; charset=utf-8",
490
489
  "Cache-Control": "no-cache, no-store"
491
490
  }, this.cookie.headers(), this.response.headers);
492
- data.response = this.response;
491
+ data.response = __spreadValues(__spreadValues({}, data.response), this.response);
492
+ const originBody = data.response.body;
493
+ data.response.originBody = originBody;
493
494
  if (process.env.FaasMode === "local") {
494
495
  this.logger.debug("[onInvoke] Response: %j", data.response);
495
496
  return;
@@ -499,7 +500,6 @@ var Http = class {
499
500
  const acceptEncoding = this.headers["accept-encoding"] || this.headers["Accept-Encoding"];
500
501
  if (!acceptEncoding || !/(br|gzip|deflate)/.test(acceptEncoding))
501
502
  return;
502
- const originBody = data.response.body;
503
503
  try {
504
504
  if (acceptEncoding.includes("br")) {
505
505
  data.response.headers["Content-Encoding"] = "br";
@@ -513,7 +513,6 @@ var Http = class {
513
513
  } else
514
514
  throw Error("No matched compression.");
515
515
  data.response.isBase64Encoded = true;
516
- data.response.originBody = originBody;
517
516
  } catch (error) {
518
517
  console.error(error);
519
518
  data.response.body = originBody;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/http",
3
- "version": "0.0.2-beta.384",
3
+ "version": "0.0.2-beta.387",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -22,8 +22,8 @@
22
22
  "dist"
23
23
  ],
24
24
  "peerDependencies": {
25
- "@faasjs/func": "^0.0.2-beta.384",
26
- "@faasjs/logger": "^0.0.2-beta.384"
25
+ "@faasjs/func": "^0.0.2-beta.387",
26
+ "@faasjs/logger": "^0.0.2-beta.387"
27
27
  },
28
28
  "devDependencies": {
29
29
  "tsup": "*",