@kravc/dos 1.8.7 → 1.8.8
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/examples/index.js +3 -1
- package/package.json +1 -1
- package/src/Service.js +11 -9
- package/src/Service.spec.js +4 -2
- package/src/helpers/createSchemasMap.js +1 -3
package/examples/index.js
CHANGED
|
@@ -22,6 +22,8 @@ const modules = [
|
|
|
22
22
|
IndexProfiles
|
|
23
23
|
]
|
|
24
24
|
|
|
25
|
-
const
|
|
25
|
+
const ROOT_PATH = process.cwd()
|
|
26
|
+
|
|
27
|
+
const service = new Service(modules, 'http://localhost:3000/', `${ROOT_PATH}/examples`)
|
|
26
28
|
|
|
27
29
|
exports.handler = handler(service)
|
package/package.json
CHANGED
package/src/Service.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const InvalidInputError = require('./errors/InvalidInputError')
|
|
3
|
+
const handler = require('./helpers/handler')
|
|
4
|
+
const authorize = require('./helpers/authorize')
|
|
5
|
+
const createSpec = require('./helpers/createSpec')
|
|
6
|
+
const { Validator } = require('@kravc/schema')
|
|
7
|
+
const OperationError = require('./errors/OperationError')
|
|
8
|
+
const createSchemasMap = require('./helpers/createSchemasMap')
|
|
9
|
+
const InvalidInputError = require('./errors/InvalidInputError')
|
|
11
10
|
const InvalidOutputError = require('./errors/InvalidOutputError')
|
|
12
11
|
const OperationNotFoundError = require('./errors/OperationNotFoundError')
|
|
12
|
+
const { get, uniq, compact } = require('lodash')
|
|
13
|
+
|
|
14
|
+
const ROOT_PATH = process.cwd()
|
|
13
15
|
|
|
14
16
|
class Service {
|
|
15
|
-
constructor(modules, url = 'http://localhost:3000/', path =
|
|
17
|
+
constructor(modules, url = 'http://localhost:3000/', path = `${ROOT_PATH}/src`) {
|
|
16
18
|
if (!url.endsWith('/')) { url = url + '/' }
|
|
17
19
|
|
|
18
20
|
const schemasMap = createSchemasMap(path)
|
package/src/Service.spec.js
CHANGED
|
@@ -25,6 +25,8 @@ const modules = [
|
|
|
25
25
|
IndexProfiles
|
|
26
26
|
]
|
|
27
27
|
|
|
28
|
+
const ROOT_PATH = process.cwd()
|
|
29
|
+
|
|
28
30
|
describe('Service', () => {
|
|
29
31
|
before(() => {
|
|
30
32
|
const { Component: Profile } = CreateProfile
|
|
@@ -33,7 +35,7 @@ describe('Service', () => {
|
|
|
33
35
|
|
|
34
36
|
describe('Service.constructor(modules, url, path = \'/src\')', () => {
|
|
35
37
|
it('initializes service', () => {
|
|
36
|
-
const service = new Service(modules, 'https://example.com/api',
|
|
38
|
+
const service = new Service(modules, 'https://example.com/api', `${ROOT_PATH}/examples`)
|
|
37
39
|
expect(service).to.exist
|
|
38
40
|
})
|
|
39
41
|
|
|
@@ -69,7 +71,7 @@ describe('Service', () => {
|
|
|
69
71
|
})
|
|
70
72
|
|
|
71
73
|
describe('.handler(request)', () => {
|
|
72
|
-
const service = new Service(modules, 'https://example.com/api/',
|
|
74
|
+
const service = new Service(modules, 'https://example.com/api/', `${ROOT_PATH}/examples`)
|
|
73
75
|
const exec = test.execute(service)
|
|
74
76
|
|
|
75
77
|
const authorization = test.createAccessToken({}, { group: 'Administrators' })
|
|
@@ -5,8 +5,6 @@ const { keyBy } = require('lodash')
|
|
|
5
5
|
const loadSync = require('./loadSync')
|
|
6
6
|
const { readdirSync, statSync } = require('fs')
|
|
7
7
|
|
|
8
|
-
const ROOT_PATH = process.cwd()
|
|
9
|
-
|
|
10
8
|
const listFilesSync = dir =>
|
|
11
9
|
readdirSync(dir)
|
|
12
10
|
.reduce((files, file) =>
|
|
@@ -16,7 +14,7 @@ const listFilesSync = dir =>
|
|
|
16
14
|
, [])
|
|
17
15
|
|
|
18
16
|
const readSchemasSync = path =>
|
|
19
|
-
listFilesSync(
|
|
17
|
+
listFilesSync(path)
|
|
20
18
|
.filter(fileName => fileName.endsWith('.yaml'))
|
|
21
19
|
.map(schemaPath => loadSync(schemaPath))
|
|
22
20
|
|