feat(pretty-json): support force option
This PR adds a force option to pretty-json for users who want all responses to be pretty printed, ie. don't want to add ?pretty=1 to all queries and don't want to use a 3rd party or hand-rolled middleware.
usage:
app.use('*', prettyJSON({ force: true }))
The author should do the following, if applicable
IMHO the API for this middleware would be more intuitive if the default mode was to prettify all responses.
Then if the query option was specified it would adopt the existing behaviour of only running when the query param is present.
That ship has unfortunately sailed as it would break backwards compat but an interesting idea if there were ever a v2.
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 91.52%. Comparing base (8fe7fee) to head (559c3ff).
Additional details and impacted files
@@ Coverage Diff @@
## next #4531 +/- ##
=======================================
Coverage 91.52% 91.52%
=======================================
Files 172 172
Lines 11221 11221
Branches 3255 3257 +2
=======================================
Hits 10270 10270
Misses 950 950
Partials 1 1
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
Hi @missinglink
This is a great feature! As you said, we can consider whether force should be the default. But currently, let's go with this.
We may include this change for the next minor bump. I'll merge this after preparing it. Thanks!