Skip to content

Conversation

kushal4345
Copy link
Contributor

Summary

This PR updates the express.json() documentation to:

  • Clarify behavior and options in a more concise way.
  • Add an example showing how to set different limit values for specific routes (e.g., /upload).

Changes

  • Added a "Different limits for specific routes" section with a code example.
  • Maintained existing style and formatting consistent with the Express docs.
  • Verified that markdown tables and headings render correctly.

Reason

Issue #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

  • No changes to Express codebase, only to documentation.
  • Follows current contributing and formatting guidelines.

@kushal4345 kushal4345 requested a review from a team as a code owner August 11, 2025 05:13
Copy link

netlify bot commented Aug 11, 2025

Deploy Preview for expressjscom-preview ready!

Name Link
🔨 Latest commit 3424f61
🔍 Latest deploy log https://app.netlify.com/projects/expressjscom-preview/deploys/68a7ed4d45639400088fcf6f
😎 Deploy Preview https://deploy-preview-2037--expressjscom-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

github-actions bot commented Aug 11, 2025

🚦 Lighthouse Results (Mobile & Desktop)

URL Device Perf A11y Best Practices
/ mobile 🔴 60 🟢 100 🟠 79
/en/blog/posts.html mobile 🟠 76 🟢 96 🟢 96
/en/5x/api.html mobile 🟠 76 🟢 95 🟢 96
/ desktop 🟢 99 🟢 100 🟠 78
/en/blog/posts.html desktop 🟢 99 🟢 96 🟢 93
/en/5x/api.html desktop 🟢 99 🟢 95 🟢 96

@kushal4345 kushal4345 closed this Aug 11, 2025
@kushal4345 kushal4345 reopened this Aug 11, 2025
Copy link
Member

@ShubhamOulkar ShubhamOulkar left a comment

Choose a reason for hiding this comment

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

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.

@kushal4345
Copy link
Contributor Author

Thanks for the review!

I understand that the property table explains the limit option, but I think this example could still add value for developers. The table shows the option in isolation, while this example demonstrates how to apply different limits for specific routes (e.g., /upload) without affecting the global middleware.

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!

@ShubhamOulkar
Copy link
Member

@kushal4345, I think updating use middleware page would be better. This page includes a built-in middleware section at the bottom.

@kushal4345
Copy link
Contributor Author

Thanks for the suggestion

i have Added a new section titled “Different Limits for Specific Routes” to the middleware page.
This section includes a clear code example demonstrating how to set different rate limits for individual routes.
The update aims to make the middleware page more informative and helpful for developers by providing practical usage guidance.

@kushal4345
Copy link
Contributor Author

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.

Copy link
Member

@bjohansebas bjohansebas left a comment

Choose a reason for hiding this comment

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

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.

Copy link
Member

Choose a reason for hiding this comment

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

From what I can see, you made the change in the wrong file, judging by the commit message.

@kushal4345
Copy link
Contributor Author

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.
Ensured the default express.json() still applies for other routes.
Fixed formatting to properly close the markdown code block.

Copy link
Member

Choose a reason for hiding this comment

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

@kushal4345
Copy link
Contributor Author

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.

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.

3 participants