@kravc/dos 1.8.1 → 1.8.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kravc/dos",
3
- "version": "1.8.1",
3
+ "version": "1.8.2",
4
4
  "description": "Convention-based, easy-to-use library for building API-driven serverless services.",
5
5
  "keywords": [
6
6
  "Service",
@@ -7,10 +7,12 @@ const SWAGGER_UI_TEMPLATE_PATH = resolve(__dirname, '../../assets/index.html')
7
7
  const SWAGGER_UI_TEMPLATE = readFileSync(SWAGGER_UI_TEMPLATE_PATH, { encoding: 'utf8' })
8
8
 
9
9
  const ROOT_PATH = process.cwd()
10
- const { name: title } = require(`${ROOT_PATH}/package.json`)
10
+ const { name: title, version } = require(`${ROOT_PATH}/package.json`)
11
11
 
12
12
  const SWAGGER_UI_HTML = SWAGGER_UI_TEMPLATE.replace('$TITLE', title)
13
13
 
14
+ const isProduction = process.env.NODE_APP_INSTANCE === 'prd'
15
+
14
16
  const specMiddleware = (service, context) => {
15
17
  const { httpPath, httpMethod } = context
16
18
 
@@ -22,7 +24,7 @@ const specMiddleware = (service, context) => {
22
24
  'Content-Type': 'text/html; charset=UTF-8'
23
25
  },
24
26
  statusCode: 200,
25
- body: SWAGGER_UI_HTML
27
+ body: isProduction ? 'healthy' : SWAGGER_UI_HTML
26
28
  }
27
29
  }
28
30
 
@@ -32,7 +34,7 @@ const specMiddleware = (service, context) => {
32
34
  'Content-Type': 'application/json; charset=utf-8'
33
35
  },
34
36
  statusCode: 200,
35
- body: JSON.stringify(service.spec, null, 2)
37
+ body: JSON.stringify(isProduction ? { info: { title, version } } : service.spec, null, 2)
36
38
  }
37
39
  }
38
40