@seeka-labs/cli-apps 1.1.23 → 1.1.25
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/LICENSE +19 -19
- package/dist/index.js +10 -10
- package/dist/index.js.map +4 -4
- package/dist/init-templates/aws-lambda/.example.gitignore +48 -48
- package/dist/init-templates/aws-lambda/.nvmrc +1 -1
- package/dist/init-templates/aws-lambda/README.md +76 -76
- package/dist/init-templates/aws-lambda/jest.config.js +4 -4
- package/dist/init-templates/aws-lambda/package.json +51 -54
- package/dist/init-templates/aws-lambda/src/index.test.ts +6 -6
- package/dist/init-templates/aws-lambda/src/lib/logging/index.ts +87 -87
- package/dist/init-templates/aws-lambda/src/lib/state/redis/index.ts +64 -64
- package/dist/init-templates/aws-lambda/src/lib/state/seeka/installations.ts +66 -66
- package/dist/init-templates/aws-lambda/src/routes/seekaAppWebhook.ts +193 -193
- package/dist/init-templates/azure-function/.example.gitignore +47 -47
- package/dist/init-templates/azure-function/README.md +107 -107
- package/dist/init-templates/azure-function/jest.config.js +4 -4
- package/dist/init-templates/azure-function/package.json +45 -48
- package/dist/init-templates/azure-function/scripts/dev-queue-setup.js +29 -29
- package/dist/init-templates/azure-function/src/functions/healthCheck.ts +13 -13
- package/dist/init-templates/azure-function/src/functions/pollingExample.ts +39 -39
- package/dist/init-templates/azure-function/src/functions/queueExample.ts +66 -66
- package/dist/init-templates/azure-function/src/functions/seekaAppWebhook.ts +236 -236
- package/dist/init-templates/azure-function/src/index.test.ts +6 -6
- package/dist/init-templates/azure-function/src/lib/browser/index.ts +54 -54
- package/dist/init-templates/azure-function/src/lib/browser/models/index.ts +6 -6
- package/dist/init-templates/azure-function/src/lib/jobs/index.ts +95 -95
- package/dist/init-templates/azure-function/src/lib/logging/index.ts +92 -92
- package/dist/init-templates/azure-function/src/lib/state/redis/index.ts +64 -64
- package/dist/init-templates/azure-function/src/lib/state/seeka/installations.ts +66 -66
- package/dist/init-templates/browser/.editorconfig +14 -14
- package/dist/init-templates/browser/.eslintrc.cjs +1 -1
- package/dist/init-templates/browser/.yarnrc +1 -1
- package/dist/init-templates/browser/jest.config.js +11 -11
- package/dist/init-templates/browser/package.json +3 -3
- package/dist/init-templates/browser/scripts/esbuild/build-browser-plugin.mjs +110 -110
- package/dist/init-templates/browser/scripts/esbuild/plugins/importAsGlobals.mjs +38 -38
- package/dist/init-templates/browser/src/browser.ts +12 -12
- package/dist/init-templates/browser/src/plugin/index.test.ts +6 -6
- package/dist/init-templates/browser/src/plugin/index.ts +49 -49
- package/dist/init-templates/browser/tsconfig.json +34 -34
- package/dist/init-templates/netlify-function/.env.example +17 -17
- package/dist/init-templates/netlify-function/.example.gitignore +36 -36
- package/dist/init-templates/netlify-function/.nvmrc +1 -1
- package/dist/init-templates/netlify-function/.vscode/launch.json +44 -44
- package/dist/init-templates/netlify-function/README.md +61 -61
- package/dist/init-templates/netlify-function/jest.config.js +4 -4
- package/dist/init-templates/netlify-function/netlify.toml +6 -6
- package/dist/init-templates/netlify-function/package.json +11 -14
- package/dist/init-templates/netlify-function/src/api/example-job-background/index.ts +51 -51
- package/dist/init-templates/netlify-function/src/api/polling-example-job-scheduled/index.ts +45 -45
- package/dist/init-templates/netlify-function/src/api/seeka-app-webhook/index.ts +216 -216
- package/dist/init-templates/netlify-function/src/index.test.ts +6 -6
- package/dist/init-templates/netlify-function/src/lib/jobs/index.ts +67 -67
- package/dist/init-templates/netlify-function/src/lib/logging/index.ts +90 -90
- package/dist/init-templates/netlify-function/src/lib/state/redis/index.ts +64 -64
- package/dist/init-templates/netlify-function/src/lib/state/seeka/installations.ts +66 -66
- package/package.json +7 -7
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
bin
|
|
2
|
-
obj
|
|
3
|
-
csx
|
|
4
|
-
.vs
|
|
5
|
-
edge
|
|
6
|
-
Publish
|
|
7
|
-
deploy.zip
|
|
8
|
-
|
|
9
|
-
*.user
|
|
10
|
-
*.suo
|
|
11
|
-
*.cscfg
|
|
12
|
-
*.Cache
|
|
13
|
-
project.lock.json
|
|
14
|
-
|
|
15
|
-
/packages
|
|
16
|
-
/TestResults
|
|
17
|
-
|
|
18
|
-
/tools/NuGet.exe
|
|
19
|
-
/App_Data
|
|
20
|
-
/secrets
|
|
21
|
-
/data
|
|
22
|
-
.secrets
|
|
23
|
-
appsettings.json
|
|
24
|
-
local.settings.json
|
|
25
|
-
|
|
26
|
-
node_modules
|
|
27
|
-
dist
|
|
28
|
-
|
|
29
|
-
# Local python packages
|
|
30
|
-
.python_packages/
|
|
31
|
-
|
|
32
|
-
# Python Environments
|
|
33
|
-
.env
|
|
34
|
-
.venv
|
|
35
|
-
env/
|
|
36
|
-
venv/
|
|
37
|
-
ENV/
|
|
38
|
-
env.bak/
|
|
39
|
-
venv.bak/
|
|
40
|
-
|
|
41
|
-
# Byte-compiled / optimized / DLL files
|
|
42
|
-
__pycache__/
|
|
43
|
-
*.py[cod]
|
|
44
|
-
*$py.class
|
|
45
|
-
|
|
46
|
-
# Azurite artifacts
|
|
47
|
-
__blobstorage__
|
|
48
|
-
__queuestorage__
|
|
1
|
+
bin
|
|
2
|
+
obj
|
|
3
|
+
csx
|
|
4
|
+
.vs
|
|
5
|
+
edge
|
|
6
|
+
Publish
|
|
7
|
+
deploy.zip
|
|
8
|
+
|
|
9
|
+
*.user
|
|
10
|
+
*.suo
|
|
11
|
+
*.cscfg
|
|
12
|
+
*.Cache
|
|
13
|
+
project.lock.json
|
|
14
|
+
|
|
15
|
+
/packages
|
|
16
|
+
/TestResults
|
|
17
|
+
|
|
18
|
+
/tools/NuGet.exe
|
|
19
|
+
/App_Data
|
|
20
|
+
/secrets
|
|
21
|
+
/data
|
|
22
|
+
.secrets
|
|
23
|
+
appsettings.json
|
|
24
|
+
local.settings.json
|
|
25
|
+
|
|
26
|
+
node_modules
|
|
27
|
+
dist
|
|
28
|
+
|
|
29
|
+
# Local python packages
|
|
30
|
+
.python_packages/
|
|
31
|
+
|
|
32
|
+
# Python Environments
|
|
33
|
+
.env
|
|
34
|
+
.venv
|
|
35
|
+
env/
|
|
36
|
+
venv/
|
|
37
|
+
ENV/
|
|
38
|
+
env.bak/
|
|
39
|
+
venv.bak/
|
|
40
|
+
|
|
41
|
+
# Byte-compiled / optimized / DLL files
|
|
42
|
+
__pycache__/
|
|
43
|
+
*.py[cod]
|
|
44
|
+
*$py.class
|
|
45
|
+
|
|
46
|
+
# Azurite artifacts
|
|
47
|
+
__blobstorage__
|
|
48
|
+
__queuestorage__
|
|
49
49
|
__azurite_db*__.json
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
v20
|
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
# Seeka app - AWS lambda
|
|
2
|
-
|
|
3
|
-
## Development
|
|
4
|
-
- `yarn install`
|
|
5
|
-
- `yarn watch:debug` or use VsCode debugging for "Debug Seeka App" configuration
|
|
6
|
-
|
|
7
|
-
### Debugging
|
|
8
|
-
Supports VSCode debugging via the debugger and utilisation of breakpoints.
|
|
9
|
-
Use "Debug Seeka App" configuration to compile, watch and start app.
|
|
10
|
-
This is only tested on Linux but may work on Windows.
|
|
11
|
-
If using Windows, WSL coupled with an Ubuntu distro will provide support for attaching the VS code debugger.
|
|
12
|
-
|
|
13
|
-
### Live urls
|
|
14
|
-
You can expose your app locally to the internet via Ngrok to test your app before deploying.
|
|
15
|
-
|
|
16
|
-
#### Setup
|
|
17
|
-
1. Sign up for a Ngrok account
|
|
18
|
-
2. Get your auth token
|
|
19
|
-
3. `yarn ngrok config add-authtoken [auth token here]` replacing `[auth token]` with the auth token retrieved from your Ngrok dashboard
|
|
20
|
-
|
|
21
|
-
#### Running
|
|
22
|
-
1. `yarn start` OR start debugging in VSCode
|
|
23
|
-
2. In separate terminal window run `yarn tunnel` and observe the log entry that starts with `Live url exposed`.
|
|
24
|
-
3. Input the URL into your Seeka app configuration as the "Webook URL" via the Seeka UI.
|
|
25
|
-
|
|
26
|
-
## Logging
|
|
27
|
-
Centralised logging handled by [Winston](https://www.npmjs.com/package/winston). Winston is installed in this template and is also used in the Seeka SDK NPM packages.
|
|
28
|
-
|
|
29
|
-
[Seq](https://datalust.co/seq) Winston transport is installed in this template (optional).
|
|
30
|
-
|
|
31
|
-
To configure Seq options, see `_SEQ_` environment variables.
|
|
32
|
-
|
|
33
|
-
To install Seq on your development machine
|
|
34
|
-
1. Run `docker run --name seq -d --restart=always -e ACCEPT_EULA=Y -p 5341:80 datalust/seq:2024.2`
|
|
35
|
-
2. Update your `LOGGING_SEQ_SERVERURL` environment variable to `http://localhost:5341` or `http://[YOUR MACHINE NAME].local:5341` if using WSL.
|
|
36
|
-
|
|
37
|
-
If creating an API key for Seq, only permission that is required is `Ingest`.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
## State management
|
|
41
|
-
Installations of your app and other state required for your app to function is stored in Redis. Another state provider can be swapped out for Redis, see `src/lib/state/seeka/installations.ts` for the file that manages the state of the installations.
|
|
42
|
-
|
|
43
|
-
### Upstash (optional)
|
|
44
|
-
If you dont want to use Upstash for Redis then you can swap out the connection strings with your Redis instance.
|
|
45
|
-
|
|
46
|
-
> If using Upstash then create a database before following the below guide to deploying your AWS lambda function.
|
|
47
|
-
|
|
48
|
-
> When choosing a region, consider the AWS region that the lambda function is running from to reduce latency between the function and the Redis database.
|
|
49
|
-
|
|
50
|
-
## Deployment
|
|
51
|
-
1. [Install the aws lambda CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html#getting-started-install-instructions)
|
|
52
|
-
1. Create a function via the AWS console with following settings
|
|
53
|
-
- Mode: Author from scratch
|
|
54
|
-
- function name: `seeka-app-example-name`
|
|
55
|
-
- runtime: `Node.js 18.x`
|
|
56
|
-
- architecture: `arm64`
|
|
57
|
-
- Advanced settings:
|
|
58
|
-
- Enable code signing: unchecked
|
|
59
|
-
- Enable function URL: checked
|
|
60
|
-
- Auth type: `NONE` - Calls to your function from Seeka will be verified by SHA256 signatures
|
|
61
|
-
- Invoke mode: Buffered
|
|
62
|
-
- Configure cross-origin resource sharing: unchecked
|
|
63
|
-
- Enable VPC: unchecked
|
|
64
|
-
- All other settings leave as defaults
|
|
65
|
-
3. Add environment variables to the function in AWS by clicking 'Configuration' and then 'Environment varables'. Use the `.env` file in this project as a reference to what variables are required by to be set in the AWS Lambda.
|
|
66
|
-
4. [Authenticate the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-authentication-short-term.html)
|
|
67
|
-
2. `yarn deploy`
|
|
68
|
-
|
|
69
|
-
> At this point you may wish to [configure concurrency](https://docs.aws.amazon.com/lambda/latest/dg/scaling-behavior.html) of the AWS lambda function depending on the amount of concurrent requests you forecast your function handling.
|
|
70
|
-
|
|
71
|
-
6. Update your `Webhook URL` in you Seeka app configuration to point to the AWS Lambda function URL. This URL can be found in your viewing your Lambda via the AWS console and copying the "Function URL". It should look something like `https://prragnghaaupodlqte6hkvo446acc.lambda-url.ap-southeast-2.on.aws/`. Ensure to append `api/webhook/seeka/app` onto this URL so the complete example to update your Seeka app configuration with will look like `https://prragnghaaupodlqte6hkvo446acc.lambda-url.ap-southeast-2.on.aws/api/webhook/seeka/app`
|
|
72
|
-
|
|
73
|
-
### Continuous delivery
|
|
74
|
-
This template includes a GitLab CD pipeline that can be used to trigger deployments of your app when changes are pushed to your Git repository.
|
|
75
|
-
|
|
76
|
-
## References
|
|
1
|
+
# Seeka app - AWS lambda
|
|
2
|
+
|
|
3
|
+
## Development
|
|
4
|
+
- `yarn install`
|
|
5
|
+
- `yarn watch:debug` or use VsCode debugging for "Debug Seeka App" configuration
|
|
6
|
+
|
|
7
|
+
### Debugging
|
|
8
|
+
Supports VSCode debugging via the debugger and utilisation of breakpoints.
|
|
9
|
+
Use "Debug Seeka App" configuration to compile, watch and start app.
|
|
10
|
+
This is only tested on Linux but may work on Windows.
|
|
11
|
+
If using Windows, WSL coupled with an Ubuntu distro will provide support for attaching the VS code debugger.
|
|
12
|
+
|
|
13
|
+
### Live urls
|
|
14
|
+
You can expose your app locally to the internet via Ngrok to test your app before deploying.
|
|
15
|
+
|
|
16
|
+
#### Setup
|
|
17
|
+
1. Sign up for a Ngrok account
|
|
18
|
+
2. Get your auth token
|
|
19
|
+
3. `yarn ngrok config add-authtoken [auth token here]` replacing `[auth token]` with the auth token retrieved from your Ngrok dashboard
|
|
20
|
+
|
|
21
|
+
#### Running
|
|
22
|
+
1. `yarn start` OR start debugging in VSCode
|
|
23
|
+
2. In separate terminal window run `yarn tunnel` and observe the log entry that starts with `Live url exposed`.
|
|
24
|
+
3. Input the URL into your Seeka app configuration as the "Webook URL" via the Seeka UI.
|
|
25
|
+
|
|
26
|
+
## Logging
|
|
27
|
+
Centralised logging handled by [Winston](https://www.npmjs.com/package/winston). Winston is installed in this template and is also used in the Seeka SDK NPM packages.
|
|
28
|
+
|
|
29
|
+
[Seq](https://datalust.co/seq) Winston transport is installed in this template (optional).
|
|
30
|
+
|
|
31
|
+
To configure Seq options, see `_SEQ_` environment variables.
|
|
32
|
+
|
|
33
|
+
To install Seq on your development machine
|
|
34
|
+
1. Run `docker run --name seq -d --restart=always -e ACCEPT_EULA=Y -p 5341:80 datalust/seq:2024.2`
|
|
35
|
+
2. Update your `LOGGING_SEQ_SERVERURL` environment variable to `http://localhost:5341` or `http://[YOUR MACHINE NAME].local:5341` if using WSL.
|
|
36
|
+
|
|
37
|
+
If creating an API key for Seq, only permission that is required is `Ingest`.
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## State management
|
|
41
|
+
Installations of your app and other state required for your app to function is stored in Redis. Another state provider can be swapped out for Redis, see `src/lib/state/seeka/installations.ts` for the file that manages the state of the installations.
|
|
42
|
+
|
|
43
|
+
### Upstash (optional)
|
|
44
|
+
If you dont want to use Upstash for Redis then you can swap out the connection strings with your Redis instance.
|
|
45
|
+
|
|
46
|
+
> If using Upstash then create a database before following the below guide to deploying your AWS lambda function.
|
|
47
|
+
|
|
48
|
+
> When choosing a region, consider the AWS region that the lambda function is running from to reduce latency between the function and the Redis database.
|
|
49
|
+
|
|
50
|
+
## Deployment
|
|
51
|
+
1. [Install the aws lambda CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html#getting-started-install-instructions)
|
|
52
|
+
1. Create a function via the AWS console with following settings
|
|
53
|
+
- Mode: Author from scratch
|
|
54
|
+
- function name: `seeka-app-example-name`
|
|
55
|
+
- runtime: `Node.js 18.x`
|
|
56
|
+
- architecture: `arm64`
|
|
57
|
+
- Advanced settings:
|
|
58
|
+
- Enable code signing: unchecked
|
|
59
|
+
- Enable function URL: checked
|
|
60
|
+
- Auth type: `NONE` - Calls to your function from Seeka will be verified by SHA256 signatures
|
|
61
|
+
- Invoke mode: Buffered
|
|
62
|
+
- Configure cross-origin resource sharing: unchecked
|
|
63
|
+
- Enable VPC: unchecked
|
|
64
|
+
- All other settings leave as defaults
|
|
65
|
+
3. Add environment variables to the function in AWS by clicking 'Configuration' and then 'Environment varables'. Use the `.env` file in this project as a reference to what variables are required by to be set in the AWS Lambda.
|
|
66
|
+
4. [Authenticate the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-authentication-short-term.html)
|
|
67
|
+
2. `yarn deploy`
|
|
68
|
+
|
|
69
|
+
> At this point you may wish to [configure concurrency](https://docs.aws.amazon.com/lambda/latest/dg/scaling-behavior.html) of the AWS lambda function depending on the amount of concurrent requests you forecast your function handling.
|
|
70
|
+
|
|
71
|
+
6. Update your `Webhook URL` in you Seeka app configuration to point to the AWS Lambda function URL. This URL can be found in your viewing your Lambda via the AWS console and copying the "Function URL". It should look something like `https://prragnghaaupodlqte6hkvo446acc.lambda-url.ap-southeast-2.on.aws/`. Ensure to append `api/webhook/seeka/app` onto this URL so the complete example to update your Seeka app configuration with will look like `https://prragnghaaupodlqte6hkvo446acc.lambda-url.ap-southeast-2.on.aws/api/webhook/seeka/app`
|
|
72
|
+
|
|
73
|
+
### Continuous delivery
|
|
74
|
+
This template includes a GitLab CD pipeline that can be used to trigger deployments of your app when changes are pushed to your Git repository.
|
|
75
|
+
|
|
76
|
+
## References
|
|
77
77
|
- https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lambda/index.html#available-commands
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
|
2
|
-
module.exports = {
|
|
3
|
-
preset: 'ts-jest',
|
|
4
|
-
testEnvironment: 'node',
|
|
1
|
+
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
|
2
|
+
module.exports = {
|
|
3
|
+
preset: 'ts-jest',
|
|
4
|
+
testEnvironment: 'node',
|
|
5
5
|
};
|
|
@@ -1,55 +1,52 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "seeka-app-example-name",
|
|
3
|
-
"version": "0.0.1",
|
|
4
|
-
"description": "Seeka example app for hosting on AWS lambda functions",
|
|
5
|
-
"author": "Seeka <platform@seeka.co>",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"main": "./index.js",
|
|
8
|
-
"private": true,
|
|
9
|
-
"engines": {
|
|
10
|
-
"node": ">=
|
|
11
|
-
},
|
|
12
|
-
"scripts": {
|
|
13
|
-
"lint": "eslint",
|
|
14
|
-
"build": "esbuild src/index.ts --bundle --minify --sourcemap --platform=node --target=node18 --outfile=dist/index.js",
|
|
15
|
-
"watch": "tsc -w",
|
|
16
|
-
"test": "yarn jest",
|
|
17
|
-
"clean": "<packageManagerRunPrefix> rimraf dist && <packageManagerRunPrefix> rimraf deploy.zip",
|
|
18
|
-
"start": "node --require dotenv/config dist/index.js",
|
|
19
|
-
"dev": "<packageManagerRunPrefix> clean && <packageManagerRunPrefix> build && node --require dotenv/config dist/index.js",
|
|
20
|
-
"tunnel": "node scripts/ngrok.js seeka-app-example-name-localdev",
|
|
21
|
-
"build:aws": "<packageManagerRunPrefix> clean && <packageManagerRunPrefix> build && cd dist && zip -r ../deploy.zip . && cd ..",
|
|
22
|
-
"deploy": "<packageManagerRunPrefix> build:aws && aws lambda update-function-code --function-name seeka-app-example-name --zip-file fileb://deploy.zip && rm deploy.zip",
|
|
23
|
-
"watch:debug": "nodemon --inspect=5858 -e ts --exec node -r ts-node/register --require dotenv/config ./src/index.ts"
|
|
24
|
-
},
|
|
25
|
-
"dependencies": {
|
|
26
|
-
"@datalust/winston-seq": "^2.0.0",
|
|
27
|
-
"@seeka-labs/sdk-apps-server": "^1.1.
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"@
|
|
38
|
-
"@types/
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
"ts-node": "^10.9.2",
|
|
53
|
-
"typescript": "^5.4.2"
|
|
54
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "seeka-app-example-name",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Seeka example app for hosting on AWS lambda functions",
|
|
5
|
+
"author": "Seeka <platform@seeka.co>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "./index.js",
|
|
8
|
+
"private": true,
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=20"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"lint": "eslint",
|
|
14
|
+
"build": "esbuild src/index.ts --bundle --minify --sourcemap --platform=node --target=node18 --outfile=dist/index.js",
|
|
15
|
+
"watch": "tsc -w",
|
|
16
|
+
"test": "yarn jest",
|
|
17
|
+
"clean": "<packageManagerRunPrefix> rimraf dist && <packageManagerRunPrefix> rimraf deploy.zip",
|
|
18
|
+
"start": "node --require dotenv/config dist/index.js",
|
|
19
|
+
"dev": "<packageManagerRunPrefix> clean && <packageManagerRunPrefix> build && node --require dotenv/config dist/index.js",
|
|
20
|
+
"tunnel": "node scripts/ngrok.js seeka-app-example-name-localdev",
|
|
21
|
+
"build:aws": "<packageManagerRunPrefix> clean && <packageManagerRunPrefix> build && cd dist && zip -r ../deploy.zip . && cd ..",
|
|
22
|
+
"deploy": "<packageManagerRunPrefix> build:aws && aws lambda update-function-code --function-name seeka-app-example-name --zip-file fileb://deploy.zip && rm deploy.zip",
|
|
23
|
+
"watch:debug": "nodemon --inspect=5858 -e ts --exec node -r ts-node/register --require dotenv/config ./src/index.ts"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@datalust/winston-seq": "^2.0.0",
|
|
27
|
+
"@seeka-labs/sdk-apps-server": "^1.1.24",
|
|
28
|
+
"express": "^4.21.1",
|
|
29
|
+
"lodash-es": "^4.17.21",
|
|
30
|
+
"redis": "^4.7.0",
|
|
31
|
+
"serverless-http": "^3.2.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@jest/globals": "^29.7.0",
|
|
35
|
+
"@types/aws-lambda": "^8.10.146",
|
|
36
|
+
"@types/express": "^5.0.0",
|
|
37
|
+
"@types/lodash-es": "^4.17.12",
|
|
38
|
+
"@types/node": "^20",
|
|
39
|
+
"@typescript-eslint/eslint-plugin": "^8.17.0",
|
|
40
|
+
"@typescript-eslint/parser": "^8.17.0",
|
|
41
|
+
"dotenv": "^16.4.7",
|
|
42
|
+
"esbuild": "^0.24.0",
|
|
43
|
+
"eslint": "^9",
|
|
44
|
+
"jest": "^29.7.0",
|
|
45
|
+
"ts-jest": "^29.2.5",
|
|
46
|
+
"ngrok": "^5.0.0-beta.2",
|
|
47
|
+
"nodemon": "^3.1.7",
|
|
48
|
+
"rimraf": "^5.0.0",
|
|
49
|
+
"ts-node": "^10.9.2",
|
|
50
|
+
"typescript": "^5.7.2"
|
|
51
|
+
}
|
|
55
52
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { describe, expect, test } from '@jest/globals';
|
|
2
|
-
|
|
3
|
-
describe('test example module', () => {
|
|
4
|
-
test('should be false', () => {
|
|
5
|
-
expect(false).toBeFalsy();
|
|
6
|
-
});
|
|
1
|
+
import { describe, expect, test } from '@jest/globals';
|
|
2
|
+
|
|
3
|
+
describe('test example module', () => {
|
|
4
|
+
test('should be false', () => {
|
|
5
|
+
expect(false).toBeFalsy();
|
|
6
|
+
});
|
|
7
7
|
});
|
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
import { Context } from 'aws-lambda';
|
|
2
|
-
import * as winston from 'winston';
|
|
3
|
-
|
|
4
|
-
import { SeqTransport } from '@datalust/winston-seq';
|
|
5
|
-
|
|
6
|
-
import * as packageJson from '../../../package.json';
|
|
7
|
-
|
|
8
|
-
import type {
|
|
9
|
-
SeekaWebhookPayload, SeekaWebhookPayloadOfSeekaAppWebhookContext
|
|
10
|
-
} from '@seeka-labs/sdk-apps-server';
|
|
11
|
-
|
|
12
|
-
const loggerTransports: winston.transport[] = [
|
|
13
|
-
new winston.transports.Console({
|
|
14
|
-
level: process.env.LOGGING_LEVEL,
|
|
15
|
-
format: winston.format.combine(
|
|
16
|
-
winston.format.errors({ stack: true }),
|
|
17
|
-
winston.format.cli(),
|
|
18
|
-
winston.format.splat(),
|
|
19
|
-
),
|
|
20
|
-
handleExceptions: true,
|
|
21
|
-
handleRejections: true,
|
|
22
|
-
}),
|
|
23
|
-
]
|
|
24
|
-
if (process.env.LOGGING_SEQ_SERVERURL) {
|
|
25
|
-
loggerTransports.push(
|
|
26
|
-
new SeqTransport({
|
|
27
|
-
level: process.env.LOGGING_LEVEL,
|
|
28
|
-
serverUrl: process.env.LOGGING_SEQ_SERVERURL,
|
|
29
|
-
apiKey: process.env.LOGGING_SEQ_APIKEY,
|
|
30
|
-
onError: ((e: any) => { console.error('Failed to configure Seq logging transport', e) }),
|
|
31
|
-
format: winston.format.combine(
|
|
32
|
-
winston.format.errors({ stack: true }),
|
|
33
|
-
winston.format.json(),
|
|
34
|
-
),
|
|
35
|
-
handleExceptions: true,
|
|
36
|
-
handleRejections: true,
|
|
37
|
-
})
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
let logger: winston.Logger | null = null;
|
|
42
|
-
|
|
43
|
-
const createLogger = () => winston.createLogger({
|
|
44
|
-
level: process.env.LOGGING_LEVEL,
|
|
45
|
-
defaultMeta: {
|
|
46
|
-
seekaAppId: process.env.SEEKA_APP_ID,
|
|
47
|
-
Hosting_Provider: 'aws',
|
|
48
|
-
Release_Version: `v${packageJson.version}`,
|
|
49
|
-
Hosting_Region: process.env.AWS_REGION,
|
|
50
|
-
Aws_Xray_TraceId: process.env._X_AMZN_TRACE_ID,
|
|
51
|
-
Aws_Lambda_FunctionName: process.env.AWS_LAMBDA_FUNCTION_NAME,
|
|
52
|
-
Service: `app/${packageJson.name}`,
|
|
53
|
-
},
|
|
54
|
-
transports: loggerTransports,
|
|
55
|
-
exitOnError: false,
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
export const getLogger = () => {
|
|
59
|
-
if (!logger || logger.closed) {
|
|
60
|
-
// If the AWS lambda host is reused then the logger will be closed and we need to recreate it
|
|
61
|
-
logger = createLogger();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return logger;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export const childLogger = (meta: object) => getLogger().child(meta);
|
|
68
|
-
|
|
69
|
-
export const webhookLogger = (payload: SeekaWebhookPayload, functionContext: Context) => {
|
|
70
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
71
|
-
const meta: any = {
|
|
72
|
-
seekaWebhookType: payload.type,
|
|
73
|
-
seekaWebhookIsTest: payload.isTest,
|
|
74
|
-
RequestId: payload.requestId,
|
|
75
|
-
AwsLambda_RequestId: functionContext.awsRequestId,
|
|
76
|
-
CausationId: payload.causationId,
|
|
77
|
-
CorrelationId: payload.causationId,
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const context = (payload as SeekaWebhookPayloadOfSeekaAppWebhookContext).context;
|
|
81
|
-
if (context) {
|
|
82
|
-
meta.seekaAppInstallId = context.applicationInstallId;
|
|
83
|
-
meta.seekaAppInstallOrganisationBrandId = context.organisationBrandId;
|
|
84
|
-
meta.seekaAppInstallOrganisationId = context.organisationId;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return childLogger(meta)
|
|
1
|
+
import { Context } from 'aws-lambda';
|
|
2
|
+
import * as winston from 'winston';
|
|
3
|
+
|
|
4
|
+
import { SeqTransport } from '@datalust/winston-seq';
|
|
5
|
+
|
|
6
|
+
import * as packageJson from '../../../package.json';
|
|
7
|
+
|
|
8
|
+
import type {
|
|
9
|
+
SeekaWebhookPayload, SeekaWebhookPayloadOfSeekaAppWebhookContext
|
|
10
|
+
} from '@seeka-labs/sdk-apps-server';
|
|
11
|
+
|
|
12
|
+
const loggerTransports: winston.transport[] = [
|
|
13
|
+
new winston.transports.Console({
|
|
14
|
+
level: process.env.LOGGING_LEVEL,
|
|
15
|
+
format: winston.format.combine(
|
|
16
|
+
winston.format.errors({ stack: true }),
|
|
17
|
+
winston.format.cli(),
|
|
18
|
+
winston.format.splat(),
|
|
19
|
+
),
|
|
20
|
+
handleExceptions: true,
|
|
21
|
+
handleRejections: true,
|
|
22
|
+
}),
|
|
23
|
+
]
|
|
24
|
+
if (process.env.LOGGING_SEQ_SERVERURL) {
|
|
25
|
+
loggerTransports.push(
|
|
26
|
+
new SeqTransport({
|
|
27
|
+
level: process.env.LOGGING_LEVEL,
|
|
28
|
+
serverUrl: process.env.LOGGING_SEQ_SERVERURL,
|
|
29
|
+
apiKey: process.env.LOGGING_SEQ_APIKEY,
|
|
30
|
+
onError: ((e: any) => { console.error('Failed to configure Seq logging transport', e) }),
|
|
31
|
+
format: winston.format.combine(
|
|
32
|
+
winston.format.errors({ stack: true }),
|
|
33
|
+
winston.format.json(),
|
|
34
|
+
),
|
|
35
|
+
handleExceptions: true,
|
|
36
|
+
handleRejections: true,
|
|
37
|
+
})
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let logger: winston.Logger | null = null;
|
|
42
|
+
|
|
43
|
+
const createLogger = () => winston.createLogger({
|
|
44
|
+
level: process.env.LOGGING_LEVEL,
|
|
45
|
+
defaultMeta: {
|
|
46
|
+
seekaAppId: process.env.SEEKA_APP_ID,
|
|
47
|
+
Hosting_Provider: 'aws',
|
|
48
|
+
Release_Version: `v${packageJson.version}`,
|
|
49
|
+
Hosting_Region: process.env.AWS_REGION,
|
|
50
|
+
Aws_Xray_TraceId: process.env._X_AMZN_TRACE_ID,
|
|
51
|
+
Aws_Lambda_FunctionName: process.env.AWS_LAMBDA_FUNCTION_NAME,
|
|
52
|
+
Service: `app/${packageJson.name}`,
|
|
53
|
+
},
|
|
54
|
+
transports: loggerTransports,
|
|
55
|
+
exitOnError: false,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export const getLogger = () => {
|
|
59
|
+
if (!logger || logger.closed) {
|
|
60
|
+
// If the AWS lambda host is reused then the logger will be closed and we need to recreate it
|
|
61
|
+
logger = createLogger();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return logger;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export const childLogger = (meta: object) => getLogger().child(meta);
|
|
68
|
+
|
|
69
|
+
export const webhookLogger = (payload: SeekaWebhookPayload, functionContext: Context) => {
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
71
|
+
const meta: any = {
|
|
72
|
+
seekaWebhookType: payload.type,
|
|
73
|
+
seekaWebhookIsTest: payload.isTest,
|
|
74
|
+
RequestId: payload.requestId,
|
|
75
|
+
AwsLambda_RequestId: functionContext.awsRequestId,
|
|
76
|
+
CausationId: payload.causationId,
|
|
77
|
+
CorrelationId: payload.causationId,
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const context = (payload as SeekaWebhookPayloadOfSeekaAppWebhookContext).context;
|
|
81
|
+
if (context) {
|
|
82
|
+
meta.seekaAppInstallId = context.applicationInstallId;
|
|
83
|
+
meta.seekaAppInstallOrganisationBrandId = context.organisationBrandId;
|
|
84
|
+
meta.seekaAppInstallOrganisationId = context.organisationId;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return childLogger(meta)
|
|
88
88
|
}
|