@creator.co/wapi 1.2.4 → 1.2.6

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 (153) hide show
  1. package/.github/workflows/npmpublish.yml +1 -1
  2. package/README.md +216 -5
  3. package/dist/index.d.ts +15 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/jest.config.js +1 -1
  6. package/dist/jest.config.js.map +1 -1
  7. package/dist/package.json +13 -2
  8. package/dist/src/API/Request.d.ts +45 -82
  9. package/dist/src/API/Request.js +49 -77
  10. package/dist/src/API/Request.js.map +1 -1
  11. package/dist/src/API/Response.d.ts +94 -163
  12. package/dist/src/API/Response.js +101 -161
  13. package/dist/src/API/Response.js.map +1 -1
  14. package/dist/src/API/Utils.d.ts +21 -42
  15. package/dist/src/API/Utils.js +22 -43
  16. package/dist/src/API/Utils.js.map +1 -1
  17. package/dist/src/BaseEvent/EventProcessor.d.ts +32 -55
  18. package/dist/src/BaseEvent/EventProcessor.js +30 -38
  19. package/dist/src/BaseEvent/EventProcessor.js.map +1 -1
  20. package/dist/src/BaseEvent/Process.d.ts +20 -43
  21. package/dist/src/BaseEvent/Process.js +16 -27
  22. package/dist/src/BaseEvent/Process.js.map +1 -1
  23. package/dist/src/BaseEvent/Transaction.d.ts +104 -2
  24. package/dist/src/BaseEvent/Transaction.js +196 -41
  25. package/dist/src/BaseEvent/Transaction.js.map +1 -1
  26. package/dist/src/Config/Configuration.d.ts +48 -66
  27. package/dist/src/Config/Configuration.js +25 -42
  28. package/dist/src/Config/Configuration.js.map +1 -1
  29. package/dist/src/Config/EnvironmentVar.d.ts +30 -57
  30. package/dist/src/Config/EnvironmentVar.js +28 -41
  31. package/dist/src/Config/EnvironmentVar.js.map +1 -1
  32. package/dist/src/Crypto/Crypto.d.ts +17 -35
  33. package/dist/src/Crypto/Crypto.js +12 -21
  34. package/dist/src/Crypto/Crypto.js.map +1 -1
  35. package/dist/src/Crypto/JWT.d.ts +21 -32
  36. package/dist/src/Crypto/JWT.js +14 -22
  37. package/dist/src/Crypto/JWT.js.map +1 -1
  38. package/dist/src/Database/Database.d.ts +18 -0
  39. package/dist/src/Database/Database.js +18 -0
  40. package/dist/src/Database/Database.js.map +1 -0
  41. package/dist/src/Database/DatabaseManager.d.ts +32 -0
  42. package/dist/src/Database/DatabaseManager.js +50 -0
  43. package/dist/src/Database/DatabaseManager.js.map +1 -0
  44. package/dist/src/Database/DatabaseTransaction.d.ts +65 -0
  45. package/dist/src/Database/DatabaseTransaction.js +183 -0
  46. package/dist/src/Database/DatabaseTransaction.js.map +1 -0
  47. package/dist/src/Database/integrations/knex/KnexDatabase.d.ts +22 -0
  48. package/dist/src/Database/integrations/knex/KnexDatabase.js +108 -0
  49. package/dist/src/Database/integrations/knex/KnexDatabase.js.map +1 -0
  50. package/dist/src/Database/integrations/knex/KnexTransaction.d.ts +37 -0
  51. package/dist/src/Database/integrations/knex/KnexTransaction.js +60 -0
  52. package/dist/src/Database/integrations/knex/KnexTransaction.js.map +1 -0
  53. package/dist/src/Database/integrations/pgsql/PostgresDatabase.d.ts +30 -0
  54. package/dist/src/Database/integrations/pgsql/PostgresDatabase.js +108 -0
  55. package/dist/src/Database/integrations/pgsql/PostgresDatabase.js.map +1 -0
  56. package/dist/src/Database/integrations/pgsql/PostgresTransaction.d.ts +37 -0
  57. package/dist/src/Database/integrations/pgsql/PostgresTransaction.js +60 -0
  58. package/dist/src/Database/integrations/pgsql/PostgresTransaction.js.map +1 -0
  59. package/dist/src/Globals.d.ts +26 -94
  60. package/dist/src/Globals.js +26 -95
  61. package/dist/src/Globals.js.map +1 -1
  62. package/dist/src/Logger/Logger.d.ts +82 -105
  63. package/dist/src/Logger/Logger.js +111 -136
  64. package/dist/src/Logger/Logger.js.map +1 -1
  65. package/dist/src/Mailer/Mailer.d.ts +39 -75
  66. package/dist/src/Mailer/Mailer.js +36 -65
  67. package/dist/src/Mailer/Mailer.js.map +1 -1
  68. package/dist/src/Publisher/Publisher.d.ts +17 -25
  69. package/dist/src/Publisher/Publisher.js +21 -32
  70. package/dist/src/Publisher/Publisher.js.map +1 -1
  71. package/dist/src/Server/RouteResolver.d.ts +14 -22
  72. package/dist/src/Server/RouteResolver.js +21 -34
  73. package/dist/src/Server/RouteResolver.js.map +1 -1
  74. package/dist/src/Server/Router.d.ts +72 -51
  75. package/dist/src/Server/Router.js +8 -17
  76. package/dist/src/Server/Router.js.map +1 -1
  77. package/dist/src/Server/lib/ContainerServer.d.ts +15 -31
  78. package/dist/src/Server/lib/ContainerServer.js +13 -28
  79. package/dist/src/Server/lib/ContainerServer.js.map +1 -1
  80. package/dist/src/Server/lib/Server.d.ts +17 -32
  81. package/dist/src/Server/lib/Server.js +18 -28
  82. package/dist/src/Server/lib/Server.js.map +1 -1
  83. package/dist/src/Server/lib/container/GenericHandler.d.ts +5 -0
  84. package/dist/src/Server/lib/container/GenericHandler.js +16 -3
  85. package/dist/src/Server/lib/container/GenericHandler.js.map +1 -1
  86. package/dist/src/Server/lib/container/GenericHandlerEvent.d.ts +22 -37
  87. package/dist/src/Server/lib/container/GenericHandlerEvent.js +29 -41
  88. package/dist/src/Server/lib/container/GenericHandlerEvent.js.map +1 -1
  89. package/dist/src/Server/lib/container/HealthHandler.d.ts +6 -0
  90. package/dist/src/Server/lib/container/HealthHandler.js +6 -0
  91. package/dist/src/Server/lib/container/HealthHandler.js.map +1 -1
  92. package/dist/src/Server/lib/container/Proxy.d.ts +24 -52
  93. package/dist/src/Server/lib/container/Proxy.js +52 -52
  94. package/dist/src/Server/lib/container/Proxy.js.map +1 -1
  95. package/dist/src/Server/lib/container/Utils.d.ts +6 -10
  96. package/dist/src/Server/lib/container/Utils.js +6 -10
  97. package/dist/src/Server/lib/container/Utils.js.map +1 -1
  98. package/dist/src/Validation/Validator.d.ts +9 -13
  99. package/dist/src/Validation/Validator.js +8 -12
  100. package/dist/src/Validation/Validator.js.map +1 -1
  101. package/index.ts +15 -0
  102. package/jest.config.ts +1 -1
  103. package/package.json +13 -2
  104. package/src/API/Request.ts +66 -84
  105. package/src/API/Response.ts +144 -203
  106. package/src/API/Utils.ts +28 -44
  107. package/src/BaseEvent/EventProcessor.ts +52 -77
  108. package/src/BaseEvent/Process.ts +27 -52
  109. package/src/BaseEvent/Transaction.ts +147 -27
  110. package/src/Config/Configuration.ts +59 -76
  111. package/src/Config/EnvironmentVar.ts +39 -62
  112. package/src/Crypto/Crypto.ts +20 -36
  113. package/src/Crypto/JWT.ts +31 -35
  114. package/src/Database/Database.ts +19 -0
  115. package/src/Database/DatabaseManager.ts +51 -0
  116. package/src/Database/DatabaseTransaction.ts +118 -0
  117. package/src/Database/integrations/knex/KnexDatabase.ts +47 -0
  118. package/src/Database/integrations/knex/KnexTransaction.ts +51 -0
  119. package/src/Database/integrations/pgsql/PostgresDatabase.ts +49 -0
  120. package/src/Database/integrations/pgsql/PostgresTransaction.ts +54 -0
  121. package/src/Database/types.d.ts +49 -0
  122. package/src/Globals.ts +28 -96
  123. package/src/Logger/Logger.ts +141 -160
  124. package/src/Mailer/Mailer.ts +43 -76
  125. package/src/Publisher/Publisher.ts +31 -40
  126. package/src/Server/RouteResolver.ts +31 -52
  127. package/src/Server/Router.ts +75 -54
  128. package/src/Server/lib/ContainerServer.ts +20 -32
  129. package/src/Server/lib/Server.ts +19 -34
  130. package/src/Server/lib/container/GenericHandler.ts +17 -3
  131. package/src/Server/lib/container/GenericHandlerEvent.ts +44 -54
  132. package/src/Server/lib/container/HealthHandler.ts +6 -0
  133. package/src/Server/lib/container/Proxy.ts +39 -58
  134. package/src/Server/lib/container/Utils.ts +7 -10
  135. package/src/Validation/Validator.ts +11 -13
  136. package/tests/API/Response.test.ts +55 -56
  137. package/tests/BaseEvent/EventProcessor.test.ts +49 -50
  138. package/tests/BaseEvent/Process.test.ts +2 -2
  139. package/tests/BaseEvent/Transaction.test.ts +102 -44
  140. package/tests/Config/Config.test.ts +27 -27
  141. package/tests/Config/EnvironmentVar.test.ts +54 -18
  142. package/tests/Database/DatabaseManager.test.ts +55 -0
  143. package/tests/Database/integrations/knex/KnexDatabase.test.ts +53 -0
  144. package/tests/Database/integrations/knex/KnexTransaction.test.ts +133 -0
  145. package/tests/Database/integrations/pg/PostgresDatabase.test.ts +50 -0
  146. package/tests/Database/integrations/pg/PostgresTransaction.test.ts +51 -0
  147. package/tests/Publisher/Publisher.test.ts +3 -3
  148. package/tests/Server/lib/ContainerServer.test.ts +21 -22
  149. package/tests/Server/lib/container/GenericHandler.test.ts +31 -32
  150. package/tests/Server/lib/container/GenericHandlerEvent.test.ts +2 -2
  151. package/tests/Server/lib/container/HealthHandler.test.ts +6 -7
  152. package/tests/Server/lib/container/Proxy.test.ts +37 -35
  153. package/tsconfig.json +6 -1
