bootpress 10.0.3 → 10.0.4
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/index.js +3 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const { as, asStrict, log } = require("./helpers");
|
|
2
|
+
const { HttpError } = require("./types");
|
|
2
3
|
|
|
3
4
|
const protectedProperties = [
|
|
4
5
|
"toString",
|
|
@@ -247,6 +248,7 @@ function PassBodyAs(type, config = { messageTemplate: "Malformed Request Body\n{
|
|
|
247
248
|
const req = args.at(-3);
|
|
248
249
|
const res = args.at(-2);
|
|
249
250
|
try {
|
|
251
|
+
if (req.body === null || req.body === undefined) throw new HttpError(400, "Request body is mandatory");
|
|
250
252
|
return actualHandler(asStrict(req.body, type, config))(req, res);
|
|
251
253
|
} catch (e) {
|
|
252
254
|
const status = e.status ?? 500;
|
|
@@ -256,6 +258,7 @@ function PassBodyAs(type, config = { messageTemplate: "Malformed Request Body\n{
|
|
|
256
258
|
} else {
|
|
257
259
|
return (req, res) => {
|
|
258
260
|
try {
|
|
261
|
+
if (req.body === null || req.body === undefined) throw new HttpError(400, "Request body is mandatory");
|
|
259
262
|
return actualHandler(...args, asStrict(req.body, type, config))(req, res);
|
|
260
263
|
} catch (e) {
|
|
261
264
|
const status = e.status ?? 500;
|