ti2 1.0.25 → 1.0.28
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 +12 -6
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -200,15 +200,21 @@ module.exports = async ({
|
|
|
200
200
|
});
|
|
201
201
|
}
|
|
202
202
|
connect(app);
|
|
203
|
-
|
|
203
|
+
if (process.env.mock) {
|
|
204
|
+
app.use(middleware.mock());
|
|
205
|
+
}
|
|
206
|
+
app.use((req, res, next) => {
|
|
207
|
+
return res.sendStatus(404);
|
|
208
|
+
})
|
|
204
209
|
// global error Handling
|
|
205
210
|
app.use((err, req, res) => {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
if ((process.env.JEST_WORKER_ID)) {
|
|
209
|
-
console.debug(err);
|
|
211
|
+
if (process.env.CONSOLE_ERRORS || process.env.JEST_WORKER_ID) {
|
|
212
|
+
console.error(err);
|
|
210
213
|
}
|
|
211
|
-
return res.
|
|
214
|
+
return res.status((() => {
|
|
215
|
+
if (isNan(err.status)) return 500;
|
|
216
|
+
return parseInt(err.status, 10);
|
|
217
|
+
})()).json({
|
|
212
218
|
message: err.message || 'Internal Error',
|
|
213
219
|
});
|
|
214
220
|
});
|