Skip to content

Commit 9c93413

Browse files
committed
fix: do not pretty-print json by default
1 parent 1d320db commit 9c93413

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@ class API {
4444
// eslint-disable-next-line complexity
4545
constructor(config, Users) {
4646
this.config = {
47-
removeTrailingSlashes: true,
4847
...sharedConfig('API'),
48+
removeTrailingSlashes: true,
49+
prettyPrintedJSON: process.env.PRETTY_PRINTED_JSON
50+
? Boolean(process.env.PRETTY_PRINTED_JSON)
51+
: false,
4952
...config
5053
};
5154

@@ -163,8 +166,9 @@ class API {
163166
return bodyParser(this.config.bodyParser || {})(ctx, next);
164167
});
165168

166-
// Pretty-printed json responses
167-
app.use(json());
169+
// pretty-printed json responses
170+
// (default unless in development/test environment)
171+
app.use(json({ pretty: this.config.prettyPrintedJSON, param: 'pretty' }));
168172

169173
// Passport
170174
if (this.passport) app.use(this.passport.initialize());

0 commit comments

Comments
 (0)