@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.
Files changed (135) hide show
  1. package/.eslintrc.cjs +29 -22
  2. package/.github/workflows/npmpublish.yml +2 -5
  3. package/.github/workflows/prs.yml +1 -1
  4. package/README.md +1 -3
  5. package/dist/index.d.ts +11 -0
  6. package/dist/index.js +24 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/jest.config.d.ts +3 -0
  9. package/dist/jest.config.js +34 -0
  10. package/dist/jest.config.js.map +1 -0
  11. package/dist/package.json +64 -0
  12. package/dist/src/API/Request.d.ts +140 -0
  13. package/dist/src/API/Request.js +182 -0
  14. package/dist/src/API/Request.js.map +1 -0
  15. package/dist/src/API/Response.d.ts +256 -0
  16. package/dist/src/API/Response.js +398 -0
  17. package/dist/src/API/Response.js.map +1 -0
  18. package/dist/src/API/Utils.d.ts +63 -0
  19. package/dist/src/API/Utils.js +104 -0
  20. package/dist/src/API/Utils.js.map +1 -0
  21. package/dist/src/BaseEvent/EventProcessor.d.ts +81 -0
  22. package/dist/src/BaseEvent/EventProcessor.js +182 -0
  23. package/dist/src/BaseEvent/EventProcessor.js.map +1 -0
  24. package/dist/src/BaseEvent/Process.d.ts +74 -0
  25. package/dist/src/BaseEvent/Process.js +142 -0
  26. package/dist/src/BaseEvent/Process.js.map +1 -0
  27. package/dist/src/BaseEvent/Transaction.d.ts +29 -0
  28. package/dist/src/BaseEvent/Transaction.js +244 -0
  29. package/dist/src/BaseEvent/Transaction.js.map +1 -0
  30. package/dist/src/Config/Configuration.d.ts +131 -0
  31. package/dist/src/Config/Configuration.js +153 -0
  32. package/dist/src/Config/Configuration.js.map +1 -0
  33. package/dist/src/Config/EnvironmentVar.d.ts +101 -0
  34. package/dist/src/Config/EnvironmentVar.js +213 -0
  35. package/dist/src/Config/EnvironmentVar.js.map +1 -0
  36. package/dist/src/Crypto/Crypto.d.ts +57 -0
  37. package/dist/src/Crypto/Crypto.js +126 -0
  38. package/dist/src/Crypto/Crypto.js.map +1 -0
  39. package/dist/src/Crypto/JWT.d.ts +64 -0
  40. package/dist/src/Crypto/JWT.js +74 -0
  41. package/dist/src/Crypto/JWT.js.map +1 -0
  42. package/dist/src/Globals.d.ts +161 -0
  43. package/dist/src/Globals.js +173 -0
  44. package/dist/src/Globals.js.map +1 -0
  45. package/dist/src/Logger/Logger.d.ts +180 -0
  46. package/dist/src/Logger/Logger.js +412 -0
  47. package/dist/src/Logger/Logger.js.map +1 -0
  48. package/dist/src/Mailer/Mailer.d.ts +107 -0
  49. package/dist/src/Mailer/Mailer.js +313 -0
  50. package/dist/src/Mailer/Mailer.js.map +1 -0
  51. package/dist/src/Publisher/Publisher.d.ts +47 -0
  52. package/dist/src/Publisher/Publisher.js +141 -0
  53. package/dist/src/Publisher/Publisher.js.map +1 -0
  54. package/dist/src/Server/RouteResolver.d.ts +41 -0
  55. package/dist/src/Server/RouteResolver.js +135 -0
  56. package/dist/src/Server/RouteResolver.js.map +1 -0
  57. package/dist/src/Server/Router.d.ts +104 -0
  58. package/dist/src/Server/Router.js +45 -0
  59. package/dist/src/Server/Router.js.map +1 -0
  60. package/dist/src/Server/lib/ContainerServer.d.ts +58 -0
  61. package/dist/src/Server/lib/ContainerServer.js +143 -0
  62. package/dist/src/Server/lib/ContainerServer.js.map +1 -0
  63. package/dist/src/Server/lib/Server.d.ts +60 -0
  64. package/dist/src/Server/lib/Server.js +137 -0
  65. package/dist/src/Server/lib/Server.js.map +1 -0
  66. package/dist/src/Server/lib/container/GenericHandler.d.ts +4 -0
  67. package/dist/src/Server/lib/container/GenericHandler.js +138 -0
  68. package/dist/src/Server/lib/container/GenericHandler.js.map +1 -0
  69. package/dist/src/Server/lib/container/GenericHandlerEvent.d.ts +67 -0
  70. package/dist/src/Server/lib/container/GenericHandlerEvent.js +189 -0
  71. package/dist/src/Server/lib/container/GenericHandlerEvent.js.map +1 -0
  72. package/dist/src/Server/lib/container/HealthHandler.d.ts +3 -0
  73. package/dist/src/Server/lib/container/HealthHandler.js +45 -0
  74. package/dist/src/Server/lib/container/HealthHandler.js.map +1 -0
  75. package/dist/src/Server/lib/container/Proxy.d.ts +95 -0
  76. package/dist/src/Server/lib/container/Proxy.js +201 -0
  77. package/dist/src/Server/lib/container/Proxy.js.map +1 -0
  78. package/dist/src/Server/lib/container/Utils.d.ts +18 -0
  79. package/dist/src/Server/lib/container/Utils.js +84 -0
  80. package/dist/src/Server/lib/container/Utils.js.map +1 -0
  81. package/dist/src/Validation/Validator.d.ts +21 -0
  82. package/dist/src/Validation/Validator.js +48 -0
  83. package/dist/src/Validation/Validator.js.map +1 -0
  84. package/index.ts +12 -10
  85. package/jest.config.ts +14 -21
  86. package/package.json +3 -3
  87. package/src/API/Request.ts +17 -35
  88. package/src/API/Response.ts +24 -42
  89. package/src/API/Utils.ts +5 -7
  90. package/src/BaseEvent/EventProcessor.ts +16 -24
  91. package/src/BaseEvent/Process.ts +7 -12
  92. package/src/BaseEvent/Transaction.ts +25 -43
  93. package/src/Config/Configuration.ts +8 -14
  94. package/src/Config/EnvironmentVar.ts +10 -20
  95. package/src/Crypto/Crypto.ts +10 -10
  96. package/src/Crypto/JWT.ts +4 -10
  97. package/src/Globals.ts +19 -25
  98. package/src/Logger/Logger.ts +36 -51
  99. package/src/Mailer/Mailer.ts +19 -31
  100. package/src/Publisher/Publisher.ts +7 -12
  101. package/src/Server/RouteResolver.ts +5 -6
  102. package/src/Server/Router.ts +7 -12
  103. package/src/Server/lib/ContainerServer.ts +5 -5
  104. package/src/Server/lib/Server.ts +26 -38
  105. package/src/Server/lib/container/GenericHandler.ts +8 -13
  106. package/src/Server/lib/container/GenericHandlerEvent.ts +21 -35
  107. package/src/Server/lib/container/HealthHandler.ts +2 -2
  108. package/src/Server/lib/container/Proxy.ts +26 -38
  109. package/src/Server/lib/container/Utils.ts +2 -2
  110. package/src/Validation/Validator.ts +6 -6
  111. package/tests/API/Request.test.ts +107 -111
  112. package/tests/API/Response.test.ts +86 -91
  113. package/tests/API/Utils.test.ts +64 -64
  114. package/tests/BaseEvent/EventProcessor.test.ts +68 -84
  115. package/tests/BaseEvent/Process.test.ts +11 -11
  116. package/tests/BaseEvent/Transaction.test.ts +44 -53
  117. package/tests/Config/Config.test.ts +50 -50
  118. package/tests/Config/EnvironmentVar.test.ts +50 -59
  119. package/tests/Crypto/Crypto.test.ts +20 -22
  120. package/tests/Crypto/JWT.test.ts +40 -40
  121. package/tests/Logger/Logger.test.ts +24 -36
  122. package/tests/Mailer/Mailer.test.ts +21 -29
  123. package/tests/Publisher/Publisher.test.ts +18 -18
  124. package/tests/Server/RouteResolver.test.ts +56 -59
  125. package/tests/Server/Router.test.ts +16 -16
  126. package/tests/Server/lib/ContainerServer.test.ts +83 -85
  127. package/tests/Server/lib/Server.test.ts +4 -4
  128. package/tests/Server/lib/container/GenericHandler.test.ts +31 -41
  129. package/tests/Server/lib/container/GenericHandlerEvent.test.ts +35 -36
  130. package/tests/Server/lib/container/HealthHandler.test.ts +7 -7
  131. package/tests/Server/lib/container/Proxy.test.ts +66 -79
  132. package/tests/Server/lib/container/Utils.test.ts +16 -17
  133. package/tests/Test.utils.ts +9 -9
  134. package/tests/Validation/Validator.test.ts +28 -40
  135. package/tests/main.test.ts +2 -2
