@opra/core 0.31.10 → 0.31.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.
@@ -40,12 +40,13 @@ class MultipartIterator extends events_1.EventEmitter {
40
40
  return this._items;
41
41
  }
42
42
  getNext() {
43
- if (this._form.ended)
44
- return Promise.resolve(undefined);
45
- this.resume();
43
+ if (!this._form.ended)
44
+ this.resume();
46
45
  return new Promise((resolve, reject) => {
47
46
  if (this._stack.length)
48
47
  return resolve(this._stack.shift());
48
+ if (this._form.ended)
49
+ return resolve(undefined);
49
50
  this.once('item', () => resolve(this._stack.shift()));
50
51
  this.once('error', (e) => reject(e));
51
52
  });
@@ -88,14 +88,15 @@ class HttpAdapterHost extends platform_adapter_host_js_1.PlatformAdapterHost {
88
88
  catch (e) {
89
89
  if (e instanceof common_1.OpraException)
90
90
  throw e;
91
- if (e instanceof vg.ValidationError) {
92
- throw new common_1.BadRequestError({
93
- message: e.issues.length === 1 ? e.message : (0, common_1.translate)('error:REQUEST_VALIDATION,'),
94
- code: 'REQUEST_VALIDATION',
95
- details: e.issues
96
- }, e);
97
- }
98
- throw new common_1.BadRequestError(e);
91
+ const errors = e.issues.map(issue => new common_1.BadRequestError({
92
+ message: issue.message,
93
+ code: 'REQUEST_VALIDATION',
94
+ details: {
95
+ ...issue,
96
+ message: undefined
97
+ }
98
+ }));
99
+ return this.sendErrorResponse(executionContext, errors);
99
100
  }
100
101
  try {
101
102
  const { outgoing } = executionContext.switchToHttp();
@@ -36,12 +36,13 @@ export class MultipartIterator extends EventEmitter {
36
36
  return this._items;
37
37
  }
38
38
  getNext() {
39
- if (this._form.ended)
40
- return Promise.resolve(undefined);
41
- this.resume();
39
+ if (!this._form.ended)
40
+ this.resume();
42
41
  return new Promise((resolve, reject) => {
43
42
  if (this._stack.length)
44
43
  return resolve(this._stack.shift());
44
+ if (this._form.ended)
45
+ return resolve(undefined);
45
46
  this.once('item', () => resolve(this._stack.shift()));
46
47
  this.once('error', (e) => reject(e));
47
48
  });
@@ -84,14 +84,15 @@ export class HttpAdapterHost extends PlatformAdapterHost {
84
84
  catch (e) {
85
85
  if (e instanceof OpraException)
86
86
  throw e;
87
- if (e instanceof vg.ValidationError) {
88
- throw new BadRequestError({
89
- message: e.issues.length === 1 ? e.message : translate('error:REQUEST_VALIDATION,'),
90
- code: 'REQUEST_VALIDATION',
91
- details: e.issues
92
- }, e);
93
- }
94
- throw new BadRequestError(e);
87
+ const errors = e.issues.map(issue => new BadRequestError({
88
+ message: issue.message,
89
+ code: 'REQUEST_VALIDATION',
90
+ details: {
91
+ ...issue,
92
+ message: undefined
93
+ }
94
+ }));
95
+ return this.sendErrorResponse(executionContext, errors);
95
96
  }
96
97
  try {
97
98
  const { outgoing } = executionContext.switchToHttp();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/core",
3
- "version": "0.31.10",
3
+ "version": "0.31.12",
4
4
  "description": "Opra schema package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@browsery/type-is": "^0.6.3",
32
- "@opra/common": "^0.31.10",
32
+ "@opra/common": "^0.31.12",
33
33
  "accepts": "^1.3.8",
34
34
  "content-disposition": "^0.5.4",
35
35
  "content-type": "^1.0.5",
@@ -54,7 +54,7 @@
54
54
  "@types/accepts": "^1.3.7",
55
55
  "@types/content-disposition": "^0.5.8",
56
56
  "@types/content-type": "^1.1.8",
57
- "@types/cookie": "^0.5.4",
57
+ "@types/cookie": "^0.6.0",
58
58
  "@types/cookie-signature": "^1.1.2",
59
59
  "@types/encodeurl": "^1.0.2",
60
60
  "@types/express": "^4.17.21",