@loopback/rest 5.1.0 → 5.2.1

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.
Files changed (107) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/body-parsers/body-parser.d.ts +1 -1
  3. package/dist/body-parsers/body-parser.js +112 -115
  4. package/dist/body-parsers/body-parser.js.map +1 -1
  5. package/dist/body-parsers/body-parser.json.js +24 -27
  6. package/dist/body-parsers/body-parser.json.js.map +1 -1
  7. package/dist/body-parsers/body-parser.raw.js +19 -22
  8. package/dist/body-parsers/body-parser.raw.js.map +1 -1
  9. package/dist/body-parsers/body-parser.text.js +21 -24
  10. package/dist/body-parsers/body-parser.text.js.map +1 -1
  11. package/dist/body-parsers/body-parser.urlencoded.js +19 -22
  12. package/dist/body-parsers/body-parser.urlencoded.js.map +1 -1
  13. package/dist/coercion/coerce-parameter.d.ts +3 -1
  14. package/dist/coercion/coerce-parameter.js +28 -12
  15. package/dist/coercion/coerce-parameter.js.map +1 -1
  16. package/dist/http-handler.d.ts +1 -1
  17. package/dist/index.d.ts +1 -0
  18. package/dist/index.js +2 -0
  19. package/dist/index.js.map +1 -1
  20. package/dist/keys.d.ts +1 -1
  21. package/dist/keys.js +33 -34
  22. package/dist/keys.js.map +1 -1
  23. package/dist/parser.js +1 -1
  24. package/dist/parser.js.map +1 -1
  25. package/dist/providers/find-route.provider.d.ts +1 -1
  26. package/dist/providers/find-route.provider.js +21 -24
  27. package/dist/providers/find-route.provider.js.map +1 -1
  28. package/dist/providers/invoke-method.provider.d.ts +1 -1
  29. package/dist/providers/invoke-method.provider.js +16 -19
  30. package/dist/providers/invoke-method.provider.js.map +1 -1
  31. package/dist/providers/log-error.provider.d.ts +1 -1
  32. package/dist/providers/parse-params.provider.d.ts +1 -1
  33. package/dist/providers/parse-params.provider.js +20 -23
  34. package/dist/providers/parse-params.provider.js.map +1 -1
  35. package/dist/providers/reject.provider.d.ts +1 -1
  36. package/dist/providers/reject.provider.js +25 -28
  37. package/dist/providers/reject.provider.js.map +1 -1
  38. package/dist/providers/send.provider.d.ts +1 -1
  39. package/dist/request-context.d.ts +1 -1
  40. package/dist/rest.application.d.ts +1 -2
  41. package/dist/rest.application.js.map +1 -1
  42. package/dist/rest.component.d.ts +1 -1
  43. package/dist/rest.component.js +46 -49
  44. package/dist/rest.component.js.map +1 -1
  45. package/dist/rest.server.d.ts +1 -2
  46. package/dist/rest.server.js +618 -621
  47. package/dist/rest.server.js.map +1 -1
  48. package/dist/router/base-route.d.ts +1 -1
  49. package/dist/router/controller-route.d.ts +1 -1
  50. package/dist/router/controller-route.js +3 -4
  51. package/dist/router/controller-route.js.map +1 -1
  52. package/dist/router/handler-route.d.ts +1 -1
  53. package/dist/router/handler-route.js +2 -2
  54. package/dist/router/handler-route.js.map +1 -1
  55. package/dist/router/redirect-route.js +2 -2
  56. package/dist/router/redirect-route.js.map +1 -1
  57. package/dist/router/regexp-router.js +55 -58
  58. package/dist/router/regexp-router.js.map +1 -1
  59. package/dist/router/route-entry.d.ts +1 -1
  60. package/dist/router/trie-router.js +31 -34
  61. package/dist/router/trie-router.js.map +1 -1
  62. package/dist/sequence.d.ts +1 -1
  63. package/dist/sequence.js +74 -77
  64. package/dist/sequence.js.map +1 -1
  65. package/dist/spec-enhancers/consolidate.spec-enhancer.js +89 -92
  66. package/dist/spec-enhancers/consolidate.spec-enhancer.js.map +1 -1
  67. package/dist/spec-enhancers/info.spec-enhancer.js +63 -67
  68. package/dist/spec-enhancers/info.spec-enhancer.js.map +1 -1
  69. package/dist/types.d.ts +10 -0
  70. package/dist/validation/ajv-factory.provider.js +63 -66
  71. package/dist/validation/ajv-factory.provider.js.map +1 -1
  72. package/dist/validation/request-body.validator.d.ts +10 -2
  73. package/dist/validation/request-body.validator.js +25 -9
  74. package/dist/validation/request-body.validator.js.map +1 -1
  75. package/package.json +29 -27
  76. package/src/body-parsers/body-parser.json.ts +1 -1
  77. package/src/body-parsers/body-parser.raw.ts +1 -1
  78. package/src/body-parsers/body-parser.text.ts +1 -1
  79. package/src/body-parsers/body-parser.ts +1 -1
  80. package/src/body-parsers/body-parser.urlencoded.ts +1 -1
  81. package/src/coercion/coerce-parameter.ts +55 -15
  82. package/src/http-handler.ts +1 -1
  83. package/src/index.ts +6 -0
  84. package/src/keys.ts +1 -2
  85. package/src/parser.ts +1 -1
  86. package/src/providers/find-route.provider.ts +1 -1
  87. package/src/providers/invoke-method.provider.ts +1 -1
  88. package/src/providers/log-error.provider.ts +1 -1
  89. package/src/providers/parse-params.provider.ts +1 -1
  90. package/src/providers/reject.provider.ts +1 -1
  91. package/src/providers/send.provider.ts +1 -1
  92. package/src/request-context.ts +1 -1
  93. package/src/rest.application.ts +4 -2
  94. package/src/rest.component.ts +1 -1
  95. package/src/rest.server.ts +5 -3
  96. package/src/router/base-route.ts +1 -1
  97. package/src/router/controller-route.ts +2 -2
  98. package/src/router/external-express-routes.ts +1 -1
  99. package/src/router/handler-route.ts +1 -1
  100. package/src/router/redirect-route.ts +1 -2
  101. package/src/router/regexp-router.ts +1 -1
  102. package/src/router/route-entry.ts +1 -1
  103. package/src/router/trie-router.ts +1 -1
  104. package/src/sequence.ts +1 -1
  105. package/src/spec-enhancers/info.spec-enhancer.ts +3 -2
  106. package/src/types.ts +11 -0
  107. package/src/validation/request-body.validator.ts +35 -12
