Merge pull request #218 from zkldi/zkldi/issue-214-If-reqbody-is-undefined-replace-it-with-an-empty-object

add a body neutraliser
This commit is contained in:
zkldi
2021-06-30 20:58:27 +01:00
committed by GitHub
+8
View File
@@ -61,6 +61,14 @@ process.on("unhandledRejection", (reason, promise) => {
// limit them so as not to choke the api
app.use(express.json({ limit: "1mb" }));
app.use((req, res, next) => {
if (req.method !== "GET" && !req.body) {
req.body = {};
}
return next();
});
import mainRouter from "./router/router";
app.use("/", mainRouter);