@@ -1,6 +1,5 @@
1
- import { expect as j_expect } from '@jest/globals'
2
1
  import { APIGatewayProxyEvent, Context } from 'aws-lambda'
3
- import { expect } from 'chai'
2
+ import { expect as c_expect } from 'chai'
4
3
  import { Request, Response } from 'express'
5
4
 
6
5
  import Globals from '../../../../src/Globals'
@@ -28,11 +27,11 @@ describe('GenericHandler success invocation path', () => {
28
27
  const resp = observableResponse()
29
28
  const handlerResp = await handler(<Request>(<unknown>{}), resp)
30
29
  //
31
- expect(handlerResp).to.be.undefined
32
- j_expect(resp.send).not.toBeCalled()
33
- j_expect(resp.json).toBeCalledWith(JSON.parse(v.body))
34
- j_expect(resp.status).toBeCalledWith(v.statusCode)
35
- j_expect(resp.header).not.toBeCalled()
30
+ c_expect(handlerResp).to.be.undefined
31
+ expect(resp.send).not.toBeCalled()
32
+ expect(resp.json).toBeCalledWith(JSON.parse(v.body))
33
+ expect(resp.status).toBeCalledWith(v.statusCode)
34
+ expect(resp.header).not.toBeCalled()
36
35
  })