package/CHANGELOG.md CHANGED
@@ -3,6 +3,55 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [5.2.1](https://github.com/strongloop/loopback-next/compare/@loopback/rest@5.2.0...@loopback/rest@5.2.1) (2020-07-20)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * ensure delete only applies to optional properties ([89cd43f](https://github.com/strongloop/loopback-next/commit/89cd43f1a455983f120d9bb9c869eac36adc7ad7))
12
+ * nested scope filter ([b29d6d7](https://github.com/strongloop/loopback-next/commit/b29d6d7938b0d07e927b0939745b76cfff91272b))
13
+ * **repository-json-schema:** added type 'object' to model json schema ([5c5f9ef](https://github.com/strongloop/loopback-next/commit/5c5f9efcfdea7788503d74610e7ce64f31abc7cd)), closes [#3804](https://github.com/strongloop/loopback-next/issues/3804)
14
+
15
+
16
+
17
+
18
+
19
+ # [5.2.0](https://github.com/strongloop/loopback-next/compare/@loopback/rest@5.1.2...@loopback/rest@5.2.0) (2020-06-30)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * **rest:** fix typing to be compatible with latest @types/js-yaml ([5ac39e4](https://github.com/strongloop/loopback-next/commit/5ac39e44827ef74c9d2bccb1797a9da125c249e3))
25
+
26
+
27
+ ### Features
28
+
29
+ * coerce query object with schema ([ccea25f](https://github.com/strongloop/loopback-next/commit/ccea25fc382457f9436adfc0d8f6ce3a2d029c5e))
30
+ * **rest:** expose types from strong-error-handler ([b6f5595](https://github.com/strongloop/loopback-next/commit/b6f559549518c839a2898f1b968fc6a7901a6c6b))
31
+
32
+
33
+
34
+
35
+
36
+ ## [5.1.2](https://github.com/strongloop/loopback-next/compare/@loopback/rest@5.1.1...@loopback/rest@5.1.2) (2020-06-23)
37
+
38
+
39
+ ### Bug Fixes
40
+
41
+ * set node version to >=10.16 to support events.once ([e39da1c](https://github.com/strongloop/loopback-next/commit/e39da1ca47728eafaf83c10ce35b09b03b6a4edc))
42
+
43
+
44
+
45
+
46
+
47
+ ## [5.1.1](https://github.com/strongloop/loopback-next/compare/@loopback/rest@5.1.0...@loopback/rest@5.1.1) (2020-06-11)
48
+
49
+ **Note:** Version bump only for package @loopback/rest
50
+
51
+
52
+
53
+
54
+
6
55
  # [5.1.0](https://github.com/strongloop/loopback-next/compare/@loopback/rest@5.0.1...@loopback/rest@5.1.0) (2020-05-28)
7
56
 
8
57
 
@@ -1,4 +1,4 @@
1
- import { Context } from '@loopback/context';
1
+ import { Context } from '@loopback/core';
2
2
  import { OperationObject } from '@loopback/openapi-v3';
3
3
  import { Request } from '../types';
4
4
  import { BodyParser, RequestBody } from './types';
@@ -6,7 +6,7 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.RequestBodyParser = void 0;
8
8
  const tslib_1 = require("tslib");
9
- const context_1 = require("@loopback/context");
9
+ const core_1 = require("@loopback/core");
10
10
  const openapi_v3_1 = require("@loopback/openapi-v3");
11
11
  const debug_1 = tslib_1.__importDefault(require("debug"));
12
12
  const type_is_1 = require("type-is");
@@ -14,133 +14,130 @@ const rest_http_error_1 = require("../rest-http-error");
14
14
  const body_parser_helpers_1 = require("./body-parser.helpers");
15
15
  const types_1 = require("./types");
16
16
  const debug = debug_1.default('loopback:rest:body-parser');
17
- let RequestBodyParser = /** @class */ (() => {
18
- let RequestBodyParser = class RequestBodyParser {
19
- constructor(parsers, ctx) {
20
- this.ctx = ctx;
21
- this.parsers = sortParsers(parsers !== null && parsers !== void 0 ? parsers : []);
22
- if (debug.enabled) {
23
- debug('Body parsers: ', this.parsers.map(p => p.name));
24
- }
17
+ let RequestBodyParser = class RequestBodyParser {
18
+ constructor(parsers, ctx) {
19
+ this.ctx = ctx;
20
+ this.parsers = sortParsers(parsers !== null && parsers !== void 0 ? parsers : []);
21
+ if (debug.enabled) {
22
+ debug('Body parsers: ', this.parsers.map(p => p.name));
25
23
  }
26
- async loadRequestBodyIfNeeded(operationSpec, request) {
27
- const { requestBody, customParser } = await this._matchRequestBodySpec(operationSpec, request);
28
- if (!operationSpec.requestBody)
29
- return requestBody;
30
- const matchedMediaType = requestBody.mediaType;
31
- try {
32
- if (customParser) {
33
- // Invoke the custom parser
34
- const body = await this._invokeCustomParser(customParser, request);
24
+ }
25
+ async loadRequestBodyIfNeeded(operationSpec, request) {
26
+ const { requestBody, customParser } = await this._matchRequestBodySpec(operationSpec, request);
27
+ if (!operationSpec.requestBody)
28
+ return requestBody;
29
+ const matchedMediaType = requestBody.mediaType;
30
+ try {
31
+ if (customParser) {
32
+ // Invoke the custom parser
33
+ const body = await this._invokeCustomParser(customParser, request);
34
+ return Object.assign(requestBody, body);
35
+ }
36
+ else {
37
+ const parser = this._findParser(matchedMediaType);
38
+ if (parser) {
39
+ const body = await parser.parse(request);
35
40
  return Object.assign(requestBody, body);
36
41
  }
37
- else {
38
- const parser = this._findParser(matchedMediaType);
39
- if (parser) {
40
- const body = await parser.parse(request);
41
- return Object.assign(requestBody, body);
42
- }
43
- }
44
- }
45
- catch (err) {
46
- throw body_parser_helpers_1.normalizeParsingError(err);
47
42
  }
48
- throw rest_http_error_1.RestHttpErrors.unsupportedMediaType(matchedMediaType);
49
43
  }
50
- /**
51
- * Match the http request to a given media type of the request body spec
52
- */
53
- async _matchRequestBodySpec(operationSpec, request) {
54
- var _a;
55
- const requestBody = {
56
- value: undefined,
44
+ catch (err) {
45
+ throw body_parser_helpers_1.normalizeParsingError(err);
46
+ }
47
+ throw rest_http_error_1.RestHttpErrors.unsupportedMediaType(matchedMediaType);
48
+ }
49
+ /**
50
+ * Match the http request to a given media type of the request body spec
51
+ */
52
+ async _matchRequestBodySpec(operationSpec, request) {
53
+ var _a;
54
+ const requestBody = {
55
+ value: undefined,
56
+ };
57
+ if (!operationSpec.requestBody)
58
+ return { requestBody };
59
+ const contentType = (_a = body_parser_helpers_1.getContentType(request)) !== null && _a !== void 0 ? _a : 'application/json';
60
+ debug('Loading request body with content type %j', contentType);
61
+ // the type of `operationSpec.requestBody` could be `RequestBodyObject`
62
+ // or `ReferenceObject`, resolving a `$ref` value is not supported yet.
63
+ if (openapi_v3_1.isReferenceObject(operationSpec.requestBody)) {
64
+ throw new Error('$ref requestBody is not supported yet.');
65
+ }
66
+ let content = operationSpec.requestBody.content || {};
67
+ if (!Object.keys(content).length) {
68
+ content = {
69
+ // default to allow json and urlencoded
70
+ 'application/json': { schema: { type: 'object' } },
71
+ 'application/x-www-form-urlencoded': { schema: { type: 'object' } },
57
72
  };
58
- if (!operationSpec.requestBody)
59
- return { requestBody };
60
- const contentType = (_a = body_parser_helpers_1.getContentType(request)) !== null && _a !== void 0 ? _a : 'application/json';
61
- debug('Loading request body with content type %j', contentType);
62
- // the type of `operationSpec.requestBody` could be `RequestBodyObject`
63
- // or `ReferenceObject`, resolving a `$ref` value is not supported yet.
64
- if (openapi_v3_1.isReferenceObject(operationSpec.requestBody)) {
65
- throw new Error('$ref requestBody is not supported yet.');
66
- }
67
- let content = operationSpec.requestBody.content || {};
68
- if (!Object.keys(content).length) {
69
- content = {
70
- // default to allow json and urlencoded
71
- 'application/json': { schema: { type: 'object' } },
72
- 'application/x-www-form-urlencoded': { schema: { type: 'object' } },
73
- };
74
- }
75
- // Check of the request content type matches one of the expected media
76
- // types in the request body spec
77
- let matchedMediaType = false;
78
- let customParser = undefined;
79
- for (const type in content) {
80
- matchedMediaType = type_is_1.is(contentType, type);
81
- if (matchedMediaType) {
82
- debug('Matched media type: %s -> %s', type, contentType);
83
- requestBody.mediaType = contentType;
84
- requestBody.schema = content[type].schema;
85
- customParser = content[type]['x-parser'];
86
- break;
87
- }
73
+ }
74
+ // Check of the request content type matches one of the expected media
75
+ // types in the request body spec
76
+ let matchedMediaType = false;
77
+ let customParser = undefined;
78
+ for (const type in content) {
79
+ matchedMediaType = type_is_1.is(contentType, type);
80
+ if (matchedMediaType) {
81
+ debug('Matched media type: %s -> %s', type, contentType);
82
+ requestBody.mediaType = contentType;
83
+ requestBody.schema = content[type].schema;
84
+ customParser = content[type]['x-parser'];
85
+ break;
88
86
  }
89
- if (!matchedMediaType) {
90
- // No matching media type found, fail fast
91
- throw rest_http_error_1.RestHttpErrors.unsupportedMediaType(contentType, Object.keys(content));
87
+ }
88
+ if (!matchedMediaType) {
89
+ // No matching media type found, fail fast
90
+ throw rest_http_error_1.RestHttpErrors.unsupportedMediaType(contentType, Object.keys(content));
91
+ }
92
+ return { requestBody, customParser };
93
+ }
94
+ /**
95
+ * Find a body parser that supports the media type
96
+ * @param matchedMediaType - Media type
97
+ */
98
+ _findParser(matchedMediaType) {
99
+ for (const parser of this.parsers) {
100
+ if (!parser.supports(matchedMediaType)) {
101
+ debug('Body parser %s does not support %s', parser.name, matchedMediaType);
102
+ continue;
92
103
  }
93
- return { requestBody, customParser };
104
+ debug('Body parser %s found for %s', parser.name, matchedMediaType);
105
+ return parser;
94
106
  }
95
- /**
96
- * Find a body parser that supports the media type
97
- * @param matchedMediaType - Media type
98
- */
99
- _findParser(matchedMediaType) {
100
- for (const parser of this.parsers) {
101
- if (!parser.supports(matchedMediaType)) {
102
- debug('Body parser %s does not support %s', parser.name, matchedMediaType);
103
- continue;
104
- }
105
- debug('Body parser %s found for %s', parser.name, matchedMediaType);
106
- return parser;
107
+ }
108
+ /**
109
+ * Resolve and invoke a custom parser
110
+ * @param customParser - The parser name, class or function
111
+ * @param request - Http request
112
+ */
113
+ async _invokeCustomParser(customParser, request) {
114
+ if (typeof customParser === 'string') {
115
+ const parser = this.parsers.find(p => p.name === customParser ||
116
+ p.name === body_parser_helpers_1.builtinParsers.mapping[customParser]);
117
+ if (parser) {
118
+ debug('Using custom parser %s', customParser);
119
+ return parser.parse(request);
107
120
  }
108
121
  }
109
- /**
110
- * Resolve and invoke a custom parser
111
- * @param customParser - The parser name, class or function
112
- * @param request - Http request
113
- */
114
- async _invokeCustomParser(customParser, request) {
115
- if (typeof customParser === 'string') {
116
- const parser = this.parsers.find(p => p.name === customParser ||
117
- p.name === body_parser_helpers_1.builtinParsers.mapping[customParser]);
118
- if (parser) {
119
- debug('Using custom parser %s', customParser);
120
- return parser.parse(request);
121
- }
122
+ else if (typeof customParser === 'function') {
123
+ if (isBodyParserClass(customParser)) {
124
+ debug('Using custom parser class %s', customParser.name);
125
+ const parser = await core_1.instantiateClass(customParser, this.ctx);
126
+ return parser.parse(request);
122
127
  }
123
- else if (typeof customParser === 'function') {
124
- if (isBodyParserClass(customParser)) {
125
- debug('Using custom parser class %s', customParser.name);
126
- const parser = await context_1.instantiateClass(customParser, this.ctx);
127
- return parser.parse(request);
128
- }
129
- else {
130
- debug('Using custom parser function %s', customParser.name);
131
- return customParser(request);
132
- }
128
+ else {
129
+ debug('Using custom parser function %s', customParser.name);
130
+ return customParser(request);
133
131
  }
134
- throw new Error('Custom parser not found: ' + customParser);
135
132
  }
136
- };
137
- RequestBodyParser = tslib_1.__decorate([
138
- tslib_1.__param(0, context_1.inject(context_1.filterByTag(types_1.REQUEST_BODY_PARSER_TAG), { optional: true })),
139
- tslib_1.__param(1, context_1.inject.context()),
140
- tslib_1.__metadata("design:paramtypes", [Array, context_1.Context])
141
- ], RequestBodyParser);
142
- return RequestBodyParser;
143
- })();
133
+ throw new Error('Custom parser not found: ' + customParser);
134
+ }
135
+ };
136
+ RequestBodyParser = tslib_1.__decorate([
137
+ tslib_1.__param(0, core_1.inject(core_1.filterByTag(types_1.REQUEST_BODY_PARSER_TAG), { optional: true })),
138
+ tslib_1.__param(1, core_1.inject.context()),
139
+ tslib_1.__metadata("design:paramtypes", [Array, core_1.Context])
140
+ ], RequestBodyParser);
144
141
  exports.RequestBodyParser = RequestBodyParser;
145
142
  /**
146
143
  * Test if a function is a body parser class or plain function
@@ -154,6 +151,6 @@ function isBodyParserClass(fn) {
154
151
  * @param parsers
155
152
  */
156
153
  function sortParsers(parsers) {
157
- return parsers.sort((a, b) => context_1.compareByOrder(a.name, b.name, body_parser_helpers_1.builtinParsers.names));
154
+ return parsers.sort((a, b) => core_1.compareByOrder(a.name, b.name, body_parser_helpers_1.builtinParsers.names));
158
155
  }
159
156
  //# sourceMappingURL=body-parser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"body-parser.js","sourceRoot":"","sources":["../../src/body-parsers/body-parser.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,+CAO2B;AAC3B,qDAAwE;AACxE,0DAAgC;AAChC,qCAA2B;AAC3B,wDAAkD;AAElD,+DAI+B;AAC/B,mCAKiB;AAEjB,MAAM,KAAK,GAAG,eAAW,CAAC,2BAA2B,CAAC,CAAC;AAEvD;IAAA,IAAa,iBAAiB,GAA9B,MAAa,iB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8
  const tslib_1 = require("tslib");
9
- const context_1 = require("@loopback/context");
9
+ const core_1 = require("@loopback/core");
10
10
  const body_parser_1 = require("body-parser");
11
11
  const type_is_1 = require("type-is");
12
12
  const keys_1 = require("../keys");
13
13
  const body_parser_helpers_1 = require("./body-parser.helpers");
14
14
  const parse_json_1 = require("../parse-json");
15
- let JsonBodyParser = /** @class */ (() => {
16
- let JsonBodyParser = class JsonBodyParser {
17
- constructor(options = {}) {
18
- this.name = body_parser_helpers_1.builtinParsers.json;
19
- const jsonOptions = body_parser_helpers_1.getParserOptions('json', options);
20
- jsonOptions.reviver = parse_json_1.sanitizeJsonParse(jsonOptions.reviver);
21
- this.jsonParser = body_parser_1.json(jsonOptions);
15
+ let JsonBodyParser = class JsonBodyParser {
16
+ constructor(options = {}) {
17
+ this.name = body_parser_helpers_1.builtinParsers.json;
18
+ const jsonOptions = body_parser_helpers_1.getParserOptions('json', options);
19
+ jsonOptions.reviver = parse_json_1.sanitizeJsonParse(jsonOptions.reviver);
20
+ this.jsonParser = body_parser_1.json(jsonOptions);
21
+ }
22
+ supports(mediaType) {
23
+ return !!type_is_1.is(mediaType, '*/json', '*/*+json');
24
+ }
25
+ async parse(request) {
26
+ let body = await body_parser_helpers_1.invokeBodyParserMiddleware(this.jsonParser, request);
27
+ // https://github.com/expressjs/body-parser/blob/master/lib/types/json.js#L71-L76
28
+ const contentLength = request.get('content-length');
29
+ if (contentLength != null && +contentLength === 0) {
30
+ body = undefined;
22
31
  }
23
- supports(mediaType) {
24
- return !!type_is_1.is(mediaType, '*/json', '*/*+json');
25
- }
26
- async parse(request) {
27
- let body = await body_parser_helpers_1.invokeBodyParserMiddleware(this.jsonParser, request);
28
- // https://github.com/expressjs/body-parser/blob/master/lib/types/json.js#L71-L76
29
- const contentLength = request.get('content-length');
30
- if (contentLength != null && +contentLength === 0) {
31
- body = undefined;
32
- }
33
- return { value: body };
34
- }
35
- };
36
- JsonBodyParser = tslib_1.__decorate([
37
- tslib_1.__param(0, context_1.inject(keys_1.RestBindings.REQUEST_BODY_PARSER_OPTIONS, { optional: true })),
38
- tslib_1.__metadata("design:paramtypes", [Object])
39
- ], JsonBodyParser);
40
- return JsonBodyParser;
41
- })();
32
+ return { value: body };
33
+ }
34
+ };
35
+ JsonBodyParser = tslib_1.__decorate([
36
+ tslib_1.__param(0, core_1.inject(keys_1.RestBindings.REQUEST_BODY_PARSER_OPTIONS, { optional: true })),
37
+ tslib_1.__metadata("design:paramtypes", [Object])
38
+ ], JsonBodyParser);
42
39
  exports.JsonBodyParser = JsonBodyParser;
43
40
  //# sourceMappingURL=body-parser.json.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"body-parser.json.js","sourceRoot":"","sources":["../../src/body-parsers/body-parser.json.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,+CAAyC;AACzC,6CAAiC;AACjC,qCAA2B;AAC3B,kCAAqC;AAErC,+DAK+B;AAE/B,8CAAgD;AAEhD;IAAA,IAAa,cAAc,GAA3B,MAAa,cAAc;QAIzB,YAEE,UAAoC,EAAE;YALxC,SAAI,GAAG,oCAAc,CAAC,IAAI,CAAC;YAOzB,MAAM,WAAW,GAAG,sCAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACtD,WAAW,CAAC,OAAO,GAAG,8BAAiB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YAC7D,IAAI,CAAC,UAAU,GAAG,kBAAI,CAAC,WAAW,CAAC,CAAC;QACtC,CAAC;QAED,QAAQ,CAAC,SAAiB;YACxB,OAAO,CAAC,CAAC,YAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;QAC/C,CAAC;QAED,KAAK,CAAC,KAAK,CAAC,OAAgB;YAC1B,IAAI,IAAI,GAAG,MAAM,gDAA0B,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;YACtE,iFAAiF;YACjF,MAAM,a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AAa,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QACpD,IAAI,aAAa,IAAI,IAAI,IAAI,CAAC,aAAa,KAAK,CAAC,EAAE;YACjD,IAAI,GAAG,SAAS,CAAC;SAClB;QACD,OAAO,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC;IACvB,CAAC;CACF,CAAA;AA1BY,cAAc;IAKtB,mBAAA,aAAM,CAAC,mBAAY,CAAC,2BAA2B,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAA;;GAL1D,cAAc,CA0B1B;AA1BY,wCAAc"}
@@ -6,7 +6,7 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.RawBodyParser = void 0;
8
8
  const tslib_1 = require("tslib");
9
- const context_1 = require("@loopback/context");
9
+ const core_1 = require("@loopback/core");
10
10
  const body_parser_1 = require("body-parser");
11
11
  const type_is_1 = require("type-is");
12
12
  const keys_1 = require("../keys");
@@ -14,26 +14,23 @@ const body_parser_helpers_1 = require("./body-parser.helpers");
14
14
  /**
15
15
  * Parsing the request body into Buffer
16
16
  */
17
- let RawBodyParser = /** @class */ (() => {
18
- let RawBodyParser = class RawBodyParser {
19
- constructor(options = {}) {
20
- this.name = body_parser_helpers_1.builtinParsers.raw;
21
- const rawOptions = body_parser_helpers_1.getParserOptions('raw', options);
22
- this.rawParser = body_parser_1.raw(rawOptions);
23
- }
24
- supports(mediaType) {
25
- return !!type_is_1.is(mediaType, 'application/octet-stream');
26
- }
27
- async parse(request) {
28
- const body = await body_parser_helpers_1.invokeBodyParserMiddleware(this.rawParser, request);
29
- return { value: body };
30
- }
31
- };
32
- RawBodyParser = tslib_1.__decorate([
33
- tslib_1.__param(0, context_1.inject(keys_1.RestBindings.REQUEST_BODY_PARSER_OPTIONS, { optional: true })),
34
- tslib_1.__metadata("design:paramtypes", [Object])
35
- ], RawBodyParser);
36
- return RawBodyParser;
37
- })();
17
+ let RawBodyParser = class RawBodyParser {
18
+ constructor(options = {}) {
19
+ this.name = body_parser_helpers_1.builtinParsers.raw;
20
+ const rawOptions = body_parser_helpers_1.getParserOptions('raw', options);
21
+ this.rawParser = body_parser_1.raw(rawOptions);
22
+ }
23
+ supports(mediaType) {
24
+ return !!type_is_1.is(mediaType, 'application/octet-stream');
25
+ }
26
+ async parse(request) {
27
+ const body = await body_parser_helpers_1.invokeBodyParserMiddleware(this.rawParser, request);
28
+ return { value: body };
29
+ }
30
+ };
31
+ RawBodyParser = tslib_1.__decorate([
32
+ tslib_1.__param(0, core_1.inject(keys_1.RestBindings.REQUEST_BODY_PARSER_OPTIONS, { optional: true })),
33
+ tslib_1.__metadata("design:paramtypes", [Object])
34
+ ], RawBodyParser);
38
35
  exports.RawBodyParser = RawBodyParser;
39
36
  //# sourceMappingURL=body-parser.raw.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"body-parser.raw.js","sourceRoot":"","sources":["../../src/body-parsers/body-parser.raw.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,+CAAyC;AACzC,6CAAgC;AAChC,qCAA2B;AAC3B,kCAAqC;AAErC,+DAK+B;AAG/B;;GAEG;AACH;IAAA,IAAa,aAAa,GAA1B,MAAa,aAAa;QAIxB,YAEE,UAAoC,EAAE;YALxC,SAAI,GAAG,oCAAc,CAAC,GAAG,CAAC;YAOxB,MAAM,UAAU,GAAG,sCAAgB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YACpD,IAAI,CAAC,SAAS,GAAG,iBAAG,CAAC,UAAU,CAAC,CAAC;QACnC,CAAC;QAED,QAAQ,CAAC,SAAiB;YACxB,OAAO,CAAC,CAAC,YAAE,CAAC,SAAS,EAAE,0BAA0B,CAAC,CAAC;QACrD,CAAC;QAED,KAAK,CAAC,KAAK,CAAC,OAAgB;YAC1B,MAAM,IAAI,GAAG,MAAM,gDAA0B,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YACvE,OAAO,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC;QACvB,CAAC;KACF,CAAA;IApBY,aAAa;QAKrB,mBAAA,gBAAM,CAAC,mBAAY,CAAC,2BAA2B,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAA;;OAL1D,aAAa,CAoBzB;IAAD,oBAAC;KAAA;AApBY,sCAAa"}
1
+ {"version":3,"file":"body-parser.raw.js","sourceRoot":"","sources":["../../src/body-parsers/body-parser.raw.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,yCAAsC;AACtC,6CAAgC;AAChC,qCAA2B;AAC3B,kCAAqC;AAErC,+DAK+B;AAG/B;;GAEG;AACH,IAAa,aAAa,GAA1B,MAAa,aAAa;IAIxB,YAEE,UAAoC,EAAE;QALxC,SAAI,GAAG,oCAAc,CAAC,GAAG,CAAC;QAOxB,MAAM,UAAU,GAAG,sCAAgB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACpD,IAAI,CAAC,SAAS,GAAG,iBAAG,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC;IAED,QAAQ,CAAC,SAAiB;QACxB,OAAO,CAAC,CAAC,YAAE,CAAC,SAAS,EAAE,0BAA0B,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,OAAgB;QAC1B,MAAM,IAAI,GAAG,MAAM,gDAA0B,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACvE,OAAO,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC;IACvB,CAAC;CACF,CAAA;AApBY,aAAa;IAKrB,mBAAA,aAAM,CAAC,mBAAY,CAAC,2BAA2B,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAA;;GAL1D,aAAa,CAoBzB;AApBY,sCAAa"}
@@ -6,33 +6,30 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.TextBodyParser = void 0;
8
8
  const tslib_1 = require("tslib");
9
- const context_1 = require("@loopback/context");
9
+ const core_1 = require("@loopback/core");
10
10
  const body_parser_1 = require("body-parser");
11
11
  const type_is_1 = require("type-is");
12
12
  const keys_1 = require("../keys");
13
13
  const body_parser_helpers_1 = require("./body-parser.helpers");
14
- let TextBodyParser = /** @class */ (() => {
15
- let TextBodyParser = class TextBodyParser {
16
- constructor(options = {}) {
17
- this.name = body_parser_helpers_1.builtinParsers.text;
18
- const textOptions = Object.assign({ type: 'text/*' }, body_parser_helpers_1.getParserOptions('text', options));
19
- this.textParser = body_parser_1.text(textOptions);
20
- }
21
- supports(mediaType) {
22
- // Please note that `text/*` matches `text/plain` and `text/html` but`text`
23
- // does not.
24
- return !!type_is_1.is(mediaType, 'text/*');
25
- }
26
- async parse(request) {
27
- const body = await body_parser_helpers_1.invokeBodyParserMiddleware(this.textParser, request);
28
- return { value: body };
29
- }
30
- };
31
- TextBodyParser = tslib_1.__decorate([
32
- tslib_1.__param(0, context_1.inject(keys_1.RestBindings.REQUEST_BODY_PARSER_OPTIONS, { optional: true })),
33
- tslib_1.__metadata("design:paramtypes", [Object])
34
- ], TextBodyParser);
35
- return TextBodyParser;
36
- })();
14
+ let TextBodyParser = class TextBodyParser {
15
+ constructor(options = {}) {
16
+ this.name = body_parser_helpers_1.builtinParsers.text;
17
+ const textOptions = Object.assign({ type: 'text/*' }, body_parser_helpers_1.getParserOptions('text', options));
18
+ this.textParser = body_parser_1.text(textOptions);
19
+ }
20
+ supports(mediaType) {
21
+ // Please note that `text/*` matches `text/plain` and `text/html` but`text`
22
+ // does not.
23
+ return !!type_is_1.is(mediaType, 'text/*');
24
+ }
25
+ async parse(request) {
26
+ const body = await body_parser_helpers_1.invokeBodyParserMiddleware(this.textParser, request);
27
+ return { value: body };
28
+ }
29
+ };
30
+ TextBodyParser = tslib_1.__decorate([
31
+ tslib_1.__param(0, core_1.inject(keys_1.RestBindings.REQUEST_BODY_PARSER_OPTIONS, { optional: true })),
32
+ tslib_1.__metadata("design:paramtypes", [Object])
33
+ ], TextBodyParser);
37
34
  exports.TextBodyParser = TextBodyParser;
38
35
  //# sourceMappingURL=body-parser.text.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"body-parser.text.js","sourceRoot":"","sources":["../../src/body-parsers/body-parser.text.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,+CAAyC;AACzC,6CAAiC;AACjC,qCAA2B;AAC3B,kCAAqC;AAErC,+DAK+B;AAG/B;IAAA,IAAa,cAAc,GAA3B,MAAa,cAAc;QAIzB,YAEE,UAAoC,EAAE;YALxC,SAAI,GAAG,oCAAc,CAAC,IAAI,CAAC;YAOzB,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAC/B,EAAC,IAAI,EAAE,QAAQ,EAAC,EAChB,sCAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,CAClC,CAAC;YACF,IAAI,CAAC,UAAU,GAAG,kBAAI,CAAC,WAAW,CAAC,CAAC;QACtC,CAAC;QAED,QAAQ,CAAC,SAAiB;YACxB,2EAA2E;YAC3E,YAAY;YACZ,OAAO,CAAC,CAAC,YAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QACnC,CAAC;QAED,KAAK,CAAC,KAAK,CAAC,OAAgB;YAC1B,MAAM,IAAI,GAAG,MAAM,gDAA0B,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;YACxE,OAAO,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC;QACvB,CAAC;KACF,CAAA;IAzBY,cAAc;QAKtB,mBAAA,gBAAM,CAAC,mBAAY,CAAC,2BAA2B,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAA;;OAL1D,cAAc,CAyB1B;IAAD,qBAAC;KAAA;AAzBY,wCAAc"}
1
+ {"version":3,"file":"body-parser.text.js","sourceRoot":"","sources":["../../src/body-parsers/body-parser.text.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,yCAAsC;AACtC,6CAAiC;AACjC,qCAA2B;AAC3B,kCAAqC;AAErC,+DAK+B;AAG/B,IAAa,cAAc,GAA3B,MAAa,cAAc;IAIzB,YAEE,UAAoC,EAAE;QALxC,SAAI,GAAG,oCAAc,CAAC,IAAI,CAAC;QAOzB,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAC/B,EAAC,IAAI,EAAE,QAAQ,EAAC,EAChB,sCAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,CAClC,CAAC;QACF,IAAI,CAAC,UAAU,GAAG,kBAAI,CAAC,WAAW,CAAC,CAAC;IACtC,CAAC;IAED,QAAQ,CAAC,SAAiB;QACxB,2EAA2E;QAC3E,YAAY;QACZ,OAAO,CAAC,CAAC,YAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,OAAgB;QAC1B,MAAM,IAAI,GAAG,MAAM,gDAA0B,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACxE,OAAO,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC;IACvB,CAAC;CACF,CAAA;AAzBY,cAAc;IAKtB,mBAAA,aAAM,CAAC,mBAAY,CAAC,2BAA2B,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAA;;GAL1D,cAAc,CAyB1B;AAzBY,wCAAc"}
@@ -6,31 +6,28 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.UrlEncodedBodyParser = void 0;
8
8
  const tslib_1 = require("tslib");
9
- const context_1 = require("@loopback/context");
9
+ const core_1 = require("@loopback/core");
10
10
  const body_parser_1 = require("body-parser");
11
11
  const type_is_1 = require("type-is");
12
12
  const keys_1 = require("../keys");
13
13
  const body_parser_helpers_1 = require("./body-parser.helpers");
14
- let UrlEncodedBodyParser = /** @class */ (() => {
15
- let UrlEncodedBodyParser = class UrlEncodedBodyParser {
16
- constructor(options = {}) {
17
- this.name = body_parser_helpers_1.builtinParsers.urlencoded;
18
- const urlencodedOptions = body_parser_helpers_1.getParserOptions('urlencoded', options);
19
- this.urlencodedParser = body_parser_1.urlencoded(urlencodedOptions);
20
- }
21
- supports(mediaType) {
22
- return !!type_is_1.is(mediaType, 'urlencoded');
23
- }
24
- async parse(request) {
25
- const body = await body_parser_helpers_1.invokeBodyParserMiddleware(this.urlencodedParser, request);
26
- return { value: body, coercionRequired: true };
27
- }
28
- };
29
- UrlEncodedBodyParser = tslib_1.__decorate([
30
- tslib_1.__param(0, context_1.inject(keys_1.RestBindings.REQUEST_BODY_PARSER_OPTIONS, { optional: true })),
31
- tslib_1.__metadata("design:paramtypes", [Object])
32
- ], UrlEncodedBodyParser);
33
- return UrlEncodedBodyParser;
34
- })();
14
+ let UrlEncodedBodyParser = class UrlEncodedBodyParser {
15
+ constructor(options = {}) {
16
+ this.name = body_parser_helpers_1.builtinParsers.urlencoded;
17
+ const urlencodedOptions = body_parser_helpers_1.getParserOptions('urlencoded', options);
18
+ this.urlencodedParser = body_parser_1.urlencoded(urlencodedOptions);
19
+ }
20
+ supports(mediaType) {
21
+ return !!type_is_1.is(mediaType, 'urlencoded');
22
+ }
23
+ async parse(request) {
24
+ const body = await body_parser_helpers_1.invokeBodyParserMiddleware(this.urlencodedParser, request);
25
+ return { value: body, coercionRequired: true };
26
+ }
27
+ };
28
+ UrlEncodedBodyParser = tslib_1.__decorate([
29
+ tslib_1.__param(0, core_1.inject(keys_1.RestBindings.REQUEST_BODY_PARSER_OPTIONS, { optional: true })),
30
+ tslib_1.__metadata("design:paramtypes", [Object])
31
+ ], UrlEncodedBodyParser);
35
32
  exports.UrlEncodedBodyParser = UrlEncodedBodyParser;
36
33
  //# sourceMappingURL=body-parser.urlencoded.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"body-parser.urlencoded.js","sourceRoot":"","sources":["../../src/body-parsers/body-parser.urlencoded.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,+CAAyC;AACzC,6CAAuC;AACvC,qCAA2B;AAC3B,kCAAqC;AAErC,+DAK+B;AAG/B;IAAA,IAAa,oBAAoB,GAAjC,MAAa,oBAAoB;QAI/B,YAEE,UAAoC,EAAE;YALxC,SAAI,GAAG,oCAAc,CAAC,UAAU,CAAC;YAO/B,MAAM,iBAAiB,GAAG,sCAAgB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;YAClE,IAAI,CAAC,gBAAgB,GAAG,wBAAU,CAAC,iBAAiB,CAAC,CAAC;QACxD,CAAC;QAED,QAAQ,CAAC,SAAiB;YACxB,OAAO,CAAC,CAAC,YAAE,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;QACvC,CAAC;QAED,KAAK,CAAC,KAAK,CAAC,OAAgB;YAC1B,MAAM,IAAI,GAAG,MAAM,gDAA0B,CAC3C,IAAI,CAAC,gBAAgB,EACrB,OAAO,CACR,CAAC;YACF,OAAO,EAAC,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAC,CAAC;QAC/C,CAAC;KACF,CAAA;IAvBY,oBAAoB;QAK5B,mBAAA,gBAAM,CAAC,mBAAY,CAAC,2BAA2B,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAA;;OAL1D,oBAAoB,CAuBhC;IAAD,2BAAC;KAAA;AAvBY,oDAAoB"}
1
+ {"version":3,"file":"body-parser.urlencoded.js","sourceRoot":"","sources":["../../src/body-parsers/body-parser.urlencoded.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,yCAAsC;AACtC,6CAAuC;AACvC,qCAA2B;AAC3B,kCAAqC;AAErC,+DAK+B;AAG/B,IAAa,o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