Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

respect per route body-parser configuration #7131

Merged
merged 1 commit into from
Oct 18, 2021

Conversation

bewest
Copy link
Member

@bewest bewest commented Oct 13, 2021

This change allows each route to express policies for interpreting and parsing
the request body. Before this change uploads to entries or treatments api
would error if they were larger than 100Kb due to the preference being set for
the whole server. This change removes the global preference in favor of
allowing each route to choose it's own request size limit.

We also refactor usage of body-parser to be more consistent throughout the code
base. Most routes can use jsonParser, rawPraser, and urlencodedParser provided
by the common wares component. Anything doing something else should be called
out as such. For example, treatments, activity, and entries allow uploads up
to 50Mb. Other v1 endpoints are using the common configuration set to 1Mb.

This change allows each route to express policies for interpreting and parsing
the request body.  Before this change uploads to entries or treatments api
would error if they were larger than 100Kb due to the preference being set for
the whole server.  This change removes the global preference in favor of
allowing each route to choose it's own request size limit.

We also refactor usage of body-parser to be more consistent throughout the code
base.  Most routes can use jsonParser, rawPraser, and urlencodedParser provided
by the common wares component.  Anything doing something else should be called
out as such.  For example, treatments, activity, and entries allow uploads up
to 50Mb.  Other v1 endpoints are using the common configuration set to 1Mb.
Comment on lines -29 to -30
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines enforce a 100Kb limit for the entire server, regardless of per route configurations. Removing these lines allows the routes to properly express their size limit policies.

@bewest bewest merged commit bc8e319 into dev Oct 18, 2021
@sulkaharo sulkaharo deleted the wip/bewest/request-body-limit branch December 30, 2022 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant