@creator.co/wapi 1.2.2 → 1.2.4
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/.eslintrc.cjs +29 -22
- package/.github/workflows/npmpublish.yml +2 -5
- package/.github/workflows/prs.yml +1 -1
- package/README.md +1 -3
- package/dist/index.d.ts +11 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/jest.config.d.ts +3 -0
- package/dist/jest.config.js +34 -0
- package/dist/jest.config.js.map +1 -0
- package/dist/package.json +64 -0
- package/dist/src/API/Request.d.ts +140 -0
- package/dist/src/API/Request.js +182 -0
- package/dist/src/API/Request.js.map +1 -0
- package/dist/src/API/Response.d.ts +256 -0
- package/dist/src/API/Response.js +398 -0
- package/dist/src/API/Response.js.map +1 -0
- package/dist/src/API/Utils.d.ts +63 -0
- package/dist/src/API/Utils.js +104 -0
- package/dist/src/API/Utils.js.map +1 -0
- package/dist/src/BaseEvent/EventProcessor.d.ts +81 -0
- package/dist/src/BaseEvent/EventProcessor.js +182 -0
- package/dist/src/BaseEvent/EventProcessor.js.map +1 -0
- package/dist/src/BaseEvent/Process.d.ts +74 -0
- package/dist/src/BaseEvent/Process.js +142 -0
- package/dist/src/BaseEvent/Process.js.map +1 -0
- package/dist/src/BaseEvent/Transaction.d.ts +29 -0
- package/dist/src/BaseEvent/Transaction.js +244 -0
- package/dist/src/BaseEvent/Transaction.js.map +1 -0
- package/dist/src/Config/Configuration.d.ts +131 -0
- package/dist/src/Config/Configuration.js +153 -0
- package/dist/src/Config/Configuration.js.map +1 -0
- package/dist/src/Config/EnvironmentVar.d.ts +101 -0
- package/dist/src/Config/EnvironmentVar.js +213 -0
- package/dist/src/Config/EnvironmentVar.js.map +1 -0
- package/dist/src/Crypto/Crypto.d.ts +57 -0
- package/dist/src/Crypto/Crypto.js +126 -0
- package/dist/src/Crypto/Crypto.js.map +1 -0
- package/dist/src/Crypto/JWT.d.ts +64 -0
- package/dist/src/Crypto/JWT.js +74 -0
- package/dist/src/Crypto/JWT.js.map +1 -0
- package/dist/src/Globals.d.ts +161 -0
- package/dist/src/Globals.js +173 -0
- package/dist/src/Globals.js.map +1 -0
- package/dist/src/Logger/Logger.d.ts +180 -0
- package/dist/src/Logger/Logger.js +412 -0
- package/dist/src/Logger/Logger.js.map +1 -0
- package/dist/src/Mailer/Mailer.d.ts +107 -0
- package/dist/src/Mailer/Mailer.js +313 -0
- package/dist/src/Mailer/Mailer.js.map +1 -0
- package/dist/src/Publisher/Publisher.d.ts +47 -0
- package/dist/src/Publisher/Publisher.js +141 -0
- package/dist/src/Publisher/Publisher.js.map +1 -0
- package/dist/src/Server/RouteResolver.d.ts +41 -0
- package/dist/src/Server/RouteResolver.js +135 -0
- package/dist/src/Server/RouteResolver.js.map +1 -0
- package/dist/src/Server/Router.d.ts +104 -0
- package/dist/src/Server/Router.js +45 -0
- package/dist/src/Server/Router.js.map +1 -0
- package/dist/src/Server/lib/ContainerServer.d.ts +58 -0
- package/dist/src/Server/lib/ContainerServer.js +143 -0
- package/dist/src/Server/lib/ContainerServer.js.map +1 -0
- package/dist/src/Server/lib/Server.d.ts +60 -0
- package/dist/src/Server/lib/Server.js +137 -0
- package/dist/src/Server/lib/Server.js.map +1 -0
- package/dist/src/Server/lib/container/GenericHandler.d.ts +4 -0
- package/dist/src/Server/lib/container/GenericHandler.js +138 -0
- package/dist/src/Server/lib/container/GenericHandler.js.map +1 -0
- package/dist/src/Server/lib/container/GenericHandlerEvent.d.ts +67 -0
- package/dist/src/Server/lib/container/GenericHandlerEvent.js +189 -0
- package/dist/src/Server/lib/container/GenericHandlerEvent.js.map +1 -0
- package/dist/src/Server/lib/container/HealthHandler.d.ts +3 -0
- package/dist/src/Server/lib/container/HealthHandler.js +45 -0
- package/dist/src/Server/lib/container/HealthHandler.js.map +1 -0
- package/dist/src/Server/lib/container/Proxy.d.ts +95 -0
- package/dist/src/Server/lib/container/Proxy.js +201 -0
- package/dist/src/Server/lib/container/Proxy.js.map +1 -0
- package/dist/src/Server/lib/container/Utils.d.ts +18 -0
- package/dist/src/Server/lib/container/Utils.js +84 -0
- package/dist/src/Server/lib/container/Utils.js.map +1 -0
- package/dist/src/Validation/Validator.d.ts +21 -0
- package/dist/src/Validation/Validator.js +48 -0
- package/dist/src/Validation/Validator.js.map +1 -0
- package/index.ts +12 -10
- package/jest.config.ts +14 -21
- package/package.json +3 -3
- package/src/API/Request.ts +17 -35
- package/src/API/Response.ts +24 -42
- package/src/API/Utils.ts +5 -7
- package/src/BaseEvent/EventProcessor.ts +16 -24
- package/src/BaseEvent/Process.ts +7 -12
- package/src/BaseEvent/Transaction.ts +25 -43
- package/src/Config/Configuration.ts +8 -14
- package/src/Config/EnvironmentVar.ts +10 -20
- package/src/Crypto/Crypto.ts +10 -10
- package/src/Crypto/JWT.ts +4 -10
- package/src/Globals.ts +19 -25
- package/src/Logger/Logger.ts +36 -51
- package/src/Mailer/Mailer.ts +19 -31
- package/src/Publisher/Publisher.ts +7 -12
- package/src/Server/RouteResolver.ts +5 -6
- package/src/Server/Router.ts +7 -12
- package/src/Server/lib/ContainerServer.ts +5 -5
- package/src/Server/lib/Server.ts +26 -38
- package/src/Server/lib/container/GenericHandler.ts +8 -13
- package/src/Server/lib/container/GenericHandlerEvent.ts +21 -35
- package/src/Server/lib/container/HealthHandler.ts +2 -2
- package/src/Server/lib/container/Proxy.ts +26 -38
- package/src/Server/lib/container/Utils.ts +2 -2
- package/src/Validation/Validator.ts +6 -6
- package/tests/API/Request.test.ts +107 -111
- package/tests/API/Response.test.ts +86 -91
- package/tests/API/Utils.test.ts +64 -64
- package/tests/BaseEvent/EventProcessor.test.ts +68 -84
- package/tests/BaseEvent/Process.test.ts +11 -11
- package/tests/BaseEvent/Transaction.test.ts +44 -53
- package/tests/Config/Config.test.ts +50 -50
- package/tests/Config/EnvironmentVar.test.ts +50 -59
- package/tests/Crypto/Crypto.test.ts +20 -22
- package/tests/Crypto/JWT.test.ts +40 -40
- package/tests/Logger/Logger.test.ts +24 -36
- package/tests/Mailer/Mailer.test.ts +21 -29
- package/tests/Publisher/Publisher.test.ts +18 -18
- package/tests/Server/RouteResolver.test.ts +56 -59
- package/tests/Server/Router.test.ts +16 -16
- package/tests/Server/lib/ContainerServer.test.ts +83 -85
- package/tests/Server/lib/Server.test.ts +4 -4
- package/tests/Server/lib/container/GenericHandler.test.ts +31 -41
- package/tests/Server/lib/container/GenericHandlerEvent.test.ts +35 -36
- package/tests/Server/lib/container/HealthHandler.test.ts +7 -7
- package/tests/Server/lib/container/Proxy.test.ts +66 -79
- package/tests/Server/lib/container/Utils.test.ts +16 -17
- package/tests/Test.utils.ts +9 -9
- package/tests/Validation/Validator.test.ts +28 -40
- package/tests/main.test.ts +2 -2
|
@@ -1,84 +1,72 @@
|
|
|
1
|
-
import { expect } from
|
|
1
|
+
import { expect } from 'chai'
|
|
2
2
|
|
|
3
|
-
import Response from
|
|
4
|
-
import Globals from
|
|
5
|
-
import Validator from
|
|
6
|
-
import { ViewSchema } from
|
|
3
|
+
import Response from '../../src/API/Response'
|
|
4
|
+
import Globals from '../../src/Globals'
|
|
5
|
+
import Validator from '../../src/Validation/Validator'
|
|
6
|
+
import { ViewSchema } from '../Test.utils'
|
|
7
7
|
|
|
8
8
|
function expectFullFailure(validationResult, c = 4) {
|
|
9
9
|
expect(validationResult).to.be.an.instanceof(Response)
|
|
10
10
|
if (validationResult instanceof Response) {
|
|
11
11
|
expect(validationResult.getBody()).is.not.null
|
|
12
|
-
expect(validationResult.getBody()).to.have.property(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
)
|
|
16
|
-
expect(validationResult.getBody()).to.have.property(
|
|
17
|
-
"errCode",
|
|
18
|
-
Globals.ErrorCode_InvalidInput,
|
|
19
|
-
)
|
|
20
|
-
expect(validationResult.getBody()).to.have.property("validationFailure")
|
|
21
|
-
expect(validationResult.getBody()["validationFailure"]).to.have.lengthOf(c)
|
|
12
|
+
expect(validationResult.getBody()).to.have.property('err', Globals.ErrorResponseValidationFail)
|
|
13
|
+
expect(validationResult.getBody()).to.have.property('errCode', Globals.ErrorCode_InvalidInput)
|
|
14
|
+
expect(validationResult.getBody()).to.have.property('validationFailure')
|
|
15
|
+
expect(validationResult.getBody()['validationFailure']).to.have.lengthOf(c)
|
|
22
16
|
expect(validationResult.getCode()).is.equals(400)
|
|
23
17
|
}
|
|
24
18
|
}
|
|
25
19
|
|
|
26
|
-
describe(
|
|
27
|
-
test(
|
|
28
|
-
const validationResult = Validator.validateSchema(
|
|
29
|
-
async () => {},
|
|
30
|
-
ViewSchema,
|
|
31
|
-
)
|
|
20
|
+
describe('Validates unsuccessfully', () => {
|
|
21
|
+
test('Fails to validate async', () => {
|
|
22
|
+
const validationResult = Validator.validateSchema(async () => {}, ViewSchema)
|
|
32
23
|
expectFullFailure(validationResult, 1)
|
|
33
24
|
})
|
|
34
25
|
|
|
35
|
-
test(
|
|
26
|
+
test('Fails to validate null', () => {
|
|
36
27
|
const validationResult = Validator.validateSchema(null, ViewSchema)
|
|
37
28
|
expectFullFailure(validationResult, 1)
|
|
38
29
|
})
|
|
39
30
|
|
|
40
|
-
test(
|
|
41
|
-
const validationResult = Validator.validateSchema(
|
|
31
|
+
test('Fails to validate empty string', () => {
|
|
32
|
+
const validationResult = Validator.validateSchema('', ViewSchema)
|
|
42
33
|
expectFullFailure(validationResult, 1)
|
|
43
34
|
})
|
|
44
35
|
|
|
45
|
-
test(
|
|
36
|
+
test('Fails to validate empty object', () => {
|
|
46
37
|
const validationResult = Validator.validateSchema({}, ViewSchema)
|
|
47
38
|
expectFullFailure(validationResult)
|
|
48
39
|
})
|
|
49
40
|
|
|
50
|
-
test(
|
|
51
|
-
const validationResult = Validator.validateSchema(
|
|
52
|
-
{ name: "Joe" },
|
|
53
|
-
ViewSchema,
|
|
54
|
-
)
|
|
41
|
+
test('Fails to validate object with wrong keys', () => {
|
|
42
|
+
const validationResult = Validator.validateSchema({ name: 'Joe' }, ViewSchema)
|
|
55
43
|
expectFullFailure(validationResult)
|
|
56
44
|
})
|
|
57
45
|
|
|
58
|
-
test(
|
|
46
|
+
test('Fails to validate object with wrong key types', () => {
|
|
59
47
|
const validationResult = Validator.validateSchema({ id: 123 }, ViewSchema)
|
|
60
48
|
expectFullFailure(validationResult)
|
|
61
49
|
if (validationResult instanceof Response) {
|
|
62
|
-
console.log(validationResult.getBody()[
|
|
50
|
+
console.log(validationResult.getBody()['validationFailure'])
|
|
63
51
|
expect(
|
|
64
|
-
validationResult.getBody()[
|
|
65
|
-
return f.message ==
|
|
66
|
-
})
|
|
52
|
+
validationResult.getBody()['validationFailure'].filter(f => {
|
|
53
|
+
return f.message == 'Expected string, received number'
|
|
54
|
+
})
|
|
67
55
|
).to.have.lengthOf(1)
|
|
68
56
|
}
|
|
69
57
|
})
|
|
70
58
|
})
|
|
71
59
|
|
|
72
|
-
describe(
|
|
73
|
-
test(
|
|
60
|
+
describe('Validates successfully', () => {
|
|
61
|
+
test('Succeeds to validate', () => {
|
|
74
62
|
const validationResult = Validator.validateSchema(
|
|
75
63
|
{
|
|
76
|
-
id:
|
|
77
|
-
content:
|
|
64
|
+
id: '123',
|
|
65
|
+
content: '123',
|
|
78
66
|
createdAt: new Date(),
|
|
79
67
|
updatedAt: new Date(),
|
|
80
68
|
},
|
|
81
|
-
ViewSchema
|
|
69
|
+
ViewSchema
|
|
82
70
|
)
|
|
83
71
|
expect(validationResult).to.not.be.an.instanceof(Response)
|
|
84
72
|
expect(validationResult).to.be.true
|
package/tests/main.test.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
// import type * as Silly from "../silly"
|
|
5
5
|
// const { sillyFunction } = jest.requireActual<typeof Silly>("../silly")
|
|
6
6
|
|
|
7
|
-
describe(
|
|
8
|
-
test(
|
|
7
|
+
describe('silly function', () => {
|
|
8
|
+
test('guaranteed random', () => {
|
|
9
9
|
expect(4).toBe(4)
|
|
10
10
|
})
|
|
11
11
|
})
|