1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | Object.defineProperty(exports, "__esModule", { value: true });
|
7 | exports.RawBodyParser = void 0;
|
8 | const tslib_1 = require("tslib");
|
9 | const core_1 = require("@loopback/core");
|
10 | const body_parser_1 = require("body-parser");
|
11 | const type_is_1 = require("type-is");
|
12 | const keys_1 = require("../keys");
|
13 | const body_parser_helpers_1 = require("./body-parser.helpers");
|
14 |
|
15 |
|
16 |
|
17 | let RawBodyParser = class RawBodyParser {
|
18 | constructor(options = {}) {
|
19 | this.name = body_parser_helpers_1.builtinParsers.raw;
|
20 | const rawOptions = (0, body_parser_helpers_1.getParserOptions)('raw', options);
|
21 | this.rawParser = (0, body_parser_1.raw)(rawOptions);
|
22 | }
|
23 | supports(mediaType) {
|
24 | return !!(0, type_is_1.is)(mediaType, 'application/octet-stream');
|
25 | }
|
26 | async parse(request) {
|
27 | const body = await (0, body_parser_helpers_1.invokeBodyParserMiddleware)(this.rawParser, request);
|
28 | return { value: body };
|
29 | }
|
30 | };
|
31 | exports.RawBodyParser = RawBodyParser;
|
32 | exports.RawBodyParser = RawBodyParser = tslib_1.__decorate([
|
33 | tslib_1.__param(0, (0, core_1.inject)(keys_1.RestBindings.REQUEST_BODY_PARSER_OPTIONS, { optional: true })),
|
34 | tslib_1.__metadata("design:paramtypes", [Object])
|
35 | ], RawBodyParser);
|
36 |
|
\ | No newline at end of file |