@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,20 +1,15 @@
1
- import { expect as j_expect } from "@jest/globals"
2
- import { APIGatewayEvent, Context } from "aws-lambda"
3
- import { expect } from "chai"
1
+ import { expect as j_expect } from '@jest/globals'
2
+ import { APIGatewayEvent, Context } from 'aws-lambda'
3
+ import { expect } from 'chai'
4
4
 
5
- import Response from "../../src/API/Response"
6
- import Transaction from "../../src/BaseEvent/Transaction"
7
- import Globals from "../../src/Globals"
8
- import { observableTransaction, defaultHeaders } from "../Test.utils"
5
+ import Response from '../../src/API/Response'
6
+ import Transaction from '../../src/BaseEvent/Transaction'
7
+ import Globals from '../../src/Globals'
8
+ import { observableTransaction, defaultHeaders } from '../Test.utils'
9
9
 
10
- async function testResponse(
11
- r: Response<any>,
12
- body: any,
13
- optCode?: number,
14
- optHeaders?: any,
15
- ) {
10
+ async function testResponse(r: Response<any>, body: any, optCode?: number, optHeaders?: any) {
16
11
  const t = observableTransaction()
17
- const context = t["context"]
12
+ const context = t['context']
18
13
  const buildR = await r.build(context, t, false)
19
14
  expect(buildR).to.be.undefined
20
15
  j_expect(t.responseProxy).toBeCalledTimes(1)
@@ -30,46 +25,46 @@ async function testResponse(
30
25
  ? {
31
26
  body: JSON.stringify({
32
27
  ...body,
33
- transactionID: "unknown",
28
+ transactionID: 'unknown',
34
29
  }),
35
30
  }
36
31
  : {}),
37
32
  })
38
33
  }
39
34
 
