ti2 1.0.28 → 1.0.29

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.
Files changed (2) hide show
  1. package/index.js +7 -8
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -24,6 +24,9 @@ const cache = require('./cache');
24
24
  const rebuild = fn => obj =>
25
25
  Object.fromEntries(Object.entries(obj).flatMap(([k, v]) => fn(k, v)));
26
26
 
27
+ const isNumber = value => !Number.isNaN(Number(value));
28
+
29
+
27
30
  module.exports = async ({
28
31
  apiDocs = true,
29
32
  elasticLogIndex = 'apilog_ti2',
@@ -200,20 +203,16 @@ module.exports = async ({
200
203
  });
201
204
  }
202
205
  connect(app);
203
- if (process.env.mock) {
204
- app.use(middleware.mock());
205
- }
206
- app.use((req, res, next) => {
207
- return res.sendStatus(404);
208
- })
206
+ app.use(middleware.mock());
207
+ app.use((req, res) => res.sendStatus(404));
209
208
  // global error Handling
210
209
  app.use((err, req, res) => {
211
210
  if (process.env.CONSOLE_ERRORS || process.env.JEST_WORKER_ID) {
212
211
  console.error(err);
213
212
  }
214
213
  return res.status((() => {
215
- if (isNan(err.status)) return 500;
216
- return parseInt(err.status, 10);
214
+ if (!isNumber(err.status)) return 500;
215
+ return Number(err.status);
217
216
  })()).json({
218
217
  message: err.message || 'Internal Error',
219
218
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ti2",
3
- "version": "1.0.28",
3
+ "version": "1.0.29",
4
4
  "description": "Tourist Industry Exchange (TI2)",
5
5
  "main": "index.js",
6
6
  "scripts": {