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
Conversation
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 |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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! 👍
There was a problem hiding this comment.
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}) |
There was a problem hiding this comment.
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.
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. |
Sound good! |
UPDATED 💥 |
For avoiding
413 Request Entity too large
in some responses.fixes #1105