docs(express.json): clarify usage and add route-specific limit example#2037
docs(express.json): clarify usage and add route-specific limit example#2037kushal4345 wants to merge 8 commits intoexpressjs:gh-pagesfrom
Conversation
✅ Deploy Preview for expressjscom-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
🚦 Lighthouse Results (Mobile & Desktop)
|
ShubhamOulkar
left a comment
There was a problem hiding this comment.
I don't think changes are required. Property table explained limit option very well and clear. See our use middleware page since this example explains how to use express.json() middleware.
|
Thanks for the review! I understand that the property table explains the In my experience, beginners often struggle to connect configuration options to real-world route usage, so I felt this would make the docs more practical and beginner-friendly. Of course, I’m happy to adjust the wording or placement if you think a shorter version would fit better. Please let me know your thoughts! |
|
@kushal4345, I think updating |
97e21b2 to
7940a18
Compare
|
Thanks for the suggestion i have Added a new section titled “Different Limits for Specific Routes” to the middleware page. |
|
Hi @ShubhamOulkar, I saw you requested changes, but I couldn’t find specific comments in the Files changed tab. Could you clarify what needs to be updated? I’ll make the adjustments accordingly. |
bjohansebas
left a comment
There was a problem hiding this comment.
Thanks for your contribution. I agree with @ShubhamOulkar; it makes more sense for this to be under the use middleware page, not to add it in the API files, because each API describes its functionality and shouldn’t explain how to use it under different forms of middleware.
There was a problem hiding this comment.
From what I can see, you made the change in the wrong file, judging by the commit message.
|
Hi I’ve updated the using-middleware.md guide to include an example of applying different JSON body size limits for specific routes. Added a code snippet showing how to set a custom limit (5mb) for /upload. |
There was a problem hiding this comment.
In this file neither, it’s in this one.
https://github.com/expressjs/expressjs.com/blob/gh-pages/en/guide/using-middleware.md
|
Thanks for the clarification I’ve added the new example for different limits inside en/guide/using-middleware.md under the Built-in middleware section as suggested. Please let me know if you’d like me to adjust the placement further. |
ShubhamOulkar
left a comment
There was a problem hiding this comment.
Please remove unnecessary changes
|
|
||
| Bind application-level middleware to an instance of the [app object](/{{ page.lang }}/5x/api.html#app) by using the `app.use()` and `app.METHOD()` functions, where `METHOD` is the HTTP method of the request that the middleware function handles (such as GET, PUT, or POST) in lowercase. | ||
|
|
||
| This example shows a middleware function with no mount path. The function is executed every time the app receives a request. |
There was a problem hiding this comment.
These changes are not required. Please undo it.
| - [express.urlencoded](/en/5x/api.html#express.urlencoded) parses incoming requests with URL-encoded payloads. **NOTE: Available with Express 4.16.0+** | ||
| gh-pages | ||
|
|
||
| Here is an example of using the `express.json` middleware with a custom limit: |
There was a problem hiding this comment.
🤔 Should we need separate pages for explaining how to use built in middleware options?
It feels off-topic on the page
Co-authored-by: shubham oulkar <91728992+ShubhamOulkar@users.noreply.github.com>
|
The root issue expressjs/express#3932 that inspired the linked issue is really about understanding middleware ordering and targeting specific routes with specific middleware, not about I don't think the proposed change focused on |
|
@jonchurch hmm not sure what you mean. I understood expressjs/express#3932 to be about "how can I configure the I think my issue #1421 doesn't subvert that original wish, and that the changes in this PR are helpful for understanding how to achieve this common use case. Do you disagree with either of those things? |
Summary
This PR updates the
express.json()documentation to:limitvalues for specific routes (e.g.,/upload).Changes
Reason
Closes #1421 requests additional clarity on using
express.json()with different route limits.This helps developers quickly understand how to override defaults for specific endpoints without affecting others.
Notes