@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,12 +1,12 @@
1
- import { expect as j_expect } from "@jest/globals"
2
- import { expect } from "chai"
3
- import * as request from "supertest"
4
- import { z } from "zod"
1
+ import { expect as j_expect } from '@jest/globals'
2
+ import { expect } from 'chai'
3
+ import * as request from 'supertest'
4
+ import { z } from 'zod'
5
5
 
6
- import Response from "../../../src/API/Response"
7
- import Globals from "../../../src/Globals"
8
- import ContainerServer from "../../../src/Server/lib/ContainerServer"
9
- import { defaultUrl } from "../../Test.utils"
6
+ import Response from '../../../src/API/Response'
7
+ import Globals from '../../../src/Globals'
8
+ import ContainerServer from '../../../src/Server/lib/ContainerServer'
9
+ import { defaultUrl } from '../../Test.utils'
10
10
 
11
11
  export const ViewSchema = z.object({
12
12
  id: z.string(),
@@ -15,12 +15,12 @@ export const ViewSchema = z.object({
15
15
  updatedAt: z.string(),
16
16
  })
17
17
 
18
- describe("Container server routing", () => {
18
+ describe('Container server routing', () => {
19
19
  // @ts-ignore
20
- let mockExit = jest.spyOn(process, "exit").mockImplementation(() => {})
20
+ let mockExit = jest.spyOn(process, 'exit').mockImplementation(() => {})
21
21
  beforeAll(() => {
22
22
  // @ts-ignore
23
- mockExit = jest.spyOn(process, "exit").mockImplementation(() => {})
23
+ mockExit = jest.spyOn(process, 'exit').mockImplementation(() => {})
24
24
  })
25
25
  afterAll(() => {
26
26
  mockExit.mockRestore()
@@ -29,35 +29,35 @@ describe("Container server routing", () => {
29
29
  mockExit.mockReset()
30
30
  })
31
31
 
32
- test("Health & 404 handler", async () => {
32
+ test('Health & 404 handler', async () => {
33
33
  const server = new ContainerServer({ routes: [] })
34
34
  await server.start()
35
35
  // Health check
36
36
  const res = await request(defaultUrl)
37
37
  .get(Globals.Listener_HTTP_DefaultHealthCheckRoute)
38
- .expect("Content-Type", "text/html; charset=utf-8")
38
+ .expect('Content-Type', 'text/html; charset=utf-8')
39
39
  .expect(200)
40
- expect(res.text).to.be.equals("Healthy!")
40
+ expect(res.text).to.be.equals('Healthy!')
41
41
  // Not handled
42
42
  await request(defaultUrl)
43
43
  .get(`/abc`)
44
- .expect("Content-Type", "application/json; charset=utf-8")
44
+ .expect('Content-Type', 'application/json; charset=utf-8')
45
45
  .expect(404)
46
46
 
47
47
  // Unload
48
- await server.stop("Error")
48
+ await server.stop('Error')
49
49
  j_expect(mockExit).toHaveBeenCalledTimes(1)
50
50
  j_expect(mockExit).toBeCalledWith(1)
51
51
  })
52
52
 
53
- test("Simple route", async () => {
53
+ test('Simple route', async () => {
54
54
  const server = new ContainerServer({
55
55
  routes: [
56
56
  {
57
- path: "/abc",
58
- method: "get",
57
+ path: '/abc',
58
+ method: 'get',
59
59
  handler: async () => {
60
- return Response.SimpleResponse({ name: "abc" })
60
+ return Response.SimpleResponse({ name: 'abc' })
61
61
  },
62
62
  },
63
63
  ],
@@ -66,39 +66,39 @@ describe("Container server routing", () => {
66
66
  // Health check
67
67
  const res = await request(defaultUrl)
68
68
  .get(Globals.Listener_HTTP_DefaultHealthCheckRoute)
69
- .expect("Content-Type", "text/html; charset=utf-8")
69
+ .expect('Content-Type', 'text/html; charset=utf-8')
70
70
  .expect(200)
71
- expect(res.text).to.be.equals("Healthy!")
71
+ expect(res.text).to.be.equals('Healthy!')
72
72
  // Found route
73
73
  const resG = await request(defaultUrl)
74
74
  .get(`/abc`)
75
- .expect("Content-Type", "application/json; charset=utf-8")
75
+ .expect('Content-Type', 'application/json; charset=utf-8')
76
76
  .expect(200)
77
- expect(resG.body["name"]).to.be.deep.equals("abc")
78
- expect(resG.body["transactionID"]).to.not.be.null
77
+ expect(resG.body['name']).to.be.deep.equals('abc')
78
+ expect(resG.body['transactionID']).to.not.be.null
79
79
  // Found route, but not method
80
80
  await request(defaultUrl)
81
81
  .post(`/abc`)
82
- .expect("Content-Type", "application/json; charset=utf-8")
82
+ .expect('Content-Type', 'application/json; charset=utf-8')
83
83
  .expect(404)
84
84
  // Not found route
85
85
  await request(defaultUrl)
86
86
  .get(`/abc/123`)
87
- .expect("Content-Type", "application/json; charset=utf-8")
87
+ .expect('Content-Type', 'application/json; charset=utf-8')
88
88
  .expect(404)
89
89
  // Unload
90
- await server.stop("Error")
90
+ await server.stop('Error')
91
91
  j_expect(mockExit).toHaveBeenCalledTimes(1)
92
92
  j_expect(mockExit).toBeCalledWith(1)
93
93
  })
94
94
  })
95
95
 
96
- describe("Container server basics", () => {
96
+ describe('Container server basics', () => {
97
97
  // @ts-ignore
98
- let mockExit = jest.spyOn(process, "exit").mockImplementation(() => {})
98
+ let mockExit = jest.spyOn(process, 'exit').mockImplementation(() => {})
99
99
  beforeAll(() => {
100
100
  // @ts-ignore
101
- mockExit = jest.spyOn(process, "exit").mockImplementation(() => {})
101
+ mockExit = jest.spyOn(process, 'exit').mockImplementation(() => {})
102
102
  })
103
103
  afterAll(() => {
104
104
  mockExit.mockRestore()
@@ -107,17 +107,17 @@ describe("Container server basics", () => {
107
107
  mockExit.mockReset()
108
108
  })
109
109
 
110
- test("Starts with exports", async () => {
110
+ test('Starts with exports', async () => {
111
111
  const server = new ContainerServer({ routes: [] })
112
112
  server.getExport()
113
- return new Promise((resolve) => {
113
+ return new Promise(resolve => {
114
114
  setTimeout(async () => {
115
115
  // Health check
116
116
  const res = await request(defaultUrl)
117
117
  .get(Globals.Listener_HTTP_DefaultHealthCheckRoute)
118
- .expect("Content-Type", "text/html; charset=utf-8")
118
+ .expect('Content-Type', 'text/html; charset=utf-8')
119
119
  .expect(200)
120
- expect(res.text).to.be.equals("Healthy!")
120
+ expect(res.text).to.be.equals('Healthy!')
121
121
  // Unload
122
122
  await server.stop()
123
123
  j_expect(mockExit).toHaveBeenCalledTimes(1)
@@ -127,11 +127,11 @@ describe("Container server basics", () => {
127
127
  })
128
128
  })
129
129
 
130
- test("Stops if process sends message SIGINT", async () => {
130
+ test('Stops if process sends message SIGINT', async () => {
131
131
  const server = new ContainerServer({ routes: [] })
132
132
  await server.start()
133
- process.emit("SIGINT")
134
- return new Promise((resolve) => {
133
+ process.emit('SIGINT')
134
+ return new Promise(resolve => {
135
135
  setTimeout(async () => {
136
136
  j_expect(mockExit).toHaveBeenCalledTimes(1)
137
137
  j_expect(mockExit).toBeCalledWith(0)
@@ -140,12 +140,12 @@ describe("Container server basics", () => {
140
140
  })
141
141
  }, 10000)
142
142
 
143
- test("Stops if process sends message unhandledRejection", async () => {
143
+ test('Stops if process sends message unhandledRejection', async () => {
144
144
  const server = new ContainerServer({ routes: [] })
145
145
  await server.start()
146
146
  // @ts-ignore
147
- process.emit("unhandledRejection")
148
- return new Promise((resolve) => {
147
+ process.emit('unhandledRejection')
148
+ return new Promise(resolve => {
149
149
  setTimeout(async () => {
150
150
  j_expect(mockExit).toHaveBeenCalledTimes(1)
151
151
  j_expect(mockExit).toBeCalledWith(0)
@@ -155,12 +155,12 @@ describe("Container server basics", () => {
155
155
  }, 10000)
156
156
  })
157
157
 
158
- describe("Container server validation", () => {
158
+ describe('Container server validation', () => {
159
159
  // @ts-ignore
160
- let mockExit = jest.spyOn(process, "exit").mockImplementation(() => {})
160
+ let mockExit = jest.spyOn(process, 'exit').mockImplementation(() => {})
161
161
  beforeAll(() => {
162
162
  // @ts-ignore
163
- mockExit = jest.spyOn(process, "exit").mockImplementation(() => {})
163
+ mockExit = jest.spyOn(process, 'exit').mockImplementation(() => {})
164
164
  })
165
165
  afterAll(() => {
166
166
  mockExit.mockRestore()
@@ -170,24 +170,22 @@ describe("Container server validation", () => {
170
170
  })
171
171
 
172
172
  function validateValidationFailure(res: any, failureCount?: number) {
173
- expect(res.body["err"]).to.be.equals(Globals.ErrorResponseValidationFail)
174
- expect(res.body["errCode"]).to.be.equals(Globals.ErrorCode_InvalidInput)
175
- expect(res.body["transactionID"]).to.not.be.null
176
- expect(res.body["transactionID"]).to.be.an("string")
177
- expect(res.body["validationFailure"]?.length).to.be.equals(
178
- failureCount || 4,
179
- )
173
+ expect(res.body['err']).to.be.equals(Globals.ErrorResponseValidationFail)
174
+ expect(res.body['errCode']).to.be.equals(Globals.ErrorCode_InvalidInput)
175
+ expect(res.body['transactionID']).to.not.be.null
176
+ expect(res.body['transactionID']).to.be.an('string')
177
+ expect(res.body['validationFailure']?.length).to.be.equals(failureCount || 4)
180
178
  }
181
179
 
182
- test("Validates empty body", async () => {
180
+ test('Validates empty body', async () => {
183
181
  const server = new ContainerServer({
184
182
  routes: [
185
183
  {
186
- path: "/abc",
187
- method: "post",
184
+ path: '/abc',
185
+ method: 'post',
188
186
  inputSchema: ViewSchema,
189
187
  handler: async () => {
190
- return Response.SimpleResponse({ name: "abc" })
188
+ return Response.SimpleResponse({ name: 'abc' })
191
189
  },
192
190
  },
193
191
  ],
@@ -196,21 +194,21 @@ describe("Container server validation", () => {
196
194
  // Validation fails, empty body
197
195
  const resG = await request(defaultUrl)
198
196
  .post(`/abc`)
199
- .expect("Content-Type", "application/json; charset=utf-8")
197
+ .expect('Content-Type', 'application/json; charset=utf-8')
200
198
  .expect(400)
201
199
  validateValidationFailure(resG)
202
200
  await server.stop()
203
201
  })
204
202
 
205
- test("Validates empty string body", async () => {
203
+ test('Validates empty string body', async () => {
206
204
  const server = new ContainerServer({
207
205
  routes: [
208
206
  {
209
- path: "/abc",
210
- method: "post",
207
+ path: '/abc',
208
+ method: 'post',
211
209
  inputSchema: ViewSchema,
212
210
  handler: async () => {
213
- return Response.SimpleResponse({ name: "abc" })
211
+ return Response.SimpleResponse({ name: 'abc' })
214
212
  },
215
213
  },
216
214
  ],
@@ -219,22 +217,22 @@ describe("Container server validation", () => {
219
217
  // Validation fails, empty body
220
218
  const resG = await request(defaultUrl)
221
219
  .post(`/abc`)
222
- .send("")
223
- .expect("Content-Type", "application/json; charset=utf-8")
220
+ .send('')
221
+ .expect('Content-Type', 'application/json; charset=utf-8')
224
222
  .expect(400)
225
223
  validateValidationFailure(resG)
226
224
  await server.stop()
227
225
  })
228
226
 
229
- test("Validates empty object body", async () => {
227
+ test('Validates empty object body', async () => {
230
228
  const server = new ContainerServer({
231
229
  routes: [
232
230
  {
233
- path: "/abc",
234
- method: "post",
231
+ path: '/abc',
232
+ method: 'post',
235
233
  inputSchema: ViewSchema,
236
234
  handler: async () => {
237
- return Response.SimpleResponse({ name: "abc" })
235
+ return Response.SimpleResponse({ name: 'abc' })
238
236
  },
239
237
  },
240
238
  ],
@@ -244,21 +242,21 @@ describe("Container server validation", () => {
244
242
  const resG = await request(defaultUrl)
245
243
  .post(`/abc`)
246
244
  .send({})
247
- .expect("Content-Type", "application/json; charset=utf-8")
245
+ .expect('Content-Type', 'application/json; charset=utf-8')
248
246
  .expect(400)
249
247
  validateValidationFailure(resG)
250
248
  await server.stop()
251
249
  })
252
250
 
253
- test("Validates missing props body", async () => {
251
+ test('Validates missing props body', async () => {
254
252
  const server = new ContainerServer({
255
253
  routes: [
256
254
  {
257
- path: "/abc",
258
- method: "post",
255
+ path: '/abc',
256
+ method: 'post',
259
257
  inputSchema: ViewSchema,
260
258
  handler: async () => {
261
- return Response.SimpleResponse({ name: "abc" })
259
+ return Response.SimpleResponse({ name: 'abc' })
262
260
  },
263
261
  },
264
262
  ],
@@ -267,22 +265,22 @@ describe("Container server validation", () => {
267
265
  // Validation fails, empty body
268
266
  const resG = await request(defaultUrl)
269
267
  .post(`/abc`)
270
- .send({ id: "123" })
271
- .expect("Content-Type", "application/json; charset=utf-8")
268
+ .send({ id: '123' })
269
+ .expect('Content-Type', 'application/json; charset=utf-8')
272
270
  .expect(400)
273
271
  validateValidationFailure(resG, 3)
274
272
  await server.stop()
275
273
  })
276
274
 
277
- test("Validates wrong type props body", async () => {
275
+ test('Validates wrong type props body', async () => {
278
276
  const server = new ContainerServer({
279
277
  routes: [
280
278
  {
281
- path: "/abc",
282
- method: "post",
279
+ path: '/abc',
280
+ method: 'post',
283
281
  inputSchema: ViewSchema,
284
282
  handler: async () => {
285
- return Response.SimpleResponse({ name: "abc" })
283
+ return Response.SimpleResponse({ name: 'abc' })
286
284
  },
287
285
  },
288
286
  ],
@@ -292,21 +290,21 @@ describe("Container server validation", () => {
292
290
  const resG = await request(defaultUrl)
293
291
  .post(`/abc`)
294
292
  .send({ id: 123 })
295
- .expect("Content-Type", "application/json; charset=utf-8")
293
+ .expect('Content-Type', 'application/json; charset=utf-8')
296
294
  .expect(400)
297
295
  validateValidationFailure(resG)
298
296
  await server.stop()
299
297
  })
300
298
 
301
- test("Validates successfully", async () => {
299
+ test('Validates successfully', async () => {
302
300
  const server = new ContainerServer({
303
301
  routes: [
304
302
  {
305
- path: "/abc",
306
- method: "post",
303
+ path: '/abc',
304
+ method: 'post',
307
305
  inputSchema: ViewSchema,
308
306
  handler: async () => {
309
- return Response.SimpleResponse({ name: "abc" })
307
+ return Response.SimpleResponse({ name: 'abc' })
310
308
  },
311
309
  },
312
310
  ],
@@ -316,12 +314,12 @@ describe("Container server validation", () => {
316
314
  await request(defaultUrl)
317
315
  .post(`/abc`)
318
316
  .send({
319
- id: "123",
320
- content: "123",
317
+ id: '123',
318
+ content: '123',
321
319
  createdAt: new Date(),
322
320
  updatedAt: new Date(),
323
321
  })
324
- .expect("Content-Type", "application/json; charset=utf-8")
322
+ .expect('Content-Type', 'application/json; charset=utf-8')
325
323
  .expect(200)
326
324
  await server.stop()
327
325
  })
@@ -1,9 +1,9 @@
1
- import { expect } from "chai"
1
+ import { expect } from 'chai'
2
2
 
3
- import Server from "../../../src/Server/lib/Server"
3
+ import Server from '../../../src/Server/lib/Server'
4
4
 
5
- describe("Server basics", () => {
6
- test("Works", async () => {
5
+ describe('Server basics', () => {
6
+ test('Works', async () => {
7
7
  const server = new Server({ routes: [] })
8
8
  expect(server.getExport()).to.not.be.undefined
9
9
  })
@@ -1,10 +1,10 @@
1
- import { expect as j_expect } from "@jest/globals"
2
- import { APIGatewayProxyEvent, Context } from "aws-lambda"
3
- import { expect } from "chai"
4
- import { Request, Response } from "express"
1
+ import { expect as j_expect } from '@jest/globals'
2
+ import { APIGatewayProxyEvent, Context } from 'aws-lambda'
3
+ import { expect } from 'chai'
4
+ import { Request, Response } from 'express'
5
5
 
6
- import Globals from "../../../../src/Globals"
7
- import GenericHandler from "../../../../src/Server/lib/container/GenericHandler"
6
+ import Globals from '../../../../src/Globals'
7
+ import GenericHandler from '../../../../src/Server/lib/container/GenericHandler'
8
8
 
9
9
  function observableResponse(): Response {
10
10
  const resp = <Response>(<unknown>{
@@ -16,17 +16,15 @@ function observableResponse(): Response {
16
16
  return resp
17
17
  }
18
18
 
19
- describe("GenericHandler success invocation path", () => {
20
- test("Simple success", async () => {
19
+ describe('GenericHandler success invocation path', () => {
20
+ test('Simple success', async () => {
21
21
  const v = {
22
22
  statusCode: 200,
23
23
  body: JSON.stringify({ id: 123 }),
24
24
  }
25
- const handler = GenericHandler(
26
- async (event: APIGatewayProxyEvent, context: Context) => {
27
- context.succeed(v)
28
- },
29
- )
25
+ const handler = GenericHandler(async (event: APIGatewayProxyEvent, context: Context) => {
26
+ context.succeed(v)
27
+ })
30
28
  const resp = observableResponse()
31
29
  const handlerResp = await handler(<Request>(<unknown>{}), resp)
32
30
  //
@@ -37,17 +35,15 @@ describe("GenericHandler success invocation path", () => {
37
35
  j_expect(resp.header).not.toBeCalled()
38
36
  })
39
37
 
40
- test("Simple success w/ headers", async () => {
38
+ test('Simple success w/ headers', async () => {
41
39
  const v = {
42
40
  statusCode: 200,
43
41
  body: JSON.stringify({ id: 123 }),
44
42
  headers: { Authorization: 123 },
45
43
  }
46
- const handler = GenericHandler(
47
- async (event: APIGatewayProxyEvent, context: Context) => {
48
- context.succeed(v)
49
- },
50
- )
44
+ const handler = GenericHandler(async (event: APIGatewayProxyEvent, context: Context) => {
45
+ context.succeed(v)
46
+ })
51
47
  const resp = observableResponse()
52
48
  const handlerResp = await handler(<Request>(<unknown>{}), resp)
53
49
  //
@@ -58,16 +54,14 @@ describe("GenericHandler success invocation path", () => {
58
54
  j_expect(resp.header).toBeCalledTimes(Object.keys(v.headers).length)
59
55
  })
60
56
 
61
- test("Simple success w/ null body", async () => {
57
+ test('Simple success w/ null body', async () => {
62
58
  const v = {
63
59
  statusCode: 200,
64
60
  headers: { Authorization: 123 },
65
61
  }
66
- const handler = GenericHandler(
67
- async (event: APIGatewayProxyEvent, context: Context) => {
68
- context.succeed(v)
69
- },
70
- )
62
+ const handler = GenericHandler(async (event: APIGatewayProxyEvent, context: Context) => {
63
+ context.succeed(v)
64
+ })
71
65
  const resp = observableResponse()
72
66
  const handlerResp = await handler(<Request>(<unknown>{}), resp)
73
67
  //
@@ -79,13 +73,11 @@ describe("GenericHandler success invocation path", () => {
79
73
  })
80
74
  })
81
75
 
82
- describe("GenericHandler failure invocation path", () => {
83
- test("Invalid response", async () => {
84
- const handler = GenericHandler(
85
- async (event: APIGatewayProxyEvent, context: Context) => {
86
- context.succeed(null)
87
- },
88
- )
76
+ describe('GenericHandler failure invocation path', () => {
77
+ test('Invalid response', async () => {
78
+ const handler = GenericHandler(async (event: APIGatewayProxyEvent, context: Context) => {
79
+ context.succeed(null)
80
+ })
89
81
  const resp = observableResponse()
90
82
  const handlerResp = await handler(<Request>(<unknown>{}), resp)
91
83
  //
@@ -99,13 +91,11 @@ describe("GenericHandler failure invocation path", () => {
99
91
  j_expect(resp.status).toBeCalledWith(Globals.Resp_STATUSCODE_INVALIDRESP)
100
92
  })
101
93
 
102
- test("Error response", async () => {
103
- const err = new Error("Failed!")
104
- const handler = GenericHandler(
105
- async (event: APIGatewayProxyEvent, context: Context) => {
106
- context.fail(err)
107
- },
108
- )
94
+ test('Error response', async () => {
95
+ const err = new Error('Failed!')
96
+ const handler = GenericHandler(async (event: APIGatewayProxyEvent, context: Context) => {
97
+ context.fail(err)
98
+ })
109
99
  const resp = observableResponse()
110
100
  const handlerResp = await handler(<Request>(<unknown>{}), resp)
111
101
  //
@@ -118,8 +108,8 @@ describe("GenericHandler failure invocation path", () => {
118
108
  j_expect(resp.status).toBeCalledWith(400)
119
109
  })
120
110
 
121
- test("Exception response", async () => {
122
- const err = new Error("Failed!")
111
+ test('Exception response', async () => {
112
+ const err = new Error('Failed!')
123
113
  const handler = GenericHandler(async () => {
124
114
  throw err
125
115
  })