@kravc/dos 1.8.0 → 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.0",
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",
@@ -25,7 +25,7 @@
25
25
  "author": "Alexander Kravets <a@kra.vc>",
26
26
  "license": "ISC",
27
27
  "dependencies": {
28
- "@kravc/schema": "^2.6.0",
28
+ "@kravc/schema": "^2.7.0",
29
29
  "cookie": "^0.5.0",
30
30
  "js-yaml": "^4.1.0",
31
31
  "jsonwebtoken": "^9.0.2",
package/src/Service.js CHANGED
@@ -169,7 +169,7 @@ class Service {
169
169
  let output
170
170
 
171
171
  try {
172
- output = this._validator.validate(object, outputSchema.id)
172
+ output = this._validator.validate(object, outputSchema.id, false, true)
173
173
 
174
174
  } catch (validationError) {
175
175
  throw new InvalidOutputError(object, validationError)
@@ -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