@ladjs/api 14.1.22 → 14.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +10 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -44,8 +44,11 @@ class API {
|
|
|
44
44
|
// eslint-disable-next-line complexity
|
|
45
45
|
constructor(config, Users) {
|
|
46
46
|
this.config = {
|
|
47
|
-
removeTrailingSlashes: true,
|
|
48
47
|
...sharedConfig('API'),
|
|
48
|
+
removeTrailingSlashes: true,
|
|
49
|
+
prettyPrintedJSON: process.env.PRETTY_PRINTED_JSON
|
|
50
|
+
? Boolean(process.env.PRETTY_PRINTED_JSON)
|
|
51
|
+
: false,
|
|
49
52
|
...config
|
|
50
53
|
};
|
|
51
54
|
|
|
@@ -70,11 +73,12 @@ class API {
|
|
|
70
73
|
|
|
71
74
|
// Initialize redis
|
|
72
75
|
this.client =
|
|
73
|
-
this.config.
|
|
76
|
+
this.config.client ||
|
|
77
|
+
(this.config.redis === false
|
|
74
78
|
? false
|
|
75
79
|
: _.isPlainObject(this.config.redis)
|
|
76
80
|
? new Redis(this.config.redis, this.logger, this.config.redisMonitor)
|
|
77
|
-
: this.config.redis;
|
|
81
|
+
: this.config.redis);
|
|
78
82
|
app.context.client = this.client;
|
|
79
83
|
|
|
80
84
|
// Expose passport
|
|
@@ -162,8 +166,9 @@ class API {
|
|
|
162
166
|
return bodyParser(this.config.bodyParser || {})(ctx, next);
|
|
163
167
|
});
|
|
164
168
|
|
|
165
|
-
//
|
|
166
|
-
|
|
169
|
+
// pretty-printed json responses
|
|
170
|
+
// (default unless in development/test environment)
|
|
171
|
+
app.use(json({ pretty: this.config.prettyPrintedJSON, param: 'pretty' }));
|
|
167
172
|
|
|
168
173
|
// Passport
|
|
169
174
|
if (this.passport) app.use(this.passport.initialize());
|
package/package.json
CHANGED