@creator.co/wapi 1.7.1-alpha1 → 1.7.1-alpha3

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 (114) hide show
  1. package/coverage/clover.xml +1088 -0
  2. package/coverage/coverage/coverage.txt +40 -0
  3. package/coverage/coverage-final.json +37 -0
  4. package/coverage/coverage-summary.json +38 -0
  5. package/coverage/coverage.txt +59 -0
  6. package/coverage/lcov-report/base.css +224 -0
  7. package/coverage/lcov-report/block-navigation.js +87 -0
  8. package/coverage/lcov-report/favicon.png +0 -0
  9. package/coverage/lcov-report/index.html +371 -0
  10. package/coverage/lcov-report/prettify.css +1 -0
  11. package/coverage/lcov-report/prettify.js +2 -0
  12. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  13. package/coverage/lcov-report/sorter.js +196 -0
  14. package/coverage/lcov-report/src/API/Request.ts.html +727 -0
  15. package/coverage/lcov-report/src/API/Response.ts.html +1189 -0
  16. package/coverage/lcov-report/src/API/Utils.ts.html +313 -0
  17. package/coverage/lcov-report/src/API/index.html +131 -0
  18. package/coverage/lcov-report/src/BaseEvent/EventProcessor.ts.html +496 -0
  19. package/coverage/lcov-report/src/BaseEvent/Process.ts.html +346 -0
  20. package/coverage/lcov-report/src/BaseEvent/Transaction.ts.html +1015 -0
  21. package/coverage/lcov-report/src/BaseEvent/index.html +146 -0
  22. package/coverage/lcov-report/src/Cache/Redis.ts.html +367 -0
  23. package/coverage/lcov-report/src/Cache/index.html +116 -0
  24. package/coverage/lcov-report/src/Config/Configuration.ts.html +700 -0
  25. package/coverage/lcov-report/src/Config/EnvironmentVar.ts.html +526 -0
  26. package/coverage/lcov-report/src/Config/index.html +131 -0
  27. package/coverage/lcov-report/src/Crypto/Crypto.ts.html +352 -0
  28. package/coverage/lcov-report/src/Crypto/JWT.ts.html +337 -0
  29. package/coverage/lcov-report/src/Crypto/index.html +131 -0
  30. package/coverage/lcov-report/src/Database/Database.ts.html +151 -0
  31. package/coverage/lcov-report/src/Database/DatabaseManager.ts.html +289 -0
  32. package/coverage/lcov-report/src/Database/DatabaseTransaction.ts.html +595 -0
  33. package/coverage/lcov-report/src/Database/index.html +161 -0
  34. package/coverage/lcov-report/src/Database/index.ts.html +169 -0
  35. package/coverage/lcov-report/src/Database/integrations/knex/KnexDatabase.ts.html +283 -0
  36. package/coverage/lcov-report/src/Database/integrations/knex/KnexTransaction.ts.html +337 -0
  37. package/coverage/lcov-report/src/Database/integrations/knex/index.html +131 -0
  38. package/coverage/lcov-report/src/Database/integrations/kysely/KyselyDatabase.ts.html +376 -0
  39. package/coverage/lcov-report/src/Database/integrations/kysely/KyselyTransaction.ts.html +601 -0
  40. package/coverage/lcov-report/src/Database/integrations/kysely/index.html +131 -0
  41. package/coverage/lcov-report/src/Database/integrations/pgsql/PostgresDatabase.ts.html +250 -0
  42. package/coverage/lcov-report/src/Database/integrations/pgsql/PostgresTransaction.ts.html +346 -0
  43. package/coverage/lcov-report/src/Database/integrations/pgsql/index.html +131 -0
  44. package/coverage/lcov-report/src/Database/types.d.ts.html +232 -0
  45. package/coverage/lcov-report/src/Globals.ts.html +394 -0
  46. package/coverage/lcov-report/src/Logger/Logger.ts.html +1138 -0
  47. package/coverage/lcov-report/src/Logger/index.html +116 -0
  48. package/coverage/lcov-report/src/Mailer/Mailer.ts.html +754 -0
  49. package/coverage/lcov-report/src/Mailer/index.html +116 -0
  50. package/coverage/lcov-report/src/Publisher/Publisher.ts.html +460 -0
  51. package/coverage/lcov-report/src/Publisher/index.html +116 -0
  52. package/coverage/lcov-report/src/Server/RouteResolver.ts.html +442 -0
  53. package/coverage/lcov-report/src/Server/Router.ts.html +616 -0
  54. package/coverage/lcov-report/src/Server/index.html +131 -0
  55. package/coverage/lcov-report/src/Server/lib/ContainerServer.ts.html +280 -0
  56. package/coverage/lcov-report/src/Server/lib/Server.ts.html +403 -0
  57. package/coverage/lcov-report/src/Server/lib/container/GenericHandler.ts.html +331 -0
  58. package/coverage/lcov-report/src/Server/lib/container/GenericHandlerEvent.ts.html +547 -0
  59. package/coverage/lcov-report/src/Server/lib/container/HealthHandler.ts.html +118 -0
  60. package/coverage/lcov-report/src/Server/lib/container/Proxy.ts.html +619 -0
  61. package/coverage/lcov-report/src/Server/lib/container/Utils.ts.html +184 -0
  62. package/coverage/lcov-report/src/Server/lib/container/index.html +176 -0
  63. package/coverage/lcov-report/src/Server/lib/index.html +131 -0
  64. package/coverage/lcov-report/src/Util/AsyncSingleton.ts.html +343 -0
  65. package/coverage/lcov-report/src/Util/Utils.ts.html +313 -0
  66. package/coverage/lcov-report/src/Util/index.html +131 -0
  67. package/coverage/lcov-report/src/Validation/Validator.ts.html +217 -0
  68. package/coverage/lcov-report/src/Validation/index.html +116 -0
  69. package/coverage/lcov-report/src/index.html +116 -0
  70. package/coverage/lcov.info +2326 -0
  71. package/dist/package-lock.json +2 -2
  72. package/dist/package.json +1 -1
  73. package/package.json +1 -1
  74. package/.eslintignore +0 -3
  75. package/.eslintrc.cjs +0 -60
  76. package/.github/workflows/npmpublish.yml +0 -11
  77. package/.github/workflows/prs.yml +0 -13
  78. package/jest.config.ts +0 -33
  79. package/jest.smoke.config.ts +0 -35
  80. package/tests/API/Request.test.ts +0 -273
  81. package/tests/API/Response.test.ts +0 -367
  82. package/tests/API/Utils.test.ts +0 -167
  83. package/tests/BaseEvent/EventProcessor.test.ts +0 -261
  84. package/tests/BaseEvent/Process.test.ts +0 -49
  85. package/tests/BaseEvent/Transaction.test.ts +0 -408
  86. package/tests/Cache/Redis-client.test.ts +0 -90
  87. package/tests/Cache/Redis-cluster.test.ts +0 -100
  88. package/tests/Config/Config.test.ts +0 -205
  89. package/tests/Config/EnvironmentVar.test.ts +0 -250
  90. package/tests/Crypto/Crypto.test.ts +0 -88
  91. package/tests/Crypto/JWT.test.ts +0 -92
  92. package/tests/Database/DatabaseManager.test.ts +0 -71
  93. package/tests/Database/integrations/knex/KnexDatabase.test.ts +0 -76
  94. package/tests/Database/integrations/knex/KnexTransaction.test.ts +0 -149
  95. package/tests/Database/integrations/kysely/KyselyDatabase.test.ts +0 -113
  96. package/tests/Database/integrations/kysely/KyselyTransaction.test.ts +0 -119
  97. package/tests/Database/integrations/pg/PostgresDatabase.test.ts +0 -76
  98. package/tests/Database/integrations/pg/PostgresTransaction.test.ts +0 -118
  99. package/tests/Logger/Logger.test.ts +0 -219
  100. package/tests/Mailer/Mailer.test.ts +0 -59
  101. package/tests/Publisher/Publisher.test.ts +0 -94
  102. package/tests/Server/RouteResolver.test.ts +0 -102
  103. package/tests/Server/Router.test.ts +0 -39
  104. package/tests/Server/lib/ContainerServer.test.ts +0 -531
  105. package/tests/Server/lib/Server.test.ts +0 -12
  106. package/tests/Server/lib/container/GenericHandler.test.ts +0 -131
  107. package/tests/Server/lib/container/GenericHandlerEvent.test.ts +0 -103
  108. package/tests/Server/lib/container/HealthHandler.test.ts +0 -30
  109. package/tests/Server/lib/container/Proxy.test.ts +0 -268
  110. package/tests/Server/lib/container/Utils.test.ts +0 -47
  111. package/tests/Test.utils.ts +0 -74
  112. package/tests/Validation/Validator.test.ts +0 -76
  113. package/tsconfig.json +0 -26
  114. package/tsconfig.smoke.json +0 -26
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@creator.co/wapi",
3
- "version": "1.7.1-alpha1",
3
+ "version": "1.7.1-alpha3",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@creator.co/wapi",
9
- "version": "1.7.1-alpha1",
9
+ "version": "1.7.1-alpha3",
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
12
  "@aws-sdk/client-kms": "^3.556.0",
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creator.co/wapi",
3
- "version": "1.7.1-alpha1",
3
+ "version": "1.7.1-alpha3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creator.co/wapi",
3
- "version": "1.7.1-alpha1",
3
+ "version": "1.7.1-alpha3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/.eslintignore DELETED
@@ -1,3 +0,0 @@
1
- node_modules
2
- dist
3
- smoke-tests
package/.eslintrc.cjs DELETED
@@ -1,60 +0,0 @@
1
- /* eslint-env node */
2
- module.exports = {
3
- extends: [
4
- 'eslint:recommended',
5
- 'plugin:@typescript-eslint/recommended',
6
- 'plugin:prettier/recommended',
7
- 'plugin:import/recommended',
8
- 'plugin:import/typescript',
9
- ],
10
- parser: '@typescript-eslint/parser',
11
- plugins: ['@typescript-eslint', 'prettier'],
12
- root: true,
13
- rules: {
14
- 'prettier/prettier': [
15
- 'error',
16
- {
17
- tabWidth: 2,
18
- useTabs: false,
19
- bracketSameLine: false,
20
- semi: false,
21
- arrowParens: 'avoid',
22
- jsxSingleQuote: true,
23
- printWidth: 100,
24
- singleQuote: true,
25
- quoteProps: 'as-needed',
26
- htmlWhitespaceSensitivity: 'css',
27
- proseWrap: 'preserve',
28
- bracketSpacing: true,
29
- embeddedLanguageFormatting: 'auto',
30
- endOfLine: 'lf',
31
- trailingComma: 'es5',
32
- },
33
- ],
34
- '@typescript-eslint/ban-ts-comment': 0,
35
- '@typescript-eslint/no-explicit-any': 0,
36
- // turn on errors for missing imports
37
- 'import/no-unresolved': 'error',
38
- // 'import/no-named-as-default-member': 'off',
39
- 'import/order': [
40
- 'error',
41
- {
42
- groups: [
43
- 'builtin', // Built-in imports (come from NodeJS native) go first
44
- 'external', // <- External imports
45
- 'internal', // <- Absolute imports
46
- ['sibling', 'parent'], // <- Relative imports, the sibling and parent types they can be mingled together
47
- 'index', // <- index imports
48
- 'unknown', // <- unknown
49
- ],
50
- 'newlines-between': 'always',
51
- alphabetize: {
52
- /* sort in ascending order. Options: ["ignore", "asc", "desc"] */
53
- order: 'asc',
54
- /* ignore case. Options: [true, false] */
55
- caseInsensitive: true,
56
- },
57
- },
58
- ],
59
- },
60
- }
@@ -1,11 +0,0 @@
1
- name: NPM Publish
2
- on:
3
- push:
4
- branches: [ "main", "gabe/tweaks" ]
5
-
6
- jobs:
7
- Publish:
8
- uses: Creator-co/tool-github-workflows/.github/workflows/npm-publish.yml@main
9
- secrets: inherit
10
- with:
11
- NODE_VERSION: "20.x"
@@ -1,13 +0,0 @@
1
- name: PR Checks
2
- on:
3
- pull_request:
4
- branches:
5
- - master
6
- - main
7
-
8
- jobs:
9
- Checks:
10
- uses: Creator-co/tool-github-workflows/.github/workflows/prs-check.yml@main
11
- secrets: inherit
12
- with:
13
- NODE_VERSION: "20.x"
package/jest.config.ts DELETED
@@ -1,33 +0,0 @@
1
- import type { Config } from '@jest/types'
2
- /* eslint-env node */
3
- const config: Config.InitialOptions = {
4
- preset: 'ts-jest',
5
- testEnvironment: 'node',
6
- modulePathIgnorePatterns: ['smoke-tests'],
7
- reporters: [
8
- 'default',
9
- [
10
- 'jest-junit',
11
- {
12
- outputDirectory: 'coverage',
13
- outputName: 'jest-junit.xml',
14
- ancestorSeparator: ' › ',
15
- uniqueOutputName: 'false',
16
- suiteNameTemplate: '{filepath}',
17
- classNameTemplate: '{classname}',
18
- titleTemplate: '{title}',
19
- },
20
- ],
21
- ],
22
- coverageReporters: ['clover', 'json', 'lcov', ['text', { file: 'coverage.txt' }], 'json-summary'],
23
- collectCoverageFrom: ['src/**/*.(t|j)s', '!src/**/*.d.(t|j)s'],
24
- coverageThreshold: {
25
- global: {
26
- branches: 80,
27
- functions: 80,
28
- lines: 80,
29
- statements: 80,
30
- },
31
- },
32
- }
33
- export default config
@@ -1,35 +0,0 @@
1
- import type { Config } from '@jest/types'
2
- /* eslint-env node */
3
- const config: Config.InitialOptions = {
4
- testEnvironment: 'node',
5
- // ECMA suppport https://jestjs.io/docs/ecmascript-modules
6
- transform: {},
7
-
8
- //
9
- reporters: [
10
- 'default',
11
- [
12
- 'jest-junit',
13
- {
14
- outputDirectory: 'coverage',
15
- outputName: 'jest-junit.xml',
16
- ancestorSeparator: ' › ',
17
- uniqueOutputName: 'false',
18
- suiteNameTemplate: '{filepath}',
19
- classNameTemplate: '{classname}',
20
- titleTemplate: '{title}',
21
- },
22
- ],
23
- ],
24
- coverageReporters: ['clover', 'json', 'lcov', ['text', { file: 'coverage.txt' }], 'json-summary'],
25
- collectCoverageFrom: ['src/**/*.(t|j)s', '!src/**/*.d.(t|j)s'],
26
- coverageThreshold: {
27
- global: {
28
- branches: 80,
29
- functions: 80,
30
- lines: 80,
31
- statements: 80,
32
- },
33
- },
34
- }
35
- export default config
@@ -1,273 +0,0 @@
1
- import { APIGatewayEvent, Context } from 'aws-lambda'
2
- import { expect } from 'chai'
3
-
4
- import Request, { HttpMethod } from '../../src/API/Request'
5
- import Logger from '../../src/Logger/Logger'
6
-
7
- function newReq(event: any, context?: any) {
8
- const logger = new Logger(
9
- {
10
- logLevel: 'DEBUG',
11
- },
12
- '123-456'
13
- )
14
- return new Request<any, any, any>(
15
- <APIGatewayEvent>(<unknown>event),
16
- <Context>context ? context : {},
17
- logger
18
- )
19
- }
20
-
21
- describe('Request querystring', () => {
22
- test('Null query string', () => {
23
- const r = newReq({
24
- queryStringParameters: null,
25
- })
26
- expect(r.containsQueryParam('123')).to.be.false
27
- expect(r.getQueryParam('123')).to.be.null
28
- })
29
-
30
- test('Empty query string', () => {
31
- const r = newReq({
32
- queryStringParameters: {},
33
- })
34
- expect(r.containsQueryParam('123')).to.be.false
35
- expect(r.getQueryParam('123')).to.be.null
36
- })
37
-
38
- test('Valid query string', () => {
39
- const v = { '123': 'abc' }
40
- const r = newReq({
41
- queryStringParameters: v,
42
- })
43
- expect(r.containsQueryParam('123')).to.be.true
44
- expect(r.getQueryParam('123')).to.be.equals('abc')
45
- expect(r.getQueryParams()).to.be.deep.equal(v)
46
- })
47
-
48
- test('Valid query string number', () => {
49
- const r = newReq({
50
- queryStringParameters: { '123': 456 },
51
- })
52
- expect(r.containsQueryParam('123')).to.be.true
53
- expect(r.getQueryParam('123')).to.be.equals(456)
54
- })
55
- })
56
-
57
- describe('Request headers', () => {
58
- test('Null headers', () => {
59
- const r = newReq({ headers: null })
60
- expect(r.getHeader('123')).to.be.null
61
- })
62
-
63
- test('Empty headers', () => {
64
- const r = newReq({ headers: {} })
65
- expect(r.getHeader('123')).to.be.null
66
- })
67
-
68
- test('Valid headers', () => {
69
- const r = newReq({ headers: { '123': 'abc' } })
70
- expect(r.getHeader('123')).to.be.equals('abc')
71
- })
72
-
73
- test('Auth headers', () => {
74
- const r = newReq({ headers: { Authorization: 'abc' } })
75
- expect(r.getAuthorizationHeader()).to.be.equals('abc')
76
- })
77
- })
78
-
79
- describe('Request context', () => {
80
- test('Null context', () => {
81
- const r = newReq({ requestContext: null })
82
- expect(r.getContextParam('123')).to.be.null
83
- })
84
-
85
- test('Empty context', () => {
86
- const r = newReq({ requestContext: {} })
87
- expect(r.getContextParam('123')).to.be.null
88
- })
89
-
90
- test('Valid context', () => {
91
- const r = newReq({
92
- requestContext: { '123': 'abc' },
93
- })
94
- expect(r.getContextParam('123')).to.be.equals('abc')
95
- })
96
- })
97
-
98
- describe('Request path params', () => {
99
- test('Null path params', () => {
100
- const r = newReq({ pathParameters: null })
101
- expect(r.containsPathParam('123')).to.be.false
102
- expect(r.getPathParam('123')).to.be.null
103
- expect(r.getPathParams()).to.be.null
104
- })
105
-
106
- test('Empty path params', () => {
107
- const r = newReq({ pathParameters: {} })
108
- expect(r.containsPathParam('123')).to.be.false
109
- expect(r.getPathParam('123')).to.be.null
110
- expect(r.getPathParams()).to.be.deep.equal({})
111
- })
112
-
113
- test('Valid path params', () => {
114
- const v = { '123': 'abc' }
115
- const r = newReq({
116
- pathParameters: v,
117
- })
118
- expect(r.containsPathParam('123')).to.be.true
119
- expect(r.getPathParam('123')).to.be.equals('abc')
120
- expect(r.getPathParams()).to.be.deep.equal(v)
121
- })
122
-
123
- test('Valid path param number', () => {
124
- const v = { '123': 456 }
125
- const r = newReq({
126
- pathParameters: v,
127
- })
128
- expect(r.containsPathParam('123')).to.be.true
129
- expect(r.getPathParam('123')).to.be.equals(456)
130
- expect(r.getPathParams()).to.be.deep.equal(v)
131
- })
132
-
133
- test('Fix path params', () => {
134
- const v = { '123': 'abc' }
135
- const r = newReq({ pathParameters: null })
136
- r.setFixedPathParams(
137
- Object.keys(v).map(k => ({ name: k })),
138
- ['/'].concat(Object.values(v))
139
- )
140
- expect(r.containsPathParam('123')).to.be.true
141
- expect(r.getPathParam('123')).to.be.equals('abc')
142
- expect(r.getPathParams()).to.be.deep.equal(v)
143
- })
144
- })
145
-
146
- describe('Request body', () => {
147
- test('Null body', () => {
148
- const r = newReq({ body: null })
149
- expect(r.getBody()).to.be.null
150
- })
151
-
152
- test('Empty body', () => {
153
- const r = newReq({ body: {} })
154
- expect(r.getBody()).to.be.deep.equals({})
155
- })
156
-
157
- test('Empty string body', () => {
158
- const r = newReq({ body: '{}' })
159
- expect(r.getBody()).to.be.deep.equals({})
160
- })
161
-
162
- test('Broken json string body', () => {
163
- const r = newReq({ body: '{name": "Joe"}' })
164
- expect(r.getBody()).to.be.equals('{name": "Joe"}')
165
- })
166
-
167
- test('Valid string body', () => {
168
- const r = newReq({ body: '{"name": "Joe"}' })
169
- expect(r.getBody()).to.be.deep.equals({
170
- name: 'Joe',
171
- })
172
- })
173
-
174
- test('Valid json body', () => {
175
- const r = newReq({ body: { name: 'Joe' } })
176
- expect(r.getBody()).to.be.deep.equals({
177
- name: 'Joe',
178
- })
179
- })
180
- })
181
-
182
- describe('Request path/method', () => {
183
- test('Null path/method', () => {
184
- const r = newReq({
185
- path: null,
186
- httpMethod: null,
187
- })
188
- expect(r.getPath()).to.be.null
189
- expect(r.getMethod.bind(r)).to.throw('Invalid HTTP method: null')
190
- })
191
-
192
- test('Empty path/method', () => {
193
- const r = newReq({
194
- path: '',
195
- httpMethod: '',
196
- })
197
- expect(r.getPath()).to.be.a('string')
198
- expect(r.getPath()).to.be.equals('')
199
- expect(r.getMethod.bind(r)).to.throw('Invalid HTTP method: ')
200
- })
201
-
202
- test('Valid method/path', () => {
203
- const r = newReq({
204
- path: '/root',
205
- httpMethod: HttpMethod.GET,
206
- })
207
- expect(r.getPath()).to.be.a('string')
208
- expect(r.getPath()).to.be.equals('/root')
209
- expect(r.getMethod()).to.be.a('string')
210
- expect(r.getMethod()).to.be.equals(HttpMethod.GET)
211
- })
212
-
213
- test('Case insensitive method', () => {
214
- const r = newReq({
215
- path: '/root',
216
- httpMethod: 'poST',
217
- })
218
-
219
- expect(r.getMethod()).to.be.equals(HttpMethod.POST)
220
- })
221
- })
222
-
223
- describe('Request ID', () => {
224
- test('From context', () => {
225
- const r = newReq({}, { awsRequestId: '123' })
226
- expect(r.getRequestID()).to.not.be.null
227
- expect(r.getRequestID()).to.be.equals('123')
228
- })
229
-
230
- test('From event', () => {
231
- const r = newReq({
232
- requestContext: { requestId: '123' },
233
- })
234
- expect(r.getRequestID()).to.not.be.null
235
- expect(r.getRequestID()).to.be.equals('123')
236
- })
237
-
238
- test('unknown', () => {
239
- const r = newReq({})
240
- expect(r.getRequestID()).to.not.be.null
241
- expect(r.getRequestID()).to.be.equals('unknown')
242
- })
243
- })
244
-
245
- describe('Request origin IP', () => {
246
- test('From context', () => {
247
- const r = newReq({
248
- requestContext: {
249
- identity: { sourceIp: '127.0.0.1' },
250
- },
251
- })
252
- expect(r.getOriginIP()).to.not.be.null
253
- expect(r.getOriginIP()).to.be.equals('127.0.0.1')
254
- })
255
-
256
- test('From header', () => {
257
- const r = newReq({
258
- headers: {
259
- 'X-Forwarded-For': '127.0.0.1',
260
- },
261
- })
262
- expect(r.getOriginIP()).to.not.be.null
263
- expect(r.getOriginIP()).to.be.equals('127.0.0.1')
264
- })
265
-
266
- test('unknown', () => {
267
- const r = newReq({})
268
- expect(r.getOriginIP()).to.not.be.null
269
- expect(r.getOriginIP()).to.be.equals('unknown')
270
- })
271
- })
272
-
273
- export {}