@faasjs/http 0.0.2-beta.392 → 0.0.2-beta.395

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/README.md CHANGED
@@ -20,7 +20,7 @@ FaasJS's http plugin.
20
20
  - [Session](classes/Session.md)
21
21
  - [Validator](classes/Validator.md)
22
22
 
23
- ### Type aliases
23
+ ### Type Aliases
24
24
 
25
25
  - [CookieOptions](#cookieoptions)
26
26
  - [HttpConfig](#httpconfig)
@@ -38,7 +38,7 @@ FaasJS's http plugin.
38
38
 
39
39
  - [useHttp](#usehttp)
40
40
 
41
- ## Type aliases
41
+ ## Type Aliases
42
42
 
43
43
  ### CookieOptions
44
44
 
@@ -165,9 +165,9 @@ ___
165
165
 
166
166
  | Name | Type |
167
167
  | :------ | :------ |
168
+ | `onError?` | (`type`: `string`, `key`: `string` \| `string`[], `value?`: `any`) => { `message`: `any` ; `statusCode?`: `number` } \| `void` |
168
169
  | `rules` | { [k in keyof Content]?: ValidatorRuleOptions } |
169
170
  | `whitelist?` | ``"error"`` \| ``"ignore"`` |
170
- | `onError?` | (`type`: `string`, `key`: `string` \| `string`[], `value?`: `any`) => `void` \| { `message`: `any` ; `statusCode?`: `number` } |
171
171
 
172
172
  ___
173
173
 
package/dist/index.js CHANGED
@@ -1,24 +1,8 @@
1
+ "use strict";
1
2
  var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
- var __spreadValues = (a, b) => {
11
- for (var prop in b || (b = {}))
12
- if (__hasOwnProp.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- if (__getOwnPropSymbols)
15
- for (var prop of __getOwnPropSymbols(b)) {
16
- if (__propIsEnum.call(b, prop))
17
- __defNormalProp(a, prop, b[prop]);
18
- }
19
- return a;
20
- };
21
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
6
  var __export = (target, all) => {
23
7
  for (var name in all)
24
8
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -66,9 +50,10 @@ function deepMerge(...sources) {
66
50
  val = deepMerge(acc[key], value);
67
51
  else
68
52
  val = value;
69
- acc = __spreadProps(__spreadValues({}, acc), {
53
+ acc = {
54
+ ...acc,
70
55
  [key]: val
71
- });
56
+ };
72
57
  }
73
58
  return acc;
74
59
  }
@@ -451,26 +436,16 @@ var Http = class {
451
436
  this.logger.debug("[onInvoke] Cookie: %j", this.cookie.content);
452
437
  this.logger.debug("[onInvoke] Session: %j", this.session.content);
453
438
  }
454
- if (this.validator) {
455
- this.logger.debug("[onInvoke] Valid request");
456
- try {
439
+ try {
440
+ if (this.validator) {
441
+ this.logger.debug("[onInvoke] Valid request");
457
442
  await this.validator.valid({
458
443
  headers: this.headers,
459
444
  params: this.params,
460
445
  cookie: this.cookie,
461
446
  session: this.session
462
447
  });
463
- } catch (error) {
464
- this.logger.error(error);
465
- data.response = {
466
- statusCode: error.statusCode || 500,
467
- headers: { "Content-Type": "application/json; charset=utf-8" },
468
- body: JSON.stringify({ error: { message: error.message } })
469
- };
470
- return;
471
448
  }
472
- }
473
- try {
474
449
  await next();
475
450
  } catch (error) {
476
451
  data.response = error;
package/dist/index.mjs CHANGED
@@ -1,22 +1,4 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1
+ "use strict";
20
2
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
21
3
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
22
4
  }) : x)(function(x) {
@@ -49,9 +31,10 @@ function deepMerge(...sources) {
49
31
  val = deepMerge(acc[key], value);
50
32
  else
51
33
  val = value;
52
- acc = __spreadProps(__spreadValues({}, acc), {
34
+ acc = {
35
+ ...acc,
53
36
  [key]: val
54
- });
37
+ };
55
38
  }
56
39
  return acc;
57
40
  }
@@ -444,26 +427,16 @@ var Http = class {
444
427
  this.logger.debug("[onInvoke] Cookie: %j", this.cookie.content);
445
428
  this.logger.debug("[onInvoke] Session: %j", this.session.content);
446
429
  }
447
- if (this.validator) {
448
- this.logger.debug("[onInvoke] Valid request");
449
- try {
430
+ try {
431
+ if (this.validator) {
432
+ this.logger.debug("[onInvoke] Valid request");
450
433
  await this.validator.valid({
451
434
  headers: this.headers,
452
435
  params: this.params,
453
436
  cookie: this.cookie,
454
437
  session: this.session
455
438
  });
456
- } catch (error) {
457
- this.logger.error(error);
458
- data.response = {
459
- statusCode: error.statusCode || 500,
460
- headers: { "Content-Type": "application/json; charset=utf-8" },
461
- body: JSON.stringify({ error: { message: error.message } })
462
- };
463
- return;
464
439
  }
465
- }
466
- try {
467
440
  await next();
468
441
  } catch (error) {
469
442
  data.response = error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/http",
3
- "version": "0.0.2-beta.392",
3
+ "version": "0.0.2-beta.395",
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.392",
26
- "@faasjs/logger": "^0.0.2-beta.392"
25
+ "@faasjs/func": "^0.0.2-beta.395",
26
+ "@faasjs/logger": "^0.0.2-beta.395"
27
27
  },
28
28
  "devDependencies": {
29
29
  "tsup": "*",