@ikonintegration/ikapi 4.0.1 → 5.0.0
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.
- package/.eslintignore +3 -0
- package/.eslintrc.cjs +81 -0
- package/.github/workflows/npmpublish.yml +8 -19
- package/.github/workflows/prs.yml +12 -0
- package/README.md +89 -99
- package/dist/index.d.ts +16 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/package-lock.json +11881 -0
- package/dist/package.json +81 -0
- package/dist/src/API/Request.d.ts +125 -0
- package/dist/src/API/Request.js +185 -0
- package/dist/src/API/Request.js.map +1 -0
- package/dist/src/API/Response.d.ts +188 -0
- package/dist/src/API/Response.js +270 -0
- package/dist/src/API/Response.js.map +1 -0
- package/dist/src/BaseEvent/DynamoTransaction.d.ts +70 -0
- package/dist/src/BaseEvent/DynamoTransaction.js +104 -0
- package/dist/src/BaseEvent/DynamoTransaction.js.map +1 -0
- package/dist/src/BaseEvent/EventProcessor.d.ts +58 -0
- package/dist/src/BaseEvent/EventProcessor.js +101 -0
- package/dist/src/BaseEvent/EventProcessor.js.map +1 -0
- package/dist/src/BaseEvent/Process.d.ts +50 -0
- package/dist/src/BaseEvent/Process.js +64 -0
- package/dist/src/BaseEvent/Process.js.map +1 -0
- package/dist/src/BaseEvent/StepTransaction.d.ts +23 -0
- package/dist/src/BaseEvent/StepTransaction.js +27 -0
- package/dist/src/BaseEvent/StepTransaction.js.map +1 -0
- package/dist/src/BaseEvent/Transaction.d.ts +149 -0
- package/dist/src/BaseEvent/Transaction.js +224 -0
- package/dist/src/BaseEvent/Transaction.js.map +1 -0
- package/dist/src/Cache/Redis.d.ts +29 -0
- package/dist/src/Cache/Redis.js +80 -0
- package/dist/src/Cache/Redis.js.map +1 -0
- package/dist/src/Cache/types.d.ts +31 -0
- package/dist/src/Cache/types.js +2 -0
- package/dist/src/Cache/types.js.map +1 -0
- package/dist/src/Config/Configuration.d.ts +123 -0
- package/dist/src/Config/Configuration.js +109 -0
- package/dist/src/Config/Configuration.js.map +1 -0
- package/dist/src/Config/EnvironmentVar.d.ts +74 -0
- package/dist/src/Config/EnvironmentVar.js +138 -0
- package/dist/src/Config/EnvironmentVar.js.map +1 -0
- package/dist/src/Crypto/Crypto.d.ts +45 -0
- package/dist/src/Crypto/Crypto.js +72 -0
- package/dist/src/Crypto/Crypto.js.map +1 -0
- package/dist/src/Database/Database.d.ts +21 -0
- package/dist/src/Database/Database.js +15 -0
- package/dist/src/Database/Database.js.map +1 -0
- package/dist/src/Database/DatabaseManager.d.ts +47 -0
- package/dist/src/Database/DatabaseManager.js +60 -0
- package/dist/src/Database/DatabaseManager.js.map +1 -0
- package/dist/src/Database/DatabaseTransaction.d.ts +101 -0
- package/dist/src/Database/DatabaseTransaction.js +126 -0
- package/dist/src/Database/DatabaseTransaction.js.map +1 -0
- package/dist/src/Database/index.d.ts +10 -0
- package/dist/src/Database/index.js +15 -0
- package/dist/src/Database/index.js.map +1 -0
- package/dist/src/Database/integrations/dynamo/DynamoDatabase.d.ts +35 -0
- package/dist/src/Database/integrations/dynamo/DynamoDatabase.js +59 -0
- package/dist/src/Database/integrations/dynamo/DynamoDatabase.js.map +1 -0
- package/dist/src/Database/integrations/kysely/KyselyDatabase.d.ts +66 -0
- package/dist/src/Database/integrations/kysely/KyselyDatabase.js +86 -0
- package/dist/src/Database/integrations/kysely/KyselyDatabase.js.map +1 -0
- package/dist/src/Database/integrations/kysely/KyselyTransaction.d.ts +70 -0
- package/dist/src/Database/integrations/kysely/KyselyTransaction.js +118 -0
- package/dist/src/Database/integrations/kysely/KyselyTransaction.js.map +1 -0
- package/dist/src/Database/integrations/pgsql/PostgresDatabase.d.ts +36 -0
- package/dist/src/Database/integrations/pgsql/PostgresDatabase.js +54 -0
- package/dist/src/Database/integrations/pgsql/PostgresDatabase.js.map +1 -0
- package/dist/src/Database/integrations/pgsql/PostgresTransaction.d.ts +63 -0
- package/dist/src/Database/integrations/pgsql/PostgresTransaction.js +61 -0
- package/dist/src/Database/integrations/pgsql/PostgresTransaction.js.map +1 -0
- package/dist/src/Database/types.d.ts +76 -0
- package/dist/src/Database/types.js +2 -0
- package/dist/src/Database/types.js.map +1 -0
- package/dist/src/Globals.d.ts +93 -0
- package/dist/src/Globals.js +99 -0
- package/dist/src/Globals.js.map +1 -0
- package/dist/src/Logger/Logger.d.ts +161 -0
- package/dist/src/Logger/Logger.js +299 -0
- package/dist/src/Logger/Logger.js.map +1 -0
- package/dist/src/Mailer/Mailer.d.ts +78 -0
- package/dist/src/Mailer/Mailer.js +182 -0
- package/dist/src/Mailer/Mailer.js.map +1 -0
- package/dist/src/Publisher/Publisher.d.ts +39 -0
- package/dist/src/Publisher/Publisher.js +77 -0
- package/dist/src/Publisher/Publisher.js.map +1 -0
- package/dist/src/Server/RouteResolver.d.ts +33 -0
- package/dist/src/Server/RouteResolver.js +100 -0
- package/dist/src/Server/RouteResolver.js.map +1 -0
- package/dist/src/Server/Router.d.ts +157 -0
- package/dist/src/Server/Router.js +32 -0
- package/dist/src/Server/Router.js.map +1 -0
- package/dist/src/Server/lib/ContainerServer.d.ts +42 -0
- package/dist/src/Server/lib/ContainerServer.js +66 -0
- package/dist/src/Server/lib/ContainerServer.js.map +1 -0
- package/dist/src/Server/lib/Server.d.ts +45 -0
- package/dist/src/Server/lib/Server.js +93 -0
- package/dist/src/Server/lib/Server.js.map +1 -0
- package/dist/src/Server/lib/container/GenericHandler.d.ts +9 -0
- package/dist/src/Server/lib/container/GenericHandler.js +82 -0
- package/dist/src/Server/lib/container/GenericHandler.js.map +1 -0
- package/dist/src/Server/lib/container/GenericHandlerEvent.d.ts +52 -0
- package/dist/src/Server/lib/container/GenericHandlerEvent.js +132 -0
- package/dist/src/Server/lib/container/GenericHandlerEvent.js.map +1 -0
- package/dist/src/Server/lib/container/HealthHandler.d.ts +9 -0
- package/dist/src/Server/lib/container/HealthHandler.js +19 -0
- package/dist/src/Server/lib/container/HealthHandler.js.map +1 -0
- package/dist/src/Server/lib/container/Proxy.d.ts +67 -0
- package/dist/src/Server/lib/container/Proxy.js +143 -0
- package/dist/src/Server/lib/container/Proxy.js.map +1 -0
- package/dist/src/Server/lib/container/Utils.d.ts +14 -0
- package/dist/src/Server/lib/container/Utils.js +37 -0
- package/dist/src/Server/lib/container/Utils.js.map +1 -0
- package/dist/src/Util/AsyncSingleton.d.ts +31 -0
- package/dist/src/Util/AsyncSingleton.js +83 -0
- package/dist/src/Util/AsyncSingleton.js.map +1 -0
- package/dist/src/Util/Utils.d.ts +61 -0
- package/dist/src/Util/Utils.js +147 -0
- package/dist/src/Util/Utils.js.map +1 -0
- package/dist/src/Validation/Validator.d.ts +17 -0
- package/dist/src/Validation/Validator.js +39 -0
- package/dist/src/Validation/Validator.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/index.ts +41 -0
- package/jest.config.ts +37 -0
- package/jest.smoke.config.ts +34 -0
- package/package.json +66 -22
- package/src/API/Request.ts +214 -0
- package/src/API/Response.ts +370 -0
- package/src/BaseEvent/DynamoTransaction.ts +175 -0
- package/src/BaseEvent/EventProcessor.ts +140 -0
- package/src/BaseEvent/Process.ts +78 -0
- package/src/BaseEvent/StepTransaction.ts +35 -0
- package/src/BaseEvent/Transaction.ts +323 -0
- package/src/Cache/Redis.ts +89 -0
- package/src/Cache/types.ts +33 -0
- package/src/Config/Configuration.ts +199 -0
- package/src/Config/EnvironmentVar.ts +142 -0
- package/src/Crypto/Crypto.ts +89 -0
- package/src/Database/Database.ts +22 -0
- package/src/Database/DatabaseManager.ts +67 -0
- package/src/Database/DatabaseTransaction.ts +170 -0
- package/src/Database/index.ts +27 -0
- package/src/Database/integrations/dynamo/DynamoDatabase.ts +58 -0
- package/src/Database/integrations/kysely/KyselyDatabase.ts +99 -0
- package/src/Database/integrations/kysely/KyselyTransaction.ts +172 -0
- package/src/Database/integrations/pgsql/PostgresDatabase.ts +56 -0
- package/src/Database/integrations/pgsql/PostgresTransaction.ts +87 -0
- package/src/Database/types.ts +85 -0
- package/src/Globals.ts +103 -0
- package/src/Logger/Logger.ts +363 -0
- package/src/Mailer/Mailer.ts +217 -0
- package/src/Publisher/Publisher.ts +96 -0
- package/src/Server/RouteResolver.ts +124 -0
- package/src/Server/Router.ts +200 -0
- package/src/Server/lib/ContainerServer.ts +65 -0
- package/src/Server/lib/Server.ts +109 -0
- package/src/Server/lib/container/GenericHandler.ts +76 -0
- package/src/Server/lib/container/GenericHandlerEvent.ts +154 -0
- package/src/Server/lib/container/HealthHandler.ts +11 -0
- package/src/Server/lib/container/Proxy.ts +172 -0
- package/src/Server/lib/container/Utils.ts +33 -0
- package/src/Util/AsyncSingleton.ts +86 -0
- package/src/Util/Utils.ts +131 -0
- package/src/Validation/Validator.ts +45 -0
- package/tests/API/Request.test.ts +273 -0
- package/tests/API/Response.test.ts +367 -0
- package/tests/BaseEvent/DynamoTransaction.test.ts +272 -0
- package/tests/BaseEvent/EventProcessor.test.ts +263 -0
- package/tests/BaseEvent/Process.test.ts +47 -0
- package/tests/BaseEvent/StepTransaction.test.ts +44 -0
- package/tests/BaseEvent/Transaction.test.ts +402 -0
- package/tests/Cache/Redis-client.test.ts +90 -0
- package/tests/Cache/Redis-cluster.test.ts +100 -0
- package/tests/Config/Config.test.ts +205 -0
- package/tests/Config/EnvironmentVar.test.ts +251 -0
- package/tests/Crypto/Crypto.test.ts +88 -0
- package/tests/Database/DatabaseManager.test.ts +79 -0
- package/tests/Database/integrations/dynamo/DynamoDatabase.test.ts +44 -0
- package/tests/Database/integrations/kysely/KyselyDatabase.test.ts +113 -0
- package/tests/Database/integrations/kysely/KyselyTransaction.test.ts +119 -0
- package/tests/Database/integrations/pg/PostgresDatabase.test.ts +76 -0
- package/tests/Database/integrations/pg/PostgresTransaction.test.ts +118 -0
- package/tests/Logger/Logger.test.ts +215 -0
- package/tests/Mailer/Mailer.test.ts +59 -0
- package/tests/Publisher/Publisher.test.ts +60 -0
- package/tests/Server/RouteResolver.test.ts +116 -0
- package/tests/Server/Router.test.ts +39 -0
- package/tests/Server/lib/ContainerServer.test.ts +531 -0
- package/tests/Server/lib/Server.test.ts +12 -0
- package/tests/Server/lib/container/GenericHandler.test.ts +131 -0
- package/tests/Server/lib/container/GenericHandlerEvent.test.ts +103 -0
- package/tests/Server/lib/container/HealthHandler.test.ts +30 -0
- package/tests/Server/lib/container/Proxy.test.ts +268 -0
- package/tests/Server/lib/container/Utils.test.ts +47 -0
- package/tests/Test.utils.ts +78 -0
- package/tests/Utils/Utils.test.ts +229 -0
- package/tests/Validation/Validator.test.ts +82 -0
- package/tsconfig.json +26 -0
- package/tsconfig.smoke.json +26 -0
- package/index.js +0 -88
- package/src/API/IKRequest.js +0 -52
- package/src/API/IKResponse.js +0 -119
- package/src/API/IKUtils.js +0 -51
- package/src/BaseEvent/IKProcess.js +0 -77
- package/src/BaseEvent/IKTransaction.js +0 -139
- package/src/Cache/Prototype/IKCache.js +0 -17
- package/src/Cache/Redis/IKRedis.js +0 -148
- package/src/Database/DDB/IKDB.js +0 -56
- package/src/Database/DDB/IKDBBaseExpression.js +0 -130
- package/src/Database/DDB/IKDBBaseQuery.js +0 -151
- package/src/Database/DDB/IKDBQueryBatchGet.js +0 -37
- package/src/Database/DDB/IKDBQueryBatchWrite.js +0 -64
- package/src/Database/DDB/IKDBQueryDelete.js +0 -34
- package/src/Database/DDB/IKDBQueryGet.js +0 -48
- package/src/Database/DDB/IKDBQueryPut.js +0 -87
- package/src/Database/DDB/IKDBQueryScan.js +0 -45
- package/src/Database/DDB/IKDBQueryTransactionalWrite.js +0 -69
- package/src/Database/DDB/IKDBQueryUpdate.js +0 -221
- package/src/Database/DDB/_IKDBQueryTransactionalRead.js +0 -46
- package/src/Database/PSQL/IKDB.js +0 -41
- package/src/Database/PSQL/IKDBBaseQuery.js +0 -26
- package/src/Database/Prototype/IKDB.js +0 -21
- package/src/Database/Prototype/IKDBBaseQuery.js +0 -14
- package/src/IKDynamoStream.js +0 -42
- package/src/IKEventProcessor.js +0 -42
- package/src/IKGlobals.js +0 -24
- package/src/IKRouter.js +0 -47
- package/src/IKStepTransaction.js +0 -14
- package/src/Logger/IKLogger.js +0 -136
- package/src/Mailer/IKMailer.js +0 -69
- package/src/Publisher/IKPublisher.js +0 -44
- package/src/Tracker/IKExecutionTracker.js +0 -79
- package/src/Validation/IKValidation.js +0 -76
package/.eslintignore
ADDED
package/.eslintrc.cjs
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
'plugin:require-extensions/recommended',
|
|
10
|
+
],
|
|
11
|
+
parser: '@typescript-eslint/parser',
|
|
12
|
+
plugins: ['@typescript-eslint', 'prettier', 'require-extensions'],
|
|
13
|
+
root: true,
|
|
14
|
+
rules: {
|
|
15
|
+
'import/extensions': ['error', 'always'],
|
|
16
|
+
'prettier/prettier': [
|
|
17
|
+
'error',
|
|
18
|
+
{
|
|
19
|
+
tabWidth: 2,
|
|
20
|
+
useTabs: false,
|
|
21
|
+
bracketSameLine: false,
|
|
22
|
+
semi: false,
|
|
23
|
+
arrowParens: 'avoid',
|
|
24
|
+
jsxSingleQuote: true,
|
|
25
|
+
printWidth: 100,
|
|
26
|
+
singleQuote: true,
|
|
27
|
+
quoteProps: 'as-needed',
|
|
28
|
+
htmlWhitespaceSensitivity: 'css',
|
|
29
|
+
proseWrap: 'preserve',
|
|
30
|
+
bracketSpacing: true,
|
|
31
|
+
embeddedLanguageFormatting: 'auto',
|
|
32
|
+
endOfLine: 'lf',
|
|
33
|
+
trailingComma: 'es5',
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
'@typescript-eslint/ban-ts-comment': 0,
|
|
37
|
+
'@typescript-eslint/no-explicit-any': 0,
|
|
38
|
+
'@typescript-eslint/explicit-member-accessibility': [
|
|
39
|
+
'error',
|
|
40
|
+
{
|
|
41
|
+
accessibility: 'explicit',
|
|
42
|
+
overrides: {
|
|
43
|
+
accessors: 'explicit',
|
|
44
|
+
constructors: 'no-public',
|
|
45
|
+
methods: 'explicit',
|
|
46
|
+
properties: 'explicit',
|
|
47
|
+
parameterProperties: 'explicit',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
'lines-between-class-members': [
|
|
52
|
+
'error',
|
|
53
|
+
{
|
|
54
|
+
enforce: [{ blankLine: 'always', prev: 'method', next: 'method' }],
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
// turn on errors for missing imports
|
|
58
|
+
'import/no-unresolved': ['error', { ignore: ['\\.js$'] }],
|
|
59
|
+
// 'import/no-named-as-default-member': 'off',
|
|
60
|
+
'import/order': [
|
|
61
|
+
'error',
|
|
62
|
+
{
|
|
63
|
+
groups: [
|
|
64
|
+
'builtin', // Built-in imports (come from NodeJS native) go first
|
|
65
|
+
'external', // <- External imports
|
|
66
|
+
'internal', // <- Absolute imports
|
|
67
|
+
['sibling', 'parent'], // <- Relative imports, the sibling and parent types they can be mingled together
|
|
68
|
+
'index', // <- index imports
|
|
69
|
+
'unknown', // <- unknown
|
|
70
|
+
],
|
|
71
|
+
'newlines-between': 'always',
|
|
72
|
+
alphabetize: {
|
|
73
|
+
/* sort in ascending order. Options: ["ignore", "asc", "desc"] */
|
|
74
|
+
order: 'asc',
|
|
75
|
+
/* ignore case. Options: [true, false] */
|
|
76
|
+
caseInsensitive: true,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
}
|
|
@@ -1,22 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
|
|
3
|
-
|
|
4
|
-
name: Node.js Package
|
|
5
|
-
|
|
1
|
+
name: NPM Publish
|
|
6
2
|
on:
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
push:
|
|
4
|
+
branches: [ "master" ]
|
|
9
5
|
|
|
10
6
|
jobs:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
with:
|
|
17
|
-
node-version: 18
|
|
18
|
-
registry-url: https://registry.npmjs.org/
|
|
19
|
-
- run: npm ci
|
|
20
|
-
- run: npm publish --access='public'
|
|
21
|
-
env:
|
|
22
|
-
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
|
|
7
|
+
Publish:
|
|
8
|
+
uses: ikon-integration/tools-github-workflows/.github/workflows/npm-publish.yml@master
|
|
9
|
+
secrets: inherit
|
|
10
|
+
with:
|
|
11
|
+
NODE_VERSION: "20.x"
|
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# IKApi 
|
|
2
2
|
Ikon nodejs API foundation
|
|
3
3
|
|
|
4
|
+
[Docs](https://ikon-integration.github.io/ikapi/)
|
|
4
5
|
|
|
5
6
|
### Overall
|
|
6
7
|
|
|
@@ -13,124 +14,113 @@ Ikon nodejs API foundation
|
|
|
13
14
|
|
|
14
15
|
- Router
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
import
|
|
17
|
+
```
|
|
18
|
+
import { Router } from '@ikonintegration/ikapi';
|
|
19
|
+
import HealthCheck from './routes/health/get';
|
|
18
20
|
|
|
19
21
|
const routes = [
|
|
20
|
-
{ route: '/
|
|
22
|
+
{ route: '/health', method: 'GET', handler: HealthCheck.handler },
|
|
23
|
+
// Additional routes can be added here
|
|
21
24
|
];
|
|
22
|
-
//Main handler
|
|
23
|
-
export const handler = async (event, context) => {
|
|
24
|
-
(await (new IKAPI.IKRouter(routes, {
|
|
25
|
-
database: {
|
|
26
|
-
type: 'DDB | SQL', -- fallback to DDB if not set
|
|
27
|
-
//DDB Specific
|
|
28
|
-
region: IBEWCoreGlobals.DatabaseRegion,
|
|
29
|
-
tableName: IBEWCoreGlobals.DatabaseTableName,
|
|
30
|
-
//SQL Specific
|
|
31
|
-
host: '127.0.0.1', database: 'DB',
|
|
32
|
-
port: 3307, user: 'root', password: 'IDK'
|
|
33
|
-
},
|
|
34
|
-
//Cache
|
|
35
|
-
cache: {
|
|
36
|
-
type: 'REDIS',
|
|
37
|
-
host: '127.0.0.1',
|
|
38
|
-
password: '22P',
|
|
39
|
-
user: '22U',
|
|
40
|
-
enableTLS: true,
|
|
41
|
-
},
|
|
42
|
-
//IKValidator
|
|
43
|
-
validation: {
|
|
44
|
-
additionalTypes: { TYPE: (val) => { return validate(val); } }
|
|
45
|
-
},
|
|
46
|
-
//Logger
|
|
47
|
-
logger: {
|
|
48
|
-
//takes precende over process.env.LOG_LEVEL
|
|
49
|
-
level: 'DEBUG' | 'INFO' | 'WARN' | 'ERROR',
|
|
50
|
-
enableSensitiveFiltering: false, //defaults to false
|
|
51
|
-
sensitiveFilteringKeywords: [], //replaced default blacklist set
|
|
52
|
-
},
|
|
53
|
-
//Queue
|
|
54
|
-
publisher: { region: 'SNS-REGION' },
|
|
55
|
-
//Resources tracker
|
|
56
|
-
resourcesTracker: { //by default, it will auto track (lambda, ecs, ddb)
|
|
57
|
-
busName: 'busName',
|
|
58
|
-
region: 'region',
|
|
59
|
-
appName: 'appName',
|
|
60
|
-
}
|
|
61
|
-
};)).handleEvent(event, context));
|
|
62
|
-
}
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
- Mailer
|
|
66
25
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
26
|
+
export const router = new Router({
|
|
27
|
+
routes,
|
|
28
|
+
healthCheckRoute: '/otherHealth',
|
|
29
|
+
logger: {
|
|
30
|
+
logLevel: 'DEBUG', // or process.env.LOG_LEVEL
|
|
31
|
+
sensitiveFilteringKeywords: ['password', 'secret'],
|
|
32
|
+
},
|
|
33
|
+
});
|
|
70
34
|
|
|
71
|
-
|
|
35
|
+
// Handler export
|
|
36
|
+
export const handler = router.getExport();
|
|
72
37
|
|
|
73
|
-
```
|
|
74
|
-
export const main = async () => {
|
|
75
|
-
const interval = (Docket.Globals.ExtractorPollerInterval * 1000);
|
|
76
|
-
console.debug('Using interval of', interval);
|
|
77
|
-
//init authorization
|
|
78
|
-
await (new Docket.Core({}, Docket.Globals.AccessLevel.ANY)).authenticate(async (core) => {
|
|
79
|
-
await (new IKAPI.IKProcess(Docket.Globals.API_Config, interval)).execute( async (process) => {
|
|
80
|
-
await pull(core);
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
38
|
```
|
|
85
39
|
|
|
86
|
-
-
|
|
40
|
+
- Route
|
|
87
41
|
|
|
88
42
|
```
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
43
|
+
import { Response, Route, HttpMethod } from '@ikonintegration/ikapi';
|
|
44
|
+
|
|
45
|
+
interface GetHealthRoute extends Route<null, { message: string }> {}
|
|
46
|
+
|
|
47
|
+
export default class HealthCheck implements GetHealthRoute {
|
|
48
|
+
public path: string = '/health';
|
|
49
|
+
public method: HttpMethod = HttpMethod.GET;
|
|
50
|
+
public openApi = {
|
|
51
|
+
summary: 'System health check',
|
|
52
|
+
description: 'Returns if the system is healthy or not',
|
|
53
|
+
tags: ['Health'],
|
|
54
|
+
security: [],
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
public handler: GetHealthRoute['handler'] = async () => {
|
|
58
|
+
return new Response({ message: 'System is healthy' });
|
|
59
|
+
};
|
|
60
|
+
}
|
|
100
61
|
```
|
|
101
62
|
|
|
63
|
+
|
|
102
64
|
- Transaction
|
|
103
65
|
|
|
104
66
|
```
|
|
67
|
+
import { Response, ResponseErrorType, Transaction } from '@ikonintegration/ikapi'
|
|
68
|
+
import type { Context, SQSEvent } from 'aws-lambda'
|
|
69
|
+
|
|
70
|
+
import Core from '../core/Core.js'
|
|
71
|
+
import Globals, { AccessLevel } from '../core/Globals.js'
|
|
72
|
+
|
|
73
|
+
export type SuccessResponseType = { message: string }
|
|
74
|
+
|
|
105
75
|
//Main handler
|
|
106
|
-
export const handler = async (event, context) => {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
76
|
+
export const handler = async (event: SQSEvent, context: Context): Promise<void> => {
|
|
77
|
+
await new Transaction<null, SuccessResponseType | ResponseErrorType>(
|
|
78
|
+
event,
|
|
79
|
+
context,
|
|
80
|
+
Globals.API_Config
|
|
81
|
+
).execute(async transaction => {
|
|
82
|
+
const type = event['eventType']
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
84
|
+
return await new Core(transaction, AccessLevel.PUBLIC).authenticate(async core => {
|
|
85
|
+
// Schedule
|
|
86
|
+
if (type == 'SCHEDULE_1') {
|
|
87
|
+
/* Schedule more message to SQS?*/
|
|
88
|
+
return Response.SuccessResponse({ message: '213' })
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return Response.BadRequestResponse('No handler for the specified event type!')
|
|
92
|
+
})
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
|
|
119
96
|
```
|
|
120
97
|
|
|
121
|
-
-
|
|
98
|
+
- Event Processor (SQS)
|
|
122
99
|
|
|
123
100
|
```
|
|
101
|
+
import { EventProcessor, Response } from '@ikonintegration/ikapi'
|
|
102
|
+
import type { Context, SQSEvent } from 'aws-lambda'
|
|
103
|
+
|
|
104
|
+
import Core from '../core/Core.js'
|
|
105
|
+
import Globals, { AccessLevel } from '../core/Globals.js'
|
|
106
|
+
|
|
107
|
+
export type SuccessResponseType = { message: string }
|
|
108
|
+
|
|
124
109
|
//Main handler
|
|
125
|
-
export const handler = async (event, context) => {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
110
|
+
export const handler = async (event: SQSEvent, context: Context): Promise<void> => {
|
|
111
|
+
await new EventProcessor<SuccessResponseType | null>(
|
|
112
|
+
event,
|
|
113
|
+
context,
|
|
114
|
+
Globals.API_Config
|
|
115
|
+
).processEvent(async (transaction, recordContent) => {
|
|
116
|
+
const type = event['eventType'] || recordContent?.['eventType']
|
|
117
|
+
return await new Core(transaction, AccessLevel.PUBLIC).authenticate(async core => {
|
|
118
|
+
// Schedule
|
|
119
|
+
if (type == Globals.EmailEventType.TEMPLATE_EMAIL)
|
|
120
|
+
return await templateEmailNotification(recordContent, core)
|
|
121
|
+
|
|
122
|
+
return Response.BadRequestResponse('No handler for the specified event type!')
|
|
123
|
+
})
|
|
124
|
+
})
|
|
125
|
+
}
|
|
136
126
|
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { HttpMethod } from './src/API/Request.js';
|
|
2
|
+
import Response, { ResponseErrorType } from './src/API/Response.js';
|
|
3
|
+
import DynamoTransaction from './src/BaseEvent/DynamoTransaction.js';
|
|
4
|
+
import EventProcessor from './src/BaseEvent/EventProcessor.js';
|
|
5
|
+
import Process from './src/BaseEvent/Process.js';
|
|
6
|
+
import StepTransaction from './src/BaseEvent/StepTransaction.js';
|
|
7
|
+
import Transaction, { TransactionConfig } from './src/BaseEvent/Transaction.js';
|
|
8
|
+
import Redis from './src/Cache/Redis.js';
|
|
9
|
+
import Configuration from './src/Config/Configuration.js';
|
|
10
|
+
import Crypto from './src/Crypto/Crypto.js';
|
|
11
|
+
import * as Database from './src/Database/index.js';
|
|
12
|
+
import Mailer from './src/Mailer/Mailer.js';
|
|
13
|
+
import Router, { Route } from './src/Server/Router.js';
|
|
14
|
+
import AsyncSingleton from './src/Util/AsyncSingleton.js';
|
|
15
|
+
import Utils from './src/Util/Utils.js';
|
|
16
|
+
export { Transaction, Process, EventProcessor, DynamoTransaction, StepTransaction, Router, Route, HttpMethod, Mailer, Crypto, Configuration, Redis, Database, Response, ResponseErrorType, Utils, AsyncSingleton, TransactionConfig, };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { HttpMethod } from './src/API/Request.js';
|
|
2
|
+
import Response from './src/API/Response.js';
|
|
3
|
+
import DynamoTransaction from './src/BaseEvent/DynamoTransaction.js';
|
|
4
|
+
import EventProcessor from './src/BaseEvent/EventProcessor.js';
|
|
5
|
+
import Process from './src/BaseEvent/Process.js';
|
|
6
|
+
import StepTransaction from './src/BaseEvent/StepTransaction.js';
|
|
7
|
+
import Transaction from './src/BaseEvent/Transaction.js';
|
|
8
|
+
import Redis from './src/Cache/Redis.js';
|
|
9
|
+
import Configuration from './src/Config/Configuration.js';
|
|
10
|
+
import Crypto from './src/Crypto/Crypto.js';
|
|
11
|
+
import * as Database from './src/Database/index.js';
|
|
12
|
+
import Mailer from './src/Mailer/Mailer.js';
|
|
13
|
+
import Router from './src/Server/Router.js';
|
|
14
|
+
import AsyncSingleton from './src/Util/AsyncSingleton.js';
|
|
15
|
+
import Utils from './src/Util/Utils.js';
|
|
16
|
+
export {
|
|
17
|
+
// Base Events
|
|
18
|
+
Transaction, Process, EventProcessor, DynamoTransaction, StepTransaction,
|
|
19
|
+
// Http
|
|
20
|
+
Router, HttpMethod,
|
|
21
|
+
// Modules
|
|
22
|
+
Mailer, Crypto, Configuration, Redis, Database,
|
|
23
|
+
// API
|
|
24
|
+
Response,
|
|
25
|
+
// Helpers
|
|
26
|
+
Utils, AsyncSingleton, };
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,QAA+B,MAAM,uBAAuB,CAAA;AACnE,OAAO,iBAAiB,MAAM,sCAAsC,CAAA;AACpE,OAAO,cAAc,MAAM,mCAAmC,CAAA;AAC9D,OAAO,OAAO,MAAM,4BAA4B,CAAA;AAChD,OAAO,eAAe,MAAM,oCAAoC,CAAA;AAChE,OAAO,WAAkC,MAAM,gCAAgC,CAAA;AAC/E,OAAO,KAAK,MAAM,sBAAsB,CAAA;AACxC,OAAO,aAAa,MAAM,+BAA+B,CAAA;AACzD,OAAO,MAAM,MAAM,wBAAwB,CAAA;AAC3C,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAA;AACnD,OAAO,MAAM,MAAM,wBAAwB,CAAA;AAC3C,OAAO,MAAiB,MAAM,wBAAwB,CAAA;AACtD,OAAO,cAAc,MAAM,8BAA8B,CAAA;AACzD,OAAO,KAAK,MAAM,qBAAqB,CAAA;AAEvC,OAAO;AACL,cAAc;AACd,WAAW,EACX,OAAO,EACP,cAAc,EACd,iBAAiB,EACjB,eAAe;AACf,OAAO;AACP,MAAM,EAEN,UAAU;AACV,UAAU;AACV,MAAM,EACN,MAAM,EACN,aAAa,EACb,KAAK,EACL,QAAQ;AACR,MAAM;AACN,QAAQ;AAER,UAAU;AACV,KAAK,EACL,cAAc,GAEf,CAAA"}
|