Skip to content

Commit

Permalink
Merge pull request #828 from telefonicaid/task/set_bodyParser_express…
Browse files Browse the repository at this point in the history
…_limit

fix bodyParser express limit from iota config
  • Loading branch information
fgalan committed May 6, 2024
2 parents 86d7cc4 + 67b1587 commit 0f5e3a0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1 @@

- Fix: default express limit to 1Mb instead default 100Kb and allow change it throught a conf env var 'IOTA_EXPRESS_LIMIT' (#827)
12 changes: 6 additions & 6 deletions lib/bindings/HTTPBinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ let httpBindingServer;
const transport = 'HTTP';

const { promisify } = require('util');
const json = promisify(bodyParser.json({ strict: false })); // accept anything JSON.parse accepts.
const text = promisify(bodyParser.text());
const raw = promisify(bodyParser.raw());
const json = promisify(bodyParser.json({ strict: false, limit: config.getConfig().iota.expressLimit })); // accept anything JSON.parse accepts.
const text = promisify(bodyParser.text({ limit: config.getConfig().iota.expressLimit }));
const raw = promisify(bodyParser.raw({ limit: config.getConfig().iota.expressLimit }));
const xml2js = require('xml2js');
const xmlStripPrefix = xml2js.processors.stripPrefix;
const xml = promisify(
Expand Down Expand Up @@ -681,7 +681,7 @@ function start(callback) {

httpBindingServer.router.post(
config.getConfig().iota.defaultResource || constants.HTTP_MEASURE_PATH,
bodyParser.json({ strict: false }), // accept anything JSON.parse accepts
bodyParser.json({ strict: false, limit: config.getConfig().iota.expressLimit }), // accept anything JSON.parse accepts
checkMandatoryParams(false),
parseDataMultipleMeasure,
addTimestamp,
Expand All @@ -704,7 +704,7 @@ function start(callback) {

httpBindingServer.router.post(
(config.getConfig().iota.defaultResource || constants.HTTP_MEASURE_PATH) + constants.HTTP_COMMANDS_PATH,
bodyParser.json({ strict: false }), // accept anything JSON.parse accepts.
bodyParser.json({ strict: false, limit: config.getConfig().iota.expressLimit }), // accept anything JSON.parse accepts.
checkMandatoryParams(false),
parseData,
addTimestamp,
Expand All @@ -715,7 +715,7 @@ function start(callback) {

httpBindingServer.router.post(
(config.getConfig().iota.defaultResource || constants.HTTP_MEASURE_PATH) + constants.HTTP_CONFIGURATION_PATH,
bodyParser.json({ strict: false }), // accept anything JSON.parse accepts.
bodyParser.json({ strict: false, limit: config.getConfig().iota.expressLimit }), // accept anything JSON.parse accepts.
checkMandatoryParams(false),
parseData,
handleConfigurationRequest
Expand Down

0 comments on commit 0f5e3a0

Please sign in to comment.