40
- describe("Response basics", () => {
41
- test("Null body", () => {
35
+ describe('Response basics', () => {
36
+ test('Null body', () => {
42
37
  const r = new Response<null>(200, null)
43
38
  expect(r.getCode()).to.be.equals(200)
44
39
  expect(r.getBody()).to.be.null
45
40
  })
46
41
 
47
- test("String body", () => {
48
- const r = new Response<string>(200, "abc")
42
+ test('String body', () => {
43
+ const r = new Response<string>(200, 'abc')
49
44
  expect(r.getCode()).to.be.equals(200)
50
- expect(r.getBody()).to.be.equals("abc")
45
+ expect(r.getBody()).to.be.equals('abc')
51
46
  })
52
47
 
53
- test("Generic body", () => {
54
- const r = new Response<any>(200, { name: "abc" })
55
- r.appendIntoBody("name2", "123")
48
+ test('Generic body', () => {
49
+ const r = new Response<any>(200, { name: 'abc' })
50
+ r.appendIntoBody('name2', '123')
56
51
  expect(r.getCode()).to.be.equals(200)
57
- expect(r.getBody().name).to.be.equals("abc")
58
- expect(r.getBody().name2).to.be.equals("123")
52
+ expect(r.getBody().name).to.be.equals('abc')
53
+ expect(r.getBody().name2).to.be.equals('123')
59
54
  })
60
55
 
61
- test("Append/validate header", () => {
56
+ test('Append/validate header', () => {
62
57
  const r = new Response<any>(200, {})
63
- r.appendHeader("name2", "123")
64
- expect(r["_headers"]["name2"]).to.be.equals("123")
58
+ r.appendHeader('name2', '123')
59
+ expect(r['_headers']['name2']).to.be.equals('123')
65
60
  })
66
61
  })
67
62
 
68
- describe("Response build", () => {
69
- test("Succeeds to transaction context", async () => {
70
- const b = { name: "abc" }
63
+ describe('Response build', () => {
64
+ test('Succeeds to transaction context', async () => {
65
+ const b = { name: 'abc' }
71
66
  const r = new Response<any>(200, b)
72
- r.appendHeader("abc", "123")
67
+ r.appendHeader('abc', '123')
73
68
  // do not use default, so we dont use proxy response for once
74
69
  const t = new Transaction(
75
70
  <APIGatewayEvent>(<unknown>{}),
@@ -77,9 +72,9 @@ describe("Response build", () => {
77
72
  done: jest.fn(),
78
73
  fail: jest.fn(),
79
74
  succeed: jest.fn(),
80
- }),
75
+ })
81
76
  )
82
- const context = t["context"]
77
+ const context = t['context']
83
78
  const buildR = await r.build(context, t, false)
84
79
  expect(buildR).to.be.undefined
85
80
  j_expect(context.fail).not.toBeCalled()
@@ -88,20 +83,20 @@ describe("Response build", () => {
88
83
  statusCode: 200,
89
84
  headers: {
90
85
  ...defaultHeaders,
91
- abc: "123",
86
+ abc: '123',
92
87
  },
93
88
  body: JSON.stringify({
94
89
  ...b,
95
- transactionID: "unknown",
90
+ transactionID: 'unknown',
96
91
  }),
97
92
  })
98
93
  })
99
94
 
100
- test("Succeeds with no context call", async () => {
101
- const b = { name: "abc" }
95
+ test('Succeeds with no context call', async () => {
96
+ const b = { name: 'abc' }
102
97
  const r = new Response<any>(200, b)
103
98
  const t = observableTransaction()
104
- const context = t["context"]
99
+ const context = t['context']
105
100
  const buildR = await r.build(context, t, true)
106
101
  expect(buildR).to.be.undefined
107
102
  j_expect(context.fail).not.toBeCalled()
@@ -109,30 +104,30 @@ describe("Response build", () => {
109
104
  j_expect(context.succeed).not.toBeCalled()
110
105
  })
111
106
 
112
- test("Succeeds to transaction context as RAW", async () => {
113
- const b = { name: "abc" }
107
+ test('Succeeds to transaction context as RAW', async () => {
108
+ const b = { name: 'abc' }
114
109
  const r = new Response<any>(200, b, {
115
110
  rawBody: true,
116
111
  })
117
112
  const t = observableTransaction()
118
- const context = t["context"]
113
+ const context = t['context']
119
114
  const buildR = await r.build(context, t, false)
120
115
  expect(buildR).to.be.undefined
121
116
  j_expect(context.fail).not.toBeCalled()
122
117
  j_expect(context.done).not.toBeCalled()
123
118
  j_expect(context.succeed).toHaveBeenCalledWith({
124
119
  ...b,
125
- transactionID: "unknown",
120
+ transactionID: 'unknown',
126
121
  })
127
122
  })
128
123
 
129
- test("Succeeds to transaction piping", async () => {
130
- const b = { name: "abc" }
124
+ test('Succeeds to transaction piping', async () => {
125
+ const b = { name: 'abc' }
131
126
  const r = new Response<any>(200, b, {
132
127
  shouldStream: true,
133
128
  })
134
129
  const t = observableTransaction()
135
- const context = t["context"]
130
+ const context = t['context']
136
131
  const buildR = await r.build(context, t, false)
137
132
  await r.build(context, t, false) //pipe twice, should not affect
138
133
  expect(buildR).to.be.undefined
@@ -150,13 +145,13 @@ describe("Response build", () => {
150
145
  })
151
146
  })
152
147
 
153
- test("Failure to transaction context as RAW", async () => {
154
- const b = { name: "abc" }
148
+ test('Failure to transaction context as RAW', async () => {
149
+ const b = { name: 'abc' }
155
150
  const r = new Response<any>(400, b, {
156
151
  rawBody: true,
157
152
  })
158
153
  const t = observableTransaction()
159
- const context = t["context"]
154
+ const context = t['context']
160
155
  const buildR = await r.build(context, t, false)
161
156
  expect(buildR).to.be.undefined
162
157
  j_expect(context.done).not.toBeCalled()
@@ -164,14 +159,14 @@ describe("Response build", () => {
164
159
  j_expect(context.fail).toHaveBeenCalledTimes(1)
165
160
  })
166
161
 
167
- test("Failure exception to transaction context as RAW", async () => {
168
- const b = { name: "abc" }
162
+ test('Failure exception to transaction context as RAW', async () => {
163
+ const b = { name: 'abc' }
169
164
  const r = new Response<any>(400, b, {
170
165
  rawBody: true,
171
166
  throwOnErrors: true,
172
167
  })
173
168
  const t = observableTransaction()
174
- const context = t["context"]
169
+ const context = t['context']
175
170
  let buildR: any = null,
176
171
  exception = null
177
172
  try {
@@ -186,14 +181,14 @@ describe("Response build", () => {
186
181
  j_expect(context.fail).not.toBeCalled()
187
182
  })
188
183
 
189
- test("Failure exception to transaction context as RAW and null body", async () => {
184
+ test('Failure exception to transaction context as RAW and null body', async () => {
190
185
  const b = null
191
186
  const r = new Response<any>(400, b, {
192
187
  rawBody: true,
193
188
  throwOnErrors: true,
194
189
  })
195
190
  const t = observableTransaction()
196
- const context = t["context"]
191
+ const context = t['context']
197
192
  let buildR: any = null,
198
193
  exception = null
199
194
  try {
@@ -208,14 +203,14 @@ describe("Response build", () => {
208
203
  j_expect(context.fail).not.toBeCalled()
209
204
  })
210
205
 
211
- test("Failure exception to transaction context as RAW and custom ero", async () => {
212
- const b = { message: "abc", error: "error 123" }
206
+ test('Failure exception to transaction context as RAW and custom ero', async () => {
207
+ const b = { message: 'abc', error: 'error 123' }
213
208
  const r = new Response<any>(400, b, {
214
209
  rawBody: true,
215
210
  throwOnErrors: true,
216
211
  })
217
212
  const t = observableTransaction()
218
- const context = t["context"]
213
+ const context = t['context']
219
214
  let buildR: any = null,
220
215
  exception = null
221
216
  try {
@@ -231,9 +226,9 @@ describe("Response build", () => {
231
226
  })
232
227
  })
233
228
 
234
- describe("Response shortcuts", () => {
235
- test("MissingParamResponse", async () => {
236
- const pName = "abc"
229
+ describe('Response shortcuts', () => {
230
+ test('MissingParamResponse', async () => {
231
+ const pName = 'abc'
237
232
  const r = Response.MissingParamResponse(pName)
238
233
  await testResponse(r, {
239
234
  err: `Invalid request. Path parameter ${pName} is missing.`,
@@ -241,8 +236,8 @@ describe("Response shortcuts", () => {
241
236
  })
242
237
  })
243
238
 
244
- test("MissingQueryResponse", async () => {
245
- const pName = "abc"
239
+ test('MissingQueryResponse', async () => {
240
+ const pName = 'abc'
246
241
  const r = Response.MissingQueryResponse(pName)
247
242
  await testResponse(r, {
248
243
  err: `Invalid request. Query parameter ${pName} is missing.`,
@@ -250,9 +245,9 @@ describe("Response shortcuts", () => {
250
245
  })
251
246
  })
252
247
 
253
- test("BadRequestResponse", async () => {
254
- const message = "abc"
255
- const code = "CODE"
248
+ test('BadRequestResponse', async () => {
249
+ const message = 'abc'
250
+ const code = 'CODE'
256
251
  const optBody = { additional: 123 }
257
252
  const r = Response.BadRequestResponse(message, code, optBody)
258
253
  await testResponse(r, {
@@ -262,17 +257,17 @@ describe("Response shortcuts", () => {
262
257
  })
263
258
  })
264
259
 
265
- test("BadRequestResponse no opts", async () => {
266
- const message = "abc"
260
+ test('BadRequestResponse no opts', async () => {
261
+ const message = 'abc'
267
262
  const r = Response.BadRequestResponse(message)
268
263
  await testResponse(r, {
269
264
  err: message,
270
265
  })
271
266
  })
272
267
 
273
- test("BadRequestResponseWithRollback", async () => {
274
- const message = "abc"
275
- const code = "CODE"
268
+ test('BadRequestResponseWithRollback', async () => {
269
+ const message = 'abc'
270
+ const code = 'CODE'
276
271
  const optBody = { additional: 123 }
277
272
  const r = Response.BadRequestResponseWithRollback(message, code, optBody)
278
273
  await testResponse(r, {
@@ -283,8 +278,8 @@ describe("Response shortcuts", () => {
283
278
  })
284
279
  })
285
280
 
286
- test("BadRequestResponseWithRollback no opts", async () => {
287
- const message = "abc"
281
+ test('BadRequestResponseWithRollback no opts', async () => {
282
+ const message = 'abc'
288
283
  const r = Response.BadRequestResponseWithRollback(message)
289
284
  await testResponse(r, {
290
285
  err: message,
@@ -292,9 +287,9 @@ describe("Response shortcuts", () => {
292
287
  })
293
288
  })
294
289
 
295
- test("UnauthorizedResponse", async () => {
296
- const message = "abc"
297
- const code = "CODE"
290
+ test('UnauthorizedResponse', async () => {
291
+ const message = 'abc'
292
+ const code = 'CODE'
298
293
  const r = Response.UnauthorizedResponse(message, code)
299
294
  await testResponse(
300
295
  r,
@@ -302,53 +297,53 @@ describe("Response shortcuts", () => {
302
297
  err: message,
303
298
  errCode: code,
304
299
  },
305
- 401,
300
+ 401
306
301
  )
307
302
  })
308
303
 
309
- test("UnauthorizedResponse no code", async () => {
310
- const message = "abc"
304
+ test('UnauthorizedResponse no code', async () => {
305
+ const message = 'abc'
311
306
  const r = Response.UnauthorizedResponse(message)
312
307
  await testResponse(r, { err: message }, 401)
313
308
  })
314
309
 
315
- test("SuccessResponse", async () => {
310
+ test('SuccessResponse', async () => {
316
311
  const body = { additional: 123 }
317
312
  const r = Response.SuccessResponse(body)
318
313
  await testResponse(r, body, 200)
319
314
  })
320
315
 
321
- test("SuccessResponse null body", async () => {
316
+ test('SuccessResponse null body', async () => {
322
317
  const r = Response.SuccessResponse(null)
323
318
  await testResponse(r, {}, 200)
324
319
  })
325
320
 
326
- test("SuccessNoContentResponse", async () => {
321
+ test('SuccessNoContentResponse', async () => {
327
322
  const r = Response.SuccessNoContentResponse()
328
323
  await testResponse(r, null, 204)
329
324
  })
330
325
 
331
- test("SimpleResponse", async () => {
326
+ test('SimpleResponse', async () => {
332
327
  const r = Response.SimpleResponse(null)
333
328
  await testResponse(r, null, 200)
334
329
  })
335
330
 
336
- test("SimpleResponse override statuscode", async () => {
331
+ test('SimpleResponse override statuscode', async () => {
337
332
  const r = Response.SimpleResponse(null, 203)
338
333
  await testResponse(r, null, 203)
339
334
  })
340
335
 
341
- test("RedirectResponse", async () => {
342
- const url = "https://google.com"
336
+ test('RedirectResponse', async () => {
337
+ const url = 'https://google.com'
343
338
  const r = Response.RedirectResponse(url)
344
339
  await testResponse(r, null, 302, { Location: url })
345
340
  })
346
341
 
347
- test("SuccessStreamResponse", async () => {
348
- const b = { name: "abc" }
349
- const r = Response.SuccessStreamResponse(b, "test-stream")
342
+ test('SuccessStreamResponse', async () => {
343
+ const b = { name: 'abc' }
344
+ const r = Response.SuccessStreamResponse(b, 'test-stream')
350
345
  const t = observableTransaction()
351
- const context = t["context"]
346
+ const context = t['context']
352
347
  const buildR = await r.build(context, t, false)
353
348
  await r.build(context, t, false) //pipe twice, should not affect
354
349
  expect(buildR).to.be.undefined
@@ -359,8 +354,8 @@ describe("Response shortcuts", () => {
359
354
  statusCode: 200,
360
355
  headers: {
361
356
  ...defaultHeaders,
362
- "Content-Type": "test-stream",
363
- Connection: "keep-alive",
357
+ 'Content-Type': 'test-stream',
358
+ Connection: 'keep-alive',
364
359
  },
365
360
  body: {
366
361
  ...b,
@@ -1,155 +1,155 @@
1
- import { expect } from "chai"
1
+ import { expect } from 'chai'
2
2
 
3
- import Utils from "../../src/API/Utils"
3
+ import Utils from '../../src/API/Utils'
4
4
 
5
- describe("isHybridlessContainer", () => {
6
- test("Simple isHybridlessContainer test", () => {
5
+ describe('isHybridlessContainer', () => {
6
+ test('Simple isHybridlessContainer test', () => {
7
7
  const v = Utils.isHybridlessContainer()
8
- expect(v).to.be.a("boolean")
8
+ expect(v).to.be.a('boolean')
9
9
  // this is done, so tests are reliable based on the testing .env
10
- expect(v).to.be[process.env.HYBRIDLESS_RUNTIME ? "true" : "false"]
10
+ expect(v).to.be[process.env.HYBRIDLESS_RUNTIME ? 'true' : 'false']
11
11
  })
12
12
  })
13
13
 
14
- describe("isValidString", () => {
15
- test("Empty string is not valid", () => {
16
- const v = Utils.isValidString("")
17
- expect(v).to.be.a("boolean")
14
+ describe('isValidString', () => {
15
+ test('Empty string is not valid', () => {
16
+ const v = Utils.isValidString('')
17
+ expect(v).to.be.a('boolean')
18
18
  expect(v).to.be.false
19
19
  })
20
20
 
21
- test("Number is not a valid string", () => {
21
+ test('Number is not a valid string', () => {
22
22
  // @ts-ignore
23
23
  const v = Utils.isValidString(12)
24
- expect(v).to.be.a("boolean")
24
+ expect(v).to.be.a('boolean')
25
25
  expect(v).to.be.false
26
26
  })
27
27
 
28
- test("Simple string is valid", () => {
29
- const v = Utils.isValidString("abc")
30
- expect(v).to.be.a("boolean")
28
+ test('Simple string is valid', () => {
29
+ const v = Utils.isValidString('abc')
30
+ expect(v).to.be.a('boolean')
31
31
  expect(v).to.be.true
32
32
  })
33
33
  })
34
34
 
35
- describe("parseIntNullIfNaN", () => {
36
- test("Null if only chars", () => {
37
- const v = Utils.parseIntNullIfNaN("abc")
35
+ describe('parseIntNullIfNaN', () => {
36
+ test('Null if only chars', () => {
37
+ const v = Utils.parseIntNullIfNaN('abc')
38
38
  expect(v).to.be.null
39
39
  })
40
40
 
41
- test("Null if chars with numbers", () => {
42
- const v = Utils.parseIntNullIfNaN("abc123")
41
+ test('Null if chars with numbers', () => {
42
+ const v = Utils.parseIntNullIfNaN('abc123')
43
43
  expect(v).to.be.null
44
44
  })
45
45
 
46
- test("Null if null", () => {
46
+ test('Null if null', () => {
47
47
  // @ts-ignore
48
48
  const v = Utils.parseIntNullIfNaN(null)
49
49
  expect(v).to.be.null
50
50
  })
51
51
 
52
- test("Not null if starts with numbers (js behavior)", () => {
53
- const v = Utils.parseIntNullIfNaN("123abc")
54
- expect(v).to.be.a("number")
52
+ test('Not null if starts with numbers (js behavior)', () => {
53
+ const v = Utils.parseIntNullIfNaN('123abc')
54
+ expect(v).to.be.a('number')
55
55
  expect(v).to.be.equals(123)
56
56
  })
57
57
 
58
- test("Not null if numbers", () => {
59
- const v = Utils.parseIntNullIfNaN("123")
60
- expect(v).to.be.a("number")
58
+ test('Not null if numbers', () => {
59
+ const v = Utils.parseIntNullIfNaN('123')
60
+ expect(v).to.be.a('number')
61
61
  expect(v).to.be.equals(123)
62
62
  })
63
63
 
64
- test("Not null if number type", () => {
64
+ test('Not null if number type', () => {
65
65
  // @ts-ignore
66
66
  const v = Utils.parseIntNullIfNaN(123)
67
- expect(v).to.be.a("number")
67
+ expect(v).to.be.a('number')
68
68
  expect(v).to.be.equals(123)
69
69
  })
70
70
  })
71
71
 
72
- describe("parseObjectNullIfEmpty", () => {
73
- test("Null if only chars", () => {
74
- const v = Utils.parseObjectNullIfEmpty("abc")
72
+ describe('parseObjectNullIfEmpty', () => {
73
+ test('Null if only chars', () => {
74
+ const v = Utils.parseObjectNullIfEmpty('abc')
75
75
  expect(v).to.be.null
76
76
  })
77
77
 
78
- test("Null if chars with numbers", () => {
79
- const v = Utils.parseObjectNullIfEmpty("abc123")
78
+ test('Null if chars with numbers', () => {
79
+ const v = Utils.parseObjectNullIfEmpty('abc123')
80
80
  expect(v).to.be.null
81
81
  })
82
82
 
83
- test("Null if null", () => {
83
+ test('Null if null', () => {
84
84
  // @ts-ignore
85
85
  const v = Utils.parseObjectNullIfEmpty(null)
86
86
  expect(v).to.be.null
87
87
  })
88
88
 
89
- test("Null if malformed object", () => {
90
- const v = Utils.parseObjectNullIfEmpty("{d: 123}")
89
+ test('Null if malformed object', () => {
90
+ const v = Utils.parseObjectNullIfEmpty('{d: 123}')
91
91
  expect(v).to.be.null
92
92
  })
93
93
 
94
- test("Null if empty object", () => {
95
- const v = Utils.parseObjectNullIfEmpty("{}")
94
+ test('Null if empty object', () => {
95
+ const v = Utils.parseObjectNullIfEmpty('{}')
96
96
  expect(v).to.be.null
97
97
  })
98
98
 
99
- test("Not null if object with a key", () => {
99
+ test('Not null if object with a key', () => {
100
100
  const v = Utils.parseObjectNullIfEmpty('{"d": 123}')
101
- expect(v).to.be.a("object")
102
- expect(v?.["d"]).to.be.equals(123)
101
+ expect(v).to.be.a('object')
102
+ expect(v?.['d']).to.be.equals(123)
103
103
  })
104
104
  })
105
105
 
106
- describe("isValidNumber", () => {
107
- test("Not a valid number if only chars", () => {
108
- const v = Utils.isValidNumber("abc")
106
+ describe('isValidNumber', () => {
107
+ test('Not a valid number if only chars', () => {
108
+ const v = Utils.isValidNumber('abc')
109
109
  expect(v).to.be.false
110
110
  })
111
111
 
112
- test("Not a valid number if only chars and numbers", () => {
113
- const v = Utils.isValidNumber("abc123")
112
+ test('Not a valid number if only chars and numbers', () => {
113
+ const v = Utils.isValidNumber('abc123')
114
114
  expect(v).to.be.false
115
115
  })
116
116
 
117
- test("Valid number if numbers and chars after", () => {
118
- const v = Utils.isValidNumber("123abc")
117
+ test('Valid number if numbers and chars after', () => {
118
+ const v = Utils.isValidNumber('123abc')
119
119
  expect(v).to.be.true
120
120
  })
121
121
 
122
- test("Valid number if numbers", () => {
123
- const v = Utils.isValidNumber("123")
122
+ test('Valid number if numbers', () => {
123
+ const v = Utils.isValidNumber('123')
124
124
  expect(v).to.be.true
125
125
  })
126
126
  })
127
127
 
128
- describe("caseInsensitiveObjectForKey", () => {
129
- test("Get a key that is lowercase, asking uppercase", () => {
130
- const v = Utils.caseInsensitiveObjectForKey({ abc: 123 }, "ABC")
131
- expect(v).to.be.a("number")
128
+ describe('caseInsensitiveObjectForKey', () => {
129
+ test('Get a key that is lowercase, asking uppercase', () => {
130
+ const v = Utils.caseInsensitiveObjectForKey({ abc: 123 }, 'ABC')
131
+ expect(v).to.be.a('number')
132
132
  expect(v).to.be.equals(123)
133
133
  })
134
134
 
135
- test("Get a key that is uppercase, asking lowercase", () => {
136
- const v = Utils.caseInsensitiveObjectForKey({ ABC: 123 }, "abc")
137
- expect(v).to.be.a("number")
135
+ test('Get a key that is uppercase, asking lowercase', () => {
136
+ const v = Utils.caseInsensitiveObjectForKey({ ABC: 123 }, 'abc')
137
+ expect(v).to.be.a('number')
138
138
  expect(v).to.be.equals(123)
139
139
  })
140
140
 
141
- test("Fails gracefully if key is not found", () => {
142
- const v = Utils.caseInsensitiveObjectForKey({ ABC: 123 }, "asd")
141
+ test('Fails gracefully if key is not found', () => {
142
+ const v = Utils.caseInsensitiveObjectForKey({ ABC: 123 }, 'asd')
143
143
  expect(v).to.be.null
144
144
  })
145
145
 
146
- test("Fails gracefully for null object", () => {
147
- const v = Utils.caseInsensitiveObjectForKey(null, "abc")
146
+ test('Fails gracefully for null object', () => {
147
+ const v = Utils.caseInsensitiveObjectForKey(null, 'abc')
148
148
  expect(v).to.be.null
149
149
  })
150
150
 
151
- test("Fails gracefully for invalid object", () => {
152
- const v = Utils.caseInsensitiveObjectForKey("", "abc")
151
+ test('Fails gracefully for invalid object', () => {
152
+ const v = Utils.caseInsensitiveObjectForKey('', 'abc')
153
153
  expect(v).to.be.null
154
154
  })
155
155
  })