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

Use env var for setting limit and parameterLimit to express's urlenconder #1106

Merged
merged 3 commits into from May 24, 2017

Conversation

gotchahn
Copy link
Contributor

@gotchahn gotchahn commented Jan 5, 2016

For avoiding 413 Request Entity too large in some responses.
fixes #1105

port = process.env.EXPRESS_PORT or process.env.PORT or 8080
address = process.env.EXPRESS_BIND_ADDRESS or process.env.BIND_ADDRESS or '0.0.0.0'
limit = process.env.EXPRESS_LIMIT or '100kb'
paramLimit = process.env.EXPRESS_PARAMETER_LIMIT or 1000
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this have to be run through parseInt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you are right. If the env EXPRESS_PARAMETER_LIMIT is not a number, NaN or undefined will return just NaN and that or 1000 will give us 1000. Good catch! 👍

Copy link
Member

Choose a reason for hiding this comment

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

TIL NaN is falsey.

@@ -427,7 +429,7 @@ class Robot
app.use express.query()

app.use express.json()
app.use express.urlencoded()
app.use express.urlencoded({limit: limit, parameterLimit: paramLimit})
Copy link
Member

Choose a reason for hiding this comment

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

☕ism, but you don't need {} here.

@technicalpickles
Copy link
Member

I'm okay adding this, but would you mind updating the documentation to talk about these new environment variables? https://github.com/github/hubot/blob/master/docs/scripting.md#http-listener makes sense.

@gotchahn
Copy link
Contributor Author

Sound good!

@gotchahn
Copy link
Contributor Author

UPDATED 💥

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.

Modify the default parameterLimit value in robot's express
4 participants