@mimik/init 3.8.1 → 3.9.2

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 CHANGED
@@ -131,7 +131,7 @@ module.exports = (app, rootDir, config, validates, cluster, options) => {
131
131
  }
132
132
  if (swaggerFilename[0] !== '/') swaggerFilename = path.join(rootDir, swaggerFilename);
133
133
  logger.debug('location of the swagger file', { swaggerFilename }, correlationIdStart);
134
- return swagger.getAPIFile(swaggerFilename, correlationIdStart, options)
134
+ return swagger.getAPIFile(swaggerFilename, correlationIdStart, config.apiBasicAuth, options)
135
135
  .then((swaggerJson) => swaggerTools.initializeMiddleware(swaggerJson, (middleware) => {
136
136
  serverSettings.basePath = swaggerJson.basePath;
137
137
  app.use(startHrTimeSet());
package/lib/common.js CHANGED
@@ -1,7 +1,9 @@
1
1
  const METRICS_ROUTE = '/metrics';
2
2
  const HEALTHCHECK_ROUTE = '/healthcheck';
3
+ const OUT_OF_SPEC_ROUTE = 'outOfSpecificationRoute';
3
4
 
4
5
  module.exports = {
5
6
  METRICS_ROUTE,
6
7
  HEALTHCHECK_ROUTE,
8
+ OUT_OF_SPEC_ROUTE,
7
9
  };
package/lib/metrics.js CHANGED
@@ -1,9 +1,10 @@
1
- const { HEALTHCHECK_ROUTE, METRICS_ROUTE } = require('./common');
1
+ const { HEALTHCHECK_ROUTE, METRICS_ROUTE, OUT_OF_SPEC_ROUTE } = require('./common');
2
2
 
3
3
  const APIRequestMetrics = (APIRequestDuration, basePath) => (req, res, next) => {
4
+ const { swagger } = req;
4
5
  let apiPath = req.originalUrl;
5
6
 
6
- if (req.swagger) apiPath = req.swagger.apiPath;
7
+ if (swagger) apiPath = swagger.apiPath;
7
8
  const startHrTime = req.metrics ? req.metrics.startHrTime : process.hrtime();
8
9
 
9
10
  res.on('finish', () => {
@@ -12,7 +13,7 @@ const APIRequestMetrics = (APIRequestDuration, basePath) => (req, res, next) =>
12
13
  const elapsedTimeInMs = elapsedHrTime[0] * 1000 + elapsedHrTime[1] / 1e6;
13
14
 
14
15
  APIRequestDuration
15
- .labels(req.method, `${basePath}${apiPath}`, req.originalUrl.includes('?'), res.statusCode)
16
+ .labels(req.method, swagger ? `${basePath}${apiPath}` : OUT_OF_SPEC_ROUTE, req.originalUrl.includes('?'), res.statusCode)
16
17
  .observe(elapsedTimeInMs);
17
18
  }
18
19
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mimik/init",
3
- "version": "3.8.1",
3
+ "version": "3.9.2",
4
4
  "description": "Init process for micro-service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -29,24 +29,24 @@
29
29
  "url": "https://bitbucket.org/mimiktech/init"
30
30
  },
31
31
  "dependencies": {
32
- "@mimik/address-helper": "^1.6.6",
32
+ "@mimik/address-helper": "^1.6.7",
33
33
  "@mimik/healthcheck": "^1.5.10",
34
34
  "@mimik/oauth-helper": "^2.1.0",
35
35
  "@mimik/public-helper": "^1.6.2",
36
36
  "@mimik/request-helper": "^1.7.8",
37
37
  "@mimik/response-helper": "^2.6.3",
38
- "@mimik/sumologic-winston-logger": "^1.6.14",
38
+ "@mimik/sumologic-winston-logger": "^1.6.15",
39
39
  "@mimik/swagger-helper": "^2.5.7",
40
40
  "@mimik/systeminfo": "^2.3.11",
41
41
  "bluebird": "3.7.2",
42
42
  "cors": "2.8.5",
43
- "helmet": "6.0.1",
43
+ "helmet": "6.1.5",
44
44
  "swagger-tools": "0.10.4"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@mimik/eslint-plugin-dependencies": "^2.4.5",
48
48
  "@mimik/eslint-plugin-document-env": "^1.0.5",
49
- "eslint": "8.35.0",
49
+ "eslint": "8.38.0",
50
50
  "eslint-config-airbnb": "19.0.4",
51
51
  "eslint-plugin-import": "2.27.5",
52
52
  "eslint-plugin-jsx-a11y": "6.7.1",