@autofleet/node-common 1.2.8 → 1.2.9

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/logger/index.js CHANGED
@@ -1,4 +1,7 @@
1
1
  const winston = require('winston');
2
+ const {LoggingWinston} = require('@google-cloud/logging-winston');
3
+
4
+ const loggingWinston = new LoggingWinston();
2
5
 
3
6
  const { createLogger } = winston;
4
7
  require('dotenv').config();
@@ -52,7 +55,7 @@ const getFormat = () => {
52
55
  };
53
56
 
54
57
  const createLoggerInstance = (level, exceptionHandlers) => {
55
- const transports = [new winston.transports.Console()];
58
+ const transports = [new winston.transports.Console(), loggingWinston];
56
59
 
57
60
  const logger = createLogger({
58
61
  level,
@@ -77,6 +80,9 @@ const createLoggerInstance = (level, exceptionHandlers) => {
77
80
  },
78
81
  });
79
82
  };
83
+
84
+ const mw = await lw.express.makeMiddleware(logger);
85
+
80
86
  if (env.NODE_ENV !== 'production') {
81
87
  logger.httpMorganInfo = undefined;
82
88
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/node-common",
3
- "version": "1.2.8",
3
+ "version": "1.2.9",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "coverage": "jest --coverage --forceExit --runInBand",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "homepage": "https://github.com/Autofleet/node-common",
25
25
  "dependencies": {
26
- "@google-cloud/logging-winston": "^0.10.2",
26
+ "@google-cloud/logging-winston": "^2.0.1",
27
27
  "@google-cloud/pubsub": "^0.20.1",
28
28
  "axios": "^0.18.0",
29
29
  "axios-retry": "^3.1.0",
@@ -38,7 +38,7 @@
38
38
  "qs": "^6.5.2",
39
39
  "timekeeper": "^2.1.2",
40
40
  "weak": "^1.0.1",
41
- "winston": "^3.0.0",
41
+ "winston": "^3.2.1",
42
42
  "ws": "^5.2.1"
43
43
  },
44
44
  "devDependencies": {
package/router/index.js CHANGED
@@ -17,11 +17,17 @@ const AfEntryPoint = func => async (req, res, next) => {
17
17
  try {
18
18
  await func(req, res, next);
19
19
  } catch (e) {
20
- logger.error(e.message);
21
- if (e.statusCode && e.statusCode < 500) {
22
- return res.status(400).json({ error: e.message, status: 'ERROR' });
20
+ if(e.array) {
21
+ logger.error('Validation error', e.array())
22
+ res.status(422);
23
+ res.json({
24
+ validationErrors: e.array(),
25
+ })
26
+ next();
27
+ } else {
28
+ logger.error(e)
29
+ next(e);
23
30
  }
24
- next(e);
25
31
  }
26
32
  };
27
33
 
package/settings/map.js CHANGED
@@ -395,11 +395,4 @@ module.exports = {
395
395
  defaultValue: 'GBP',
396
396
  context: 'ride',
397
397
  },
398
- BUFFER: {
399
- name: 'Buffer around a polygon of a route',
400
- description: 'The buffer around a polygon of a route to calculate tiled from',
401
- type: 'number',
402
- defaultValue: 1,
403
- context: 'matching',
404
- },
405
398
  };