37
36
 
38
37
  test('Simple success w/ headers', async () => {
@@ -47,11 +46,11 @@ describe('GenericHandler success invocation path', () => {
47
46
  const resp = observableResponse()
48
47
  const handlerResp = await handler(<Request>(<unknown>{}), resp)
49
48
  //
50
- expect(handlerResp).to.be.undefined
51
- j_expect(resp.send).not.toBeCalled()
52
- j_expect(resp.json).toBeCalledWith(JSON.parse(v.body))
53
- j_expect(resp.status).toBeCalledWith(v.statusCode)
54
- j_expect(resp.header).toBeCalledTimes(Object.keys(v.headers).length)
49
+ c_expect(handlerResp).to.be.undefined
50
+ expect(resp.send).not.toBeCalled()
51
+ expect(resp.json).toBeCalledWith(JSON.parse(v.body))
52
+ expect(resp.status).toBeCalledWith(v.statusCode)
53
+ expect(resp.header).toBeCalledTimes(Object.keys(v.headers).length)
55
54
  })
56
55
 
57
56
  test('Simple success w/ null body', async () => {
@@ -65,11 +64,11 @@ describe('GenericHandler success invocation path', () => {
65
64
  const resp = observableResponse()
66
65
  const handlerResp = await handler(<Request>(<unknown>{}), resp)
67
66
  //
68
- expect(handlerResp).to.be.undefined
69
- j_expect(resp.send).not.toBeCalled()
70
- j_expect(resp.json).toBeCalledWith({})
71
- j_expect(resp.status).toBeCalledWith(v.statusCode)
72
- j_expect(resp.header).toBeCalledTimes(Object.keys(v.headers).length)
67
+ c_expect(handlerResp).to.be.undefined
68
+ expect(resp.send).not.toBeCalled()
69
+ expect(resp.json).toBeCalledWith({})
70
+ expect(resp.status).toBeCalledWith(v.statusCode)
71
+ expect(resp.header).toBeCalledTimes(Object.keys(v.headers).length)
73
72
  })
74
73
  })
75
74
 
@@ -81,14 +80,14 @@ describe('GenericHandler failure invocation path', () => {
81
80
  const resp = observableResponse()
82
81
  const handlerResp = await handler(<Request>(<unknown>{}), resp)
83
82
  //
84
- expect(handlerResp).to.be.undefined
85
- j_expect(resp.send).not.toBeCalled()
86
- j_expect(resp.header).not.toBeCalled()
87
- j_expect(resp.json).toBeCalledWith({
83
+ c_expect(handlerResp).to.be.undefined
84
+ expect(resp.send).not.toBeCalled()
85
+ expect(resp.header).not.toBeCalled()
86
+ expect(resp.json).toBeCalledWith({
88
87
  err: Globals.Resp_MSG_INVALIDRESP,
89
88
  errCode: Globals.Resp_CODE_INVALIDRESP,
90
89
  })
91
- j_expect(resp.status).toBeCalledWith(Globals.Resp_STATUSCODE_INVALIDRESP)
90
+ expect(resp.status).toBeCalledWith(Globals.Resp_STATUSCODE_INVALIDRESP)
92
91
  })
93
92
 
94
93
  test('Error response', async () => {
@@ -99,13 +98,13 @@ describe('GenericHandler failure invocation path', () => {
99
98
  const resp = observableResponse()
100
99
  const handlerResp = await handler(<Request>(<unknown>{}), resp)
101
100
  //
102
- expect(handlerResp).to.be.undefined
103
- j_expect(resp.send).not.toBeCalled()
104
- j_expect(resp.header).not.toBeCalled()
105
- j_expect(resp.json).toBeCalledWith({
101
+ c_expect(handlerResp).to.be.undefined
102
+ expect(resp.send).not.toBeCalled()
103
+ expect(resp.header).not.toBeCalled()
104
+ expect(resp.json).toBeCalledWith({
106
105
  err,
107
106
  })
108
- j_expect(resp.status).toBeCalledWith(400)
107
+ expect(resp.status).toBeCalledWith(400)
109
108
  })
110
109
 
111
110
  test('Exception response', async () => {
@@ -116,15 +115,15 @@ describe('GenericHandler failure invocation path', () => {
116
115
  const resp = observableResponse()
117
116
  const handlerResp = await handler(<Request>(<unknown>{}), resp)
118
117
  //
119
- expect(handlerResp).to.be.undefined
120
- j_expect(resp.send).not.toBeCalled()
121
- j_expect(resp.header).not.toBeCalled()
122
- j_expect(resp.json).toBeCalledWith({
118
+ c_expect(handlerResp).to.be.undefined
119
+ expect(resp.send).not.toBeCalled()
120
+ expect(resp.header).not.toBeCalled()
121
+ expect(resp.json).toBeCalledWith({
123
122
  ...err,
124
123
  err: Globals.Resp_MSG_EXCEPTION,
125
124
  errCode: Globals.Resp_CODE_EXCEPTION,
126
125
  })
127
- j_expect(resp.status).toBeCalledWith(Globals.Resp_STATUSCODE_EXCEPTION)
126
+ expect(resp.status).toBeCalledWith(Globals.Resp_STATUSCODE_EXCEPTION)
128
127
  })
129
128
  })
130
129
 
@@ -17,7 +17,7 @@ describe('GenericHandlerEvent invocation paths', () => {
17
17
  )
18
18
  const resp = await event.invoke()
19
19
  expect(resp).to.not.be.null
20
- expect(resp.err).to.be.null
20
+ expect(resp.err).to.be.undefined
21
21
  expect(resp.data).to.be.equals('Success')
22
22
  })
23
23
 
@@ -94,7 +94,7 @@ describe('GenericHandlerEvent event test', () => {
94
94
  )
95
95
  const resp = await event.invoke()
96
96
  expect(resp).to.not.be.null
97
- expect(resp.err).to.be.null
97
+ expect(resp.err).to.be.undefined
98
98
  expect(resp.data).to.be.equals('Success')
99
99
  })
100
100
  })
@@ -1,5 +1,4 @@
1
- import { expect as j_expect } from '@jest/globals'
2
- import { expect } from 'chai'
1
+ import { expect as c_expect } from 'chai'
3
2
  import { Request, Response } from 'express'
4
3
 
5
4
  import HealthHandler from '../../../../src/Server/lib/container/HealthHandler'
@@ -19,11 +18,11 @@ describe('HealthHandler invocation path', () => {
19
18
  const resp = observableResponse()
20
19
  const handlerResp = await HealthHandler(<Request>(<unknown>{}), resp)
21
20
  //
22
- expect(handlerResp).to.be.undefined
23
- j_expect(resp.send).toBeCalledWith('Healthy!')
24
- j_expect(resp.json).not.toBeCalled()
25
- j_expect(resp.status).not.toBeCalled()
26
- j_expect(resp.header).not.toBeCalled()
21
+ c_expect(handlerResp).to.be.undefined
22
+ expect(resp.send).toBeCalledWith('Healthy!')
23
+ expect(resp.json).not.toBeCalled()
24
+ expect(resp.status).not.toBeCalled()
25
+ expect(resp.header).not.toBeCalled()
27
26
  })
28
27
  })
29
28
 
@@ -1,6 +1,5 @@
1
- import { expect as j_expect } from '@jest/globals'
2
1
  import { APIGatewayProxyEvent, Context } from 'aws-lambda'
3
- import { expect } from 'chai'
2
+ import { expect as c_expect } from 'chai'
4
3
  import * as request from 'supertest'
5
4
 
6
5
  import Globals from '../../../../src/Globals'
@@ -25,21 +24,21 @@ describe('Proxy configs', () => {
25
24
  const proxy = new Proxy({ routes: [] }, async () => {})
26
25
  await proxy.load()
27
26
  await proxy.unload('Error')
28
- j_expect(mockExit).toBeCalledWith(1)
27
+ expect(mockExit).toBeCalledWith(1)
29
28
  })
30
29
 
31
30
  test('Simple port config', async () => {
32
31
  const proxy = new Proxy({ routes: [], port: 56562 }, async () => {})
33
32
  await proxy.load()
34
33
  await proxy.unload()
35
- j_expect(mockExit).toBeCalledWith(0)
34
+ expect(mockExit).toBeCalledWith(0)
36
35
  })
37
36
 
38
37
  test('Simple timeout config', async () => {
39
38
  const proxy = new Proxy({ routes: [], timeout: 1000 }, async () => {})
40
39
  await proxy.load()
41
40
  await proxy.unload()
42
- j_expect(mockExit).toBeCalledWith(0)
41
+ expect(mockExit).toBeCalledWith(0)
43
42
  })
44
43
 
45
44
  test('Simple cors config', async () => {
@@ -56,7 +55,7 @@ describe('Proxy configs', () => {
56
55
  )
57
56
  await proxy.load()
58
57
  await proxy.unload()
59
- j_expect(mockExit).toBeCalledWith(0)
58
+ expect(mockExit).toBeCalledWith(0)
60
59
  })
61
60
 
62
61
  test('Empty cors config', async () => {
@@ -69,7 +68,7 @@ describe('Proxy configs', () => {
69
68
  )
70
69
  await proxy.load()
71
70
  await proxy.unload()
72
- j_expect(mockExit).toBeCalledWith(0)
71
+ expect(mockExit).toBeCalledWith(0)
73
72
  })
74
73
  })
75
74
 
@@ -91,8 +90,8 @@ describe('Proxy behaviour', () => {
91
90
  const proxy = new Proxy({ routes: [] }, async () => {})
92
91
  await proxy.load()
93
92
  await Promise.all([proxy.unload('Error'), proxy.unload('Error')])
94
- j_expect(mockExit).toHaveBeenCalledTimes(1)
95
- j_expect(mockExit).toBeCalledWith(1)
93
+ expect(mockExit).toHaveBeenCalledTimes(1)
94
+ expect(mockExit).toBeCalledWith(1)
96
95
  })
97
96
  })
98
97
 
@@ -128,19 +127,19 @@ describe('Proxy routing', () => {
128
127
  .get(Globals.Listener_HTTP_DefaultHealthCheckRoute)
129
128
  .expect('Content-Type', 'text/html; charset=utf-8')
130
129
  .expect(200)
131
- expect(res.text).to.be.equals('Healthy!')
130
+ c_expect(res.text).to.be.equals('Healthy!')
132
131
  // Generic handler
133
132
  const resG = await request(defaultUrl)
134
133
  .get(`/abc`)
135
134
  .expect('Content-Type', 'application/json; charset=utf-8')
136
135
  .expect(200)
137
- expect(resG.body).to.be.deep.equals({ name: '123' })
136
+ c_expect(resG.body).to.be.deep.equals({ name: '123' })
138
137
  // Expected count
139
- expect(count).to.be.equals(1)
138
+ c_expect(count).to.be.equals(1)
140
139
  // Unload
141
140
  await proxy.unload('Error')
142
- j_expect(mockExit).toHaveBeenCalledTimes(1)
143
- j_expect(mockExit).toBeCalledWith(1)
141
+ expect(mockExit).toHaveBeenCalledTimes(1)
142
+ expect(mockExit).toBeCalledWith(1)
144
143
  })
145
144
 
146
145
  test('Proxy on custom port', async () => {
@@ -163,19 +162,19 @@ describe('Proxy routing', () => {
163
162
  .get(Globals.Listener_HTTP_DefaultHealthCheckRoute)
164
163
  .expect('Content-Type', 'text/html; charset=utf-8')
165
164
  .expect(200)
166
- expect(res.text).to.be.equals('Healthy!')
165
+ c_expect(res.text).to.be.equals('Healthy!')
167
166
  // Generic handler
168
167
  const resG = await request(url)
169
168
  .get(`/abc`)
170
169
  .expect('Content-Type', 'application/json; charset=utf-8')
171
170
  .expect(200)
172
- expect(resG.body).to.be.deep.equals({ name: '123' })
171
+ c_expect(resG.body).to.be.deep.equals({ name: '123' })
173
172
  // Expected count
174
- expect(count).to.be.equals(1)
173
+ c_expect(count).to.be.equals(1)
175
174
  // Unload
176
175
  await proxy.unload()
177
- j_expect(mockExit).toHaveBeenCalledTimes(1)
178
- j_expect(mockExit).toBeCalledWith(0)
176
+ expect(mockExit).toHaveBeenCalledTimes(1)
177
+ expect(mockExit).toBeCalledWith(0)
179
178
  })
180
179
 
181
180
  test('Proxy does timeout', async () => {
@@ -199,7 +198,7 @@ describe('Proxy routing', () => {
199
198
  .get(Globals.Listener_HTTP_DefaultHealthCheckRoute)
200
199
  .expect('Content-Type', 'text/html; charset=utf-8')
201
200
  .expect(200)
202
- expect(res.text).to.be.equals('Healthy!')
201
+ c_expect(res.text).to.be.equals('Healthy!')
203
202
  // Generic handler
204
203
  let err: any = null
205
204
  try {
@@ -210,13 +209,13 @@ describe('Proxy routing', () => {
210
209
  } catch (e) {
211
210
  err = e
212
211
  }
213
- expect(err?.message).to.be.equals('socket hang up')
212
+ c_expect(err?.message).to.be.equals('socket hang up')
214
213
  // Expected count
215
- expect(count).to.be.equals(1)
214
+ c_expect(count).to.be.equals(1)
216
215
  // Unload
217
216
  await proxy.unload('Error')
218
- j_expect(mockExit).toHaveBeenCalledTimes(1)
219
- j_expect(mockExit).toBeCalledWith(1)
217
+ expect(mockExit).toHaveBeenCalledTimes(1)
218
+ expect(mockExit).toBeCalledWith(1)
220
219
  //
221
220
  return new Promise(resolve => {
222
221
  setTimeout(resolve, timeout * 2)
@@ -244,21 +243,24 @@ describe('Proxy routing', () => {
244
243
  )
245
244
  await proxy.load()
246
245
  // White-listed header is allowed
247
- const resWH = await request(defaultUrl).options(`/abc`).set('Authorization', 123).expect(204)
248
- expect(resWH.header['access-control-allow-origin']).to.equal('*')
249
- expect(resWH.header['access-control-allow-credentials']).to.equal('true')
250
- expect(resWH.header['access-control-allow-headers']).to.equal('Authorization')
246
+ const resWH = await request(defaultUrl).options(`/abc`).set('Authorization', '123').expect(204)
247
+ c_expect(resWH.header['access-control-allow-origin']).to.equal('*')
248
+ c_expect(resWH.header['access-control-allow-credentials']).to.equal('true')
249
+ c_expect(resWH.header['access-control-allow-headers']).to.equal('Authorization')
251
250
  // Non white-listed header is allowed
252
- const resNWH = await request(defaultUrl).options(`/abc`).set('2Authorization2', 123).expect(204)
253
- expect(resNWH.header['access-control-allow-origin']).to.equal('*')
254
- expect(resNWH.header['access-control-allow-credentials']).to.equal('true')
255
- expect(resNWH.header['access-control-allow-headers']).to.equal('Authorization')
251
+ const resNWH = await request(defaultUrl)
252
+ .options(`/abc`)
253
+ .set('2Authorization2', '123')
254
+ .expect(204)
255
+ c_expect(resNWH.header['access-control-allow-origin']).to.equal('*')
256
+ c_expect(resNWH.header['access-control-allow-credentials']).to.equal('true')
257
+ c_expect(resNWH.header['access-control-allow-headers']).to.equal('Authorization')
256
258
  // Expected count
257
- expect(count).to.be.equals(0)
259
+ c_expect(count).to.be.equals(0)
258
260
  // Unload
259
261
  await proxy.unload()
260
- j_expect(mockExit).toHaveBeenCalledTimes(1)
261
- j_expect(mockExit).toBeCalledWith(0)
262
+ expect(mockExit).toHaveBeenCalledTimes(1)
263
+ expect(mockExit).toBeCalledWith(0)
262
264
  })
263
265
  })
264
266
 
package/tsconfig.json CHANGED
@@ -1,6 +1,11 @@
1
1
  {
2
- "exclude": ["**/*.test.*", "**/__mocks__/*", "**/__tests__/*", "**/tests/*"],
2
+ "exclude": ["**/*.test.*", "**/__mocks__/*", "**/__tests__/*", "**/tests/*", "./dist/**/*"],
3
3
  "compilerOptions": {
4
+ "lib": [
5
+ "es5",
6
+ "es6",
7
+ "dom"
8
+ ],
4
9
  "noImplicitAny": false,
5
10
  "noEmitOnError": true,
6
11
  "removeComments": false,