@trayio/express 4.86.0 → 4.88.0
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpressHttpController.d.ts","sourceRoot":"","sources":["../../src/http/ExpressHttpController.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AASnD,OAAO,EACN,cAAc,EAEd,MAAM,qCAAqC,CAAC;AAG7C,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAW1D,qBAAa,qBAAqB;IAEhC,SAAS,CAAC,UAAU,EAAE,cAAc;IACpC,SAAS,CAAC,2BAA2B,EAAE,MAAM;IAC7C,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;gBAFzB,UAAU,EAAE,cAAc,EAC1B,2BAA2B,EAAE,MAAe,EAC5C,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;IAGpC,OAAO,CAAC,QAAQ,
|
|
1
|
+
{"version":3,"file":"ExpressHttpController.d.ts","sourceRoot":"","sources":["../../src/http/ExpressHttpController.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AASnD,OAAO,EACN,cAAc,EAEd,MAAM,qCAAqC,CAAC;AAG7C,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAW1D,qBAAa,qBAAqB;IAEhC,SAAS,CAAC,UAAU,EAAE,cAAc;IACpC,SAAS,CAAC,2BAA2B,EAAE,MAAM;IAC7C,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;gBAFzB,UAAU,EAAE,cAAc,EAC1B,2BAA2B,EAAE,MAAe,EAC5C,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;IAGpC,OAAO,CAAC,QAAQ,CA4Ed;IAEF,SAAS,WAAY,MAAM,YAKzB;IAEF,OAAO,CAAC,gBAAgB,CAoBtB;IAGF,OAAO,CAAC,uBAAuB,CAI7B;IAEF,OAAO,CAAC,sBAAsB,CAmC3B;IAEH,OAAO,CAAC,aAAa,CAenB;IAEF,OAAO,CAAC,YAAY,CAkBlB;IAEF,OAAO,CAAC,+BAA+B,CAWpC;CACH"}
|
|
@@ -29,6 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.ExpressHttpController = void 0;
|
|
30
30
|
const TE = __importStar(require("fp-ts/TaskEither"));
|
|
31
31
|
const E = __importStar(require("fp-ts/Either"));
|
|
32
|
+
const O = __importStar(require("fp-ts/Option"));
|
|
32
33
|
const Http_1 = require("@trayio/commons/http/Http");
|
|
33
34
|
const BufferExtensions_1 = require("@trayio/commons/buffer/BufferExtensions");
|
|
34
35
|
const formidable_1 = __importDefault(require("formidable"));
|
|
@@ -51,7 +52,26 @@ class ExpressHttpController {
|
|
|
51
52
|
[key]: newValue,
|
|
52
53
|
};
|
|
53
54
|
}, {});
|
|
54
|
-
|
|
55
|
+
let requestBody;
|
|
56
|
+
try {
|
|
57
|
+
requestBody = await this.parseRequestBody(req);
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
if (O.isSome(this.logger)) {
|
|
61
|
+
this.logger.value.warning(`Issue in the request: ${err.message}`, {
|
|
62
|
+
path: req.path,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
if (err.message.includes('maxTotalFileSize exceeded') ||
|
|
66
|
+
err.message.includes('maxFileSize exceeded')) {
|
|
67
|
+
return res.status(400).json({
|
|
68
|
+
error: 'File too large. Max size is 100MB.',
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return res.status(400).json({
|
|
72
|
+
error: `Invalid request: ${err.message}`,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
55
75
|
const httpResponse = await endpoint.execute(this.logger)(Http_1.HttpRequest.create({
|
|
56
76
|
headers,
|
|
57
77
|
pathParams: req.params,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trayio/express",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.88.0",
|
|
4
4
|
"description": "Express extensions and implementations",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./*": "./dist/*.js"
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@trayio/commons": "4.
|
|
17
|
+
"@trayio/commons": "4.88.0",
|
|
18
18
|
"cors": "2.8.5",
|
|
19
19
|
"express": "4.20.0",
|
|
20
20
|
"formidable": "3.5.1"
|