@@ -1,84 +1,72 @@
1
- import { expect } from "chai"
1
+ import { expect } from 'chai'
2
2
 
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"
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
- "err",
14
- Globals.ErrorResponseValidationFail,
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("Validates unsuccessfully", () => {
27
- test("Fails to validate async", () => {
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("Fails to validate null", () => {
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("Fails to validate empty string", () => {
41
- const validationResult = Validator.validateSchema("", ViewSchema)
31
+ test('Fails to validate empty string', () => {
32
+ const validationResult = Validator.validateSchema('', ViewSchema)
42
33
  expectFullFailure(validationResult, 1)
43
34
  })
44
35
 
45
- test("Fails to validate empty object", () => {
36
+ test('Fails to validate empty object', () => {
46
37
  const validationResult = Validator.validateSchema({}, ViewSchema)
47
38
  expectFullFailure(validationResult)
48
39
  })
49
40
 
50
- test("Fails to validate object with wrong keys", () => {
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("Fails to validate object with wrong key types", () => {
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()["validationFailure"])
50
+ console.log(validationResult.getBody()['validationFailure'])
63
51
  expect(
64
- validationResult.getBody()["validationFailure"].filter((f) => {
65
- return f.message == "Expected string, received number"
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("Validates successfully", () => {
73
- test("Succeeds to validate", () => {
60
+ describe('Validates successfully', () => {
61
+ test('Succeeds to validate', () => {
74
62
  const validationResult = Validator.validateSchema(
75
63
  {
76
- id: "123",
77
- content: "123",
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
@@ -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("silly function", () => {
8
- test("guaranteed random", () => {
7
+ describe('silly function', () => {
8
+ test('guaranteed random', () => {
9
9
  expect(4).toBe(4)
10
10
  })
11
11
  })