@mbc-cqrs-serverless/cli 0.1.4-beta.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/package.json +39 -0
- package/templates/.env.local +54 -0
- package/templates/.envrc +3 -0
- package/templates/.eslintrc.js +50 -0
- package/templates/.prettierrc +8 -0
- package/templates/README.md +168 -0
- package/templates/gitignore +46 -0
- package/templates/infra-local/appsync-simulator/.dockerignore +1 -0
- package/templates/infra-local/appsync-simulator/Dockerfile +8 -0
- package/templates/infra-local/appsync-simulator/package-lock.json +7179 -0
- package/templates/infra-local/appsync-simulator/package.json +30 -0
- package/templates/infra-local/appsync-simulator/src/main.ts +61 -0
- package/templates/infra-local/appsync-simulator/src/resolversConfig.ts +19 -0
- package/templates/infra-local/appsync-simulator/src/schema.graphql +28 -0
- package/templates/infra-local/appsync-simulator/src/schema.ts +7 -0
- package/templates/infra-local/appsync-simulator/src/vtl/readVTL.ts +6 -0
- package/templates/infra-local/appsync-simulator/src/vtl/sendMessage.req.vtl +4 -0
- package/templates/infra-local/appsync-simulator/src/vtl/sendMessage.res.vtl +1 -0
- package/templates/infra-local/cognito-local/.dockerignore +1 -0
- package/templates/infra-local/cognito-local/Dockerfile +9 -0
- package/templates/infra-local/cognito-local/db/clients.json +17 -0
- package/templates/infra-local/cognito-local/db/local_2G7noHgW.json +282 -0
- package/templates/infra-local/cognito-local/package-lock.json +2321 -0
- package/templates/infra-local/cognito-local/package.json +17 -0
- package/templates/infra-local/cognito-local/patches/cognito-local+3.23.2.patch +57 -0
- package/templates/infra-local/docker-compose.yml +91 -0
- package/templates/infra-local/elasticmq.conf +23 -0
- package/templates/infra-local/resources.sh +11 -0
- package/templates/infra-local/scripts/trigger_ddb_stream.sh +69 -0
- package/templates/infra-local/serverless.yml +306 -0
- package/templates/jest.config.js +4 -0
- package/templates/nest-cli.json +16 -0
- package/templates/package.json +118 -0
- package/templates/prisma/ddb.ts +232 -0
- package/templates/prisma/dynamodbs/cqrs.json +1 -0
- package/templates/prisma/dynamodbs/cqrs_desc.json +18 -0
- package/templates/prisma/dynamodbs/sequences.json +14 -0
- package/templates/prisma/dynamodbs/tasks.json +18 -0
- package/templates/prisma/schema.prisma +45 -0
- package/templates/src/event-factory.ts +7 -0
- package/templates/src/helpers/get-order.ts +19 -0
- package/templates/src/helpers/index.ts +1 -0
- package/templates/src/main.module.ts +26 -0
- package/templates/src/main.ts +7 -0
- package/templates/src/master/dto/master-attributes.dto.ts +6 -0
- package/templates/src/master/dto/master-command.dto.ts +12 -0
- package/templates/src/master/entity/master-command.entity.ts +13 -0
- package/templates/src/master/entity/master-data-list.entity.ts +13 -0
- package/templates/src/master/entity/master-data.entity.ts +13 -0
- package/templates/src/master/handler/master-rds.handler.ts +59 -0
- package/templates/src/master/master.controller.ts +83 -0
- package/templates/src/master/master.module.ts +19 -0
- package/templates/src/master/master.service.ts +58 -0
- package/templates/src/prisma/index.ts +5 -0
- package/templates/src/prisma/interfaces/index.ts +1 -0
- package/templates/src/prisma/interfaces/prisma-module-options.interface.ts +50 -0
- package/templates/src/prisma/prisma.constants.ts +2 -0
- package/templates/src/prisma/prisma.logging.middleware.ts +20 -0
- package/templates/src/prisma/prisma.module.ts +75 -0
- package/templates/src/prisma/prisma.service.ts +45 -0
- package/templates/src/repl.ts +21 -0
- package/templates/test/api.http +42 -0
- package/templates/test/jest-e2e.json +9 -0
- package/templates/tsconfig.build.json +4 -0
- package/templates/tsconfig.json +25 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cognito-local",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"postinstall": "patch-package",
|
|
8
|
+
"dev": "HOST=0.0.0.0 npx cognito-local",
|
|
9
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
10
|
+
},
|
|
11
|
+
"author": "",
|
|
12
|
+
"license": "ISC",
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"cognito-local": "^3.23.2",
|
|
15
|
+
"patch-package": "^8.0.0"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
diff --git a/node_modules/cognito-local/lib/errors.d.ts b/node_modules/cognito-local/lib/errors.d.ts
|
|
2
|
+
index 73c8ba1..4de35b5 100644
|
|
3
|
+
--- a/node_modules/cognito-local/lib/errors.d.ts
|
|
4
|
+
+++ b/node_modules/cognito-local/lib/errors.d.ts
|
|
5
|
+
@@ -46,3 +46,6 @@ export declare class InvalidLambdaResponseError extends CognitoError {
|
|
6
|
+
export declare class InvalidParameterError extends CognitoError {
|
|
7
|
+
constructor(message?: string);
|
|
8
|
+
}
|
|
9
|
+
+export declare class UserDisableException extends CognitoError {
|
|
10
|
+
+ constructor();
|
|
11
|
+
+}
|
|
12
|
+
diff --git a/node_modules/cognito-local/lib/errors.js b/node_modules/cognito-local/lib/errors.js
|
|
13
|
+
index ff327dc..a4da36a 100644
|
|
14
|
+
--- a/node_modules/cognito-local/lib/errors.js
|
|
15
|
+
+++ b/node_modules/cognito-local/lib/errors.js
|
|
16
|
+
@@ -18,6 +18,7 @@ __export(exports, {
|
|
17
|
+
ResourceNotFoundError: () => ResourceNotFoundError,
|
|
18
|
+
UnexpectedLambdaExceptionError: () => UnexpectedLambdaExceptionError,
|
|
19
|
+
UnsupportedError: () => UnsupportedError,
|
|
20
|
+
+ UserDisableException: () => UserDisableException,
|
|
21
|
+
UserLambdaValidationError: () => UserLambdaValidationError,
|
|
22
|
+
UserNotConfirmedException: () => UserNotConfirmedException,
|
|
23
|
+
UserNotFoundError: () => UserNotFoundError,
|
|
24
|
+
@@ -101,6 +102,11 @@ class InvalidParameterError extends CognitoError {
|
|
25
|
+
super("InvalidParameterException", message);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
+class UserDisableException extends CognitoError {
|
|
29
|
+
+ constructor() {
|
|
30
|
+
+ super("UserDisableException", "User is disable.");
|
|
31
|
+
+ }
|
|
32
|
+
+}
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
CodeMismatchError,
|
|
36
|
+
@@ -115,6 +121,7 @@ class InvalidParameterError extends CognitoError {
|
|
37
|
+
ResourceNotFoundError,
|
|
38
|
+
UnexpectedLambdaExceptionError,
|
|
39
|
+
UnsupportedError,
|
|
40
|
+
+ UserDisableException,
|
|
41
|
+
UserLambdaValidationError,
|
|
42
|
+
UserNotConfirmedException,
|
|
43
|
+
UserNotFoundError,
|
|
44
|
+
diff --git a/node_modules/cognito-local/lib/targets/initiateAuth.js b/node_modules/cognito-local/lib/targets/initiateAuth.js
|
|
45
|
+
index ee7c3d6..23632d7 100644
|
|
46
|
+
--- a/node_modules/cognito-local/lib/targets/initiateAuth.js
|
|
47
|
+
+++ b/node_modules/cognito-local/lib/targets/initiateAuth.js
|
|
48
|
+
@@ -125,6 +125,9 @@ const userPasswordAuthFlow = async (ctx, req, userPool, userPoolClient, services
|
|
49
|
+
if (user.UserStatus === "UNCONFIRMED") {
|
|
50
|
+
throw new import_errors.UserNotConfirmedException();
|
|
51
|
+
}
|
|
52
|
+
+ if (!user.Enabled) {
|
|
53
|
+
+ throw new import_errors.UserDisableException();
|
|
54
|
+
+ }
|
|
55
|
+
if (userPool.options.MfaConfiguration === "OPTIONAL" && (user.MFAOptions ?? []).length > 0 || userPool.options.MfaConfiguration === "ON") {
|
|
56
|
+
return verifyMfaChallenge(ctx, user, req, userPool, services);
|
|
57
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
version: '2'
|
|
2
|
+
services:
|
|
3
|
+
stepfunctions-local:
|
|
4
|
+
image: amazon/aws-stepfunctions-local
|
|
5
|
+
ports:
|
|
6
|
+
- 8083:8083
|
|
7
|
+
environment:
|
|
8
|
+
- AWS_ACCOUNT_ID=101010101010
|
|
9
|
+
- AWS_DEFAULT_REGION=ap-northeast-1
|
|
10
|
+
- LAMBDA_ENDPOINT=http://host.docker.internal:3002
|
|
11
|
+
- SQS_ENDPOINT=http://host.docker.internal:9324
|
|
12
|
+
- SNS_ENDPOINT=http://host.docker.internal:4002
|
|
13
|
+
- DYNAMODB_ENDPOINT=http://host.docker.internal:8000
|
|
14
|
+
- STEP_FUNCTIONS_ENDPOINT=http://host.docker.internal:8083
|
|
15
|
+
- ECS_ENDPOINT=VALUE
|
|
16
|
+
extra_hosts:
|
|
17
|
+
- 'host.docker.internal:host-gateway'
|
|
18
|
+
|
|
19
|
+
rds:
|
|
20
|
+
image: mysql:8
|
|
21
|
+
environment:
|
|
22
|
+
MYSQL_ROOT_PASSWORD: RootCqrs
|
|
23
|
+
MYSQL_DATABASE: cqrs
|
|
24
|
+
volumes:
|
|
25
|
+
- ./docker-data/mysql:/var/lib/mysql
|
|
26
|
+
ports:
|
|
27
|
+
- 3306:3306
|
|
28
|
+
|
|
29
|
+
dynamodb-local:
|
|
30
|
+
image: amazon/dynamodb-local
|
|
31
|
+
ports:
|
|
32
|
+
- 8000:8000
|
|
33
|
+
volumes:
|
|
34
|
+
- ./docker-data/dynamodb-local:/home/dynamodblocal/data
|
|
35
|
+
working_dir: /home/dynamodblocal
|
|
36
|
+
command: '-jar DynamoDBLocal.jar -sharedDb -dbPath ./data'
|
|
37
|
+
|
|
38
|
+
dynamodb-admin:
|
|
39
|
+
image: aaronshaf/dynamodb-admin
|
|
40
|
+
environment:
|
|
41
|
+
- DYNAMO_ENDPOINT=dynamodb-local:8000
|
|
42
|
+
- AWS_REGION=ap-northeast-1
|
|
43
|
+
- AWS_ACCESS_KEY_ID=local
|
|
44
|
+
- AWS_SECRET_ACCESS_KEY=local
|
|
45
|
+
ports:
|
|
46
|
+
- 8001:8001
|
|
47
|
+
depends_on:
|
|
48
|
+
- dynamodb-local
|
|
49
|
+
|
|
50
|
+
queue:
|
|
51
|
+
image: softwaremill/elasticmq-native:latest
|
|
52
|
+
ports:
|
|
53
|
+
- 9324:9324 # sqs
|
|
54
|
+
- 9325:9325 # ui
|
|
55
|
+
volumes:
|
|
56
|
+
- ./elasticmq.conf:/opt/elasticmq.conf
|
|
57
|
+
- ./docker-data/elasticmq:/data
|
|
58
|
+
|
|
59
|
+
localstack:
|
|
60
|
+
image: localstack/localstack
|
|
61
|
+
ports:
|
|
62
|
+
- '4566:4566'
|
|
63
|
+
- '4510-4559:4510-4559'
|
|
64
|
+
environment:
|
|
65
|
+
- SERVICES=s3
|
|
66
|
+
- AWS_DEFAULT_REGION=ap-northeast-1
|
|
67
|
+
- SERVICE_ACCESS_KEY=local
|
|
68
|
+
- SERVICE_SECRET_KEY=local
|
|
69
|
+
- EXTRA_CORS_ALLOWED_ORIGINS=*
|
|
70
|
+
volumes:
|
|
71
|
+
- ./docker-data/localstack:/var/lib/localstack
|
|
72
|
+
- ./docker-data/run/docker.sock:/var/run/docker.sock
|
|
73
|
+
|
|
74
|
+
appsync:
|
|
75
|
+
build:
|
|
76
|
+
context: ./appsync-simulator
|
|
77
|
+
dockerfile: Dockerfile
|
|
78
|
+
ports:
|
|
79
|
+
- 4001:4001
|
|
80
|
+
environment:
|
|
81
|
+
- PORT=4001
|
|
82
|
+
- API_KEY=da2-fakeApiId123456
|
|
83
|
+
|
|
84
|
+
cognito-local:
|
|
85
|
+
build:
|
|
86
|
+
context: ./cognito-local
|
|
87
|
+
dockerfile: Dockerfile
|
|
88
|
+
ports:
|
|
89
|
+
- 9229:9229
|
|
90
|
+
volumes:
|
|
91
|
+
- ./docker-data/.cognito:/app/.cognito
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
include classpath("application.conf")
|
|
2
|
+
|
|
3
|
+
node-address {
|
|
4
|
+
host = "*"
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
queues {
|
|
8
|
+
task-action-queue {
|
|
9
|
+
defaultVisibilityTimeout = 60 seconds
|
|
10
|
+
delay = 5 seconds
|
|
11
|
+
receiveMessageWait = 0 seconds
|
|
12
|
+
}
|
|
13
|
+
notification-queue {
|
|
14
|
+
defaultVisibilityTimeout = 60 seconds
|
|
15
|
+
delay = 5 seconds
|
|
16
|
+
receiveMessageWait = 0 seconds
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
aws {
|
|
21
|
+
region = ap-northeast-1
|
|
22
|
+
accountId = 101010101010
|
|
23
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
if [ -f .env ]; then
|
|
4
|
+
export $(echo $(cat .env | sed 's/#.*//g'| xargs) | envsubst)
|
|
5
|
+
fi
|
|
6
|
+
|
|
7
|
+
echo "======= create S3 buckets ======="
|
|
8
|
+
aws --endpoint-url=http://localhost:4566 s3 mb s3://$S3_BUCKET_NAME
|
|
9
|
+
|
|
10
|
+
echo "======= list S3 buckets ======="
|
|
11
|
+
aws --endpoint-url=http://localhost:4566 s3 ls
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
export AWS_DEFAULT_REGION=ap-northeast-1
|
|
4
|
+
export AWS_ACCOUNT_ID=101010101010
|
|
5
|
+
export AWS_ACCESS_KEY_ID=local
|
|
6
|
+
export AWS_SECRET_ACCESS_KEY=local
|
|
7
|
+
|
|
8
|
+
endpoint='http://localhost:8000'
|
|
9
|
+
|
|
10
|
+
source .env
|
|
11
|
+
|
|
12
|
+
echo "Read table name"
|
|
13
|
+
declare -a tables
|
|
14
|
+
while IFS= read -r line; do
|
|
15
|
+
tables+=("$line")
|
|
16
|
+
done < <(jq -r '.[]' ./prisma/dynamodbs/cqrs.json)
|
|
17
|
+
|
|
18
|
+
# Check table health
|
|
19
|
+
start=$(date +%s)
|
|
20
|
+
for table in "${tables[@]}"; do
|
|
21
|
+
while true; do
|
|
22
|
+
|
|
23
|
+
elapsed=$(($(date +%s) - ${start}))
|
|
24
|
+
if [[ ${elapsed} -gt 10 ]]; then
|
|
25
|
+
echo "Timeout"
|
|
26
|
+
exit 1
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
echo "Check health table ${table}"
|
|
30
|
+
status=$(aws --endpoint=${endpoint} dynamodb describe-table --table-name local-${APP_NAME}-${table}-command --query 'Table.TableStatus')
|
|
31
|
+
echo "Table status: ${status}"
|
|
32
|
+
if [[ "${status}" == "\"ACTIVE\"" ]]; then
|
|
33
|
+
echo "Table ${table} is ACTIVE"
|
|
34
|
+
break
|
|
35
|
+
else
|
|
36
|
+
echo "Table ${table} is not ACTIVE"
|
|
37
|
+
sleep 1
|
|
38
|
+
fi
|
|
39
|
+
done
|
|
40
|
+
done
|
|
41
|
+
|
|
42
|
+
# Wait serverless start
|
|
43
|
+
start=$(date +%s)
|
|
44
|
+
while true; do
|
|
45
|
+
|
|
46
|
+
elapsed=$(($(date +%s) - ${start}))
|
|
47
|
+
if [[ ${elapsed} -gt 10 ]]; then
|
|
48
|
+
echo "Timeout"
|
|
49
|
+
exit 1
|
|
50
|
+
fi
|
|
51
|
+
|
|
52
|
+
echo "Check health serverless"
|
|
53
|
+
status=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:3000)
|
|
54
|
+
echo "Serverless status: ${status}"
|
|
55
|
+
if [[ "${status}" == "200" ]]; then
|
|
56
|
+
echo "Serverless is ACTIVE"
|
|
57
|
+
break
|
|
58
|
+
else
|
|
59
|
+
echo "Serverless is not ACTIVE"
|
|
60
|
+
sleep 1
|
|
61
|
+
fi
|
|
62
|
+
done
|
|
63
|
+
|
|
64
|
+
# Trigger command stream
|
|
65
|
+
timestamp=$(date +%s)
|
|
66
|
+
for table in "${tables[@]}"; do
|
|
67
|
+
echo "Send a command to trigger command stream ${table}"
|
|
68
|
+
aws --endpoint=${endpoint} dynamodb put-item --table-name local-${APP_NAME}-${table}-command --item "{\"pk\": {\"S\": \"test\" }, \"sk\": { \"S\": \"${timestamp}\" }}"
|
|
69
|
+
done
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
service: serverless-example
|
|
2
|
+
useDotenv: true
|
|
3
|
+
|
|
4
|
+
plugins:
|
|
5
|
+
- serverless-offline-sns
|
|
6
|
+
- serverless-offline-sqs
|
|
7
|
+
- serverless-offline-lambda
|
|
8
|
+
- serverless-step-functions
|
|
9
|
+
- serverless-step-functions-local
|
|
10
|
+
- serverless-dynamodb
|
|
11
|
+
- serverless-offline-dynamodb-streams
|
|
12
|
+
- serverless-offline-aws-eventbridge
|
|
13
|
+
- serverless-offline-ses-v2
|
|
14
|
+
- serverless-offline
|
|
15
|
+
|
|
16
|
+
custom:
|
|
17
|
+
serverless-offline:
|
|
18
|
+
corsAllowOrigin: '*'
|
|
19
|
+
corsAllowHeaders: '*'
|
|
20
|
+
host: 0.0.0.0
|
|
21
|
+
reloadHandler: true
|
|
22
|
+
ignoreJWTSignature: true
|
|
23
|
+
serverless-offline-ses-v2:
|
|
24
|
+
port: 8005
|
|
25
|
+
serverless-offline-sns:
|
|
26
|
+
port: 4002 # a free port for the sns server to run on
|
|
27
|
+
debug: true
|
|
28
|
+
subscriptions:
|
|
29
|
+
- topic:
|
|
30
|
+
topicName: CqrsSnsTopic
|
|
31
|
+
rawMessageDelivery: 'true'
|
|
32
|
+
filterPolicy: { 'action': ['task-execute'] }
|
|
33
|
+
queue: http://localhost:9324/101010101010/task-action-queue
|
|
34
|
+
- topic:
|
|
35
|
+
topicName: CqrsSnsTopic
|
|
36
|
+
rawMessageDelivery: 'true'
|
|
37
|
+
filterPolicy:
|
|
38
|
+
{
|
|
39
|
+
'action':
|
|
40
|
+
['notification-action', 'command-status', 'task-status'],
|
|
41
|
+
}
|
|
42
|
+
queue: http://localhost:9324/101010101010/notification-queue
|
|
43
|
+
# host: 0.0.0.0 # Optional, defaults to 127.0.0.1 if not provided to serverless-offline
|
|
44
|
+
# sns-endpoint: http://127.0.0.1:4567 # Optional. Only if you want to use a custom SNS provider endpoint
|
|
45
|
+
# sns-subscribe-endpoint: http://127.0.0.1:3000 # Optional. Only if you want to use a custom subscribe endpoint from SNS to send messages back to
|
|
46
|
+
accountId: 101010101010 # Optional
|
|
47
|
+
serverless-offline-sqs:
|
|
48
|
+
autoCreate: false # create queue if not exists
|
|
49
|
+
accountId: 101010101010
|
|
50
|
+
debug: true
|
|
51
|
+
apiVersion: '2012-11-05'
|
|
52
|
+
endpoint: http://localhost:9324
|
|
53
|
+
region: ap-northeast-1
|
|
54
|
+
accessKeyId: root
|
|
55
|
+
secretAccessKey: root
|
|
56
|
+
skipCacheInvalidation: false
|
|
57
|
+
stepFunctionsLocal:
|
|
58
|
+
accountId: 101010101010
|
|
59
|
+
region: ap-northeast-1
|
|
60
|
+
# lambdaEndpoint: http://0.0.0.0:3002
|
|
61
|
+
externalInstance: true
|
|
62
|
+
serverless-dynamodb:
|
|
63
|
+
stages:
|
|
64
|
+
# set for create tables on dev enviroment
|
|
65
|
+
- dev
|
|
66
|
+
start:
|
|
67
|
+
docker: true
|
|
68
|
+
inMemory: true
|
|
69
|
+
port: 8000
|
|
70
|
+
noStart: true
|
|
71
|
+
seed: true
|
|
72
|
+
migrate: false # create tables on start
|
|
73
|
+
onStart: false
|
|
74
|
+
convertEmptyValues: true
|
|
75
|
+
serverless-offline-dynamodb-streams:
|
|
76
|
+
endpoint: http://localhost:8000
|
|
77
|
+
serverless-offline-aws-eventbridge:
|
|
78
|
+
port: 4010 # port to run the eventBridge mock server on
|
|
79
|
+
mockEventBridgeServer: true # Set to false if EventBridge is already mocked by another stack
|
|
80
|
+
hostname: 127.0.0.1 # IP or hostname of existing EventBridge if mocked by another stack
|
|
81
|
+
pubSubPort: 4011 # Port to run the MQ server (or just listen if using an EventBridge Mock server from another stack)
|
|
82
|
+
debug: false # flag to show debug messages
|
|
83
|
+
account: '' # account id that gets passed to the event
|
|
84
|
+
maximumRetryAttempts: 10 # maximumRetryAttempts to retry lambda
|
|
85
|
+
retryDelayMs: 500 # retry delay
|
|
86
|
+
throwRetryExhausted: false # default true
|
|
87
|
+
payloadSizeLimit: '10mb' # Controls the maximum payload size being passed to https://www.npmjs.com/package/bytes (Note: this payload size might not be the same size as your AWS Eventbridge receive)
|
|
88
|
+
# localStackConfig:
|
|
89
|
+
# localStackEndpoint: http://localhost:4566
|
|
90
|
+
|
|
91
|
+
provider:
|
|
92
|
+
name: aws
|
|
93
|
+
region: ap-northeast-1
|
|
94
|
+
runtime: nodejs18.x
|
|
95
|
+
profile: serverless
|
|
96
|
+
httpApi:
|
|
97
|
+
authorizers:
|
|
98
|
+
localAuthorizer:
|
|
99
|
+
type: jwt
|
|
100
|
+
identitySource: $request.header.Authorization
|
|
101
|
+
issuerUrl: http://localhost:9229/local_2G7noHgW
|
|
102
|
+
audience:
|
|
103
|
+
- dnk8y7ii3wled35p3lw0l2cd7
|
|
104
|
+
keycloakAuthorizer:
|
|
105
|
+
type: jwt
|
|
106
|
+
identitySource: $request.header.Authorization
|
|
107
|
+
issuerUrl: http://localhost:8180/realms/master
|
|
108
|
+
# issuerUrl: http://localhost:8180/auth/realms/master # old version
|
|
109
|
+
audience:
|
|
110
|
+
- cqrs-demo
|
|
111
|
+
|
|
112
|
+
functions:
|
|
113
|
+
main:
|
|
114
|
+
handler: ../dist/main.handler
|
|
115
|
+
events:
|
|
116
|
+
- httpApi: # public api
|
|
117
|
+
method: GET
|
|
118
|
+
path: /
|
|
119
|
+
- httpApi:
|
|
120
|
+
method: ANY
|
|
121
|
+
path: '/swagger-ui/{proxy+}'
|
|
122
|
+
- httpApi: # protected api
|
|
123
|
+
method: ANY
|
|
124
|
+
path: '/{proxy+}'
|
|
125
|
+
authorizer:
|
|
126
|
+
name: localAuthorizer
|
|
127
|
+
# authorizer:
|
|
128
|
+
# name: keycloakAuthorizer
|
|
129
|
+
# - eventBridge:
|
|
130
|
+
# eventBus: marketing
|
|
131
|
+
# # run every 5 minutes
|
|
132
|
+
# schedule: "cron(0/5 * * * ? *)"
|
|
133
|
+
- sqs:
|
|
134
|
+
arn:
|
|
135
|
+
Fn::GetAtt:
|
|
136
|
+
- TaskActionQueue
|
|
137
|
+
- Arn
|
|
138
|
+
- sqs:
|
|
139
|
+
arn:
|
|
140
|
+
Fn::GetAtt:
|
|
141
|
+
- NotificationQueue
|
|
142
|
+
- Arn
|
|
143
|
+
- stream:
|
|
144
|
+
type: dynamodb
|
|
145
|
+
maximumRetryAttempts: 10
|
|
146
|
+
arn: ${env:LOCAL_DDB_MASTER_STREAM}
|
|
147
|
+
filterPatterns:
|
|
148
|
+
- eventName: [INSERT]
|
|
149
|
+
|
|
150
|
+
stepFunctions:
|
|
151
|
+
# https://goessner.net/articles/JsonPath/index.html
|
|
152
|
+
# https://docs.aws.amazon.com/step-functions/latest/dg/concepts-input-output-filtering.html
|
|
153
|
+
stateMachines:
|
|
154
|
+
command:
|
|
155
|
+
name: command
|
|
156
|
+
definition:
|
|
157
|
+
Comment: 'An example of the Amazon States Language using wait states'
|
|
158
|
+
StartAt: check_version
|
|
159
|
+
States:
|
|
160
|
+
fail:
|
|
161
|
+
Type: Fail
|
|
162
|
+
CausePath: $.cause
|
|
163
|
+
ErrorPath: $.error
|
|
164
|
+
success:
|
|
165
|
+
Type: Succeed
|
|
166
|
+
check_version:
|
|
167
|
+
Type: Task
|
|
168
|
+
Resource: arn:aws:states:::lambda:invoke
|
|
169
|
+
Parameters:
|
|
170
|
+
FunctionName: arn:aws:lambda:ap-northeast-1:101010101010:function:serverless-example-dev-main
|
|
171
|
+
Payload:
|
|
172
|
+
input.$: $
|
|
173
|
+
context.$: $$
|
|
174
|
+
Retry:
|
|
175
|
+
- ErrorEquals:
|
|
176
|
+
- Lambda.ServiceException
|
|
177
|
+
- Lambda.AWSLambdaException
|
|
178
|
+
- Lambda.SdkClientException
|
|
179
|
+
IntervalSeconds: 2
|
|
180
|
+
MaxAttempts: 5
|
|
181
|
+
BackoffRate: 2
|
|
182
|
+
OutputPath: $.Payload[0][0]
|
|
183
|
+
Next: check_version_result
|
|
184
|
+
check_version_result:
|
|
185
|
+
Type: Choice
|
|
186
|
+
Choices:
|
|
187
|
+
- Variable: $.result
|
|
188
|
+
NumericEquals: 0
|
|
189
|
+
Next: history_copy
|
|
190
|
+
- Variable: $.result
|
|
191
|
+
NumericEquals: 1
|
|
192
|
+
Next: wait_prev_command
|
|
193
|
+
- Variable: $.result
|
|
194
|
+
NumericEquals: -1
|
|
195
|
+
Next: fail
|
|
196
|
+
Default: wait_prev_command
|
|
197
|
+
wait_prev_command:
|
|
198
|
+
Type: Task
|
|
199
|
+
Resource: arn:aws:states:::lambda:invoke.waitForTaskToken
|
|
200
|
+
Parameters:
|
|
201
|
+
FunctionName: arn:aws:lambda:ap-northeast-1:101010101010:function:serverless-example-dev-main
|
|
202
|
+
Payload:
|
|
203
|
+
input.$: $
|
|
204
|
+
context.$: $$
|
|
205
|
+
taskToken.$: $$.Task.Token
|
|
206
|
+
Retry:
|
|
207
|
+
- ErrorEquals:
|
|
208
|
+
- Lambda.ServiceException
|
|
209
|
+
- Lambda.AWSLambdaException
|
|
210
|
+
- Lambda.SdkClientException
|
|
211
|
+
IntervalSeconds: 2
|
|
212
|
+
MaxAttempts: 5
|
|
213
|
+
BackoffRate: 2
|
|
214
|
+
OutputPath: $.Payload[0][0]
|
|
215
|
+
Next: history_copy
|
|
216
|
+
history_copy:
|
|
217
|
+
Type: Task
|
|
218
|
+
Resource: arn:aws:states:::lambda:invoke
|
|
219
|
+
Parameters:
|
|
220
|
+
FunctionName: arn:aws:lambda:ap-northeast-1:101010101010:function:serverless-example-dev-main
|
|
221
|
+
Payload:
|
|
222
|
+
input.$: $
|
|
223
|
+
context.$: $$
|
|
224
|
+
Retry:
|
|
225
|
+
- ErrorEquals:
|
|
226
|
+
- Lambda.ServiceException
|
|
227
|
+
- Lambda.AWSLambdaException
|
|
228
|
+
- Lambda.SdkClientException
|
|
229
|
+
IntervalSeconds: 2
|
|
230
|
+
MaxAttempts: 5
|
|
231
|
+
BackoffRate: 2
|
|
232
|
+
OutputPath: $.Payload[0][0]
|
|
233
|
+
Next: transform_data
|
|
234
|
+
transform_data:
|
|
235
|
+
Type: Task
|
|
236
|
+
Resource: arn:aws:states:::lambda:invoke
|
|
237
|
+
Parameters:
|
|
238
|
+
FunctionName: arn:aws:lambda:ap-northeast-1:101010101010:function:serverless-example-dev-main
|
|
239
|
+
Payload:
|
|
240
|
+
input.$: $
|
|
241
|
+
context.$: $$
|
|
242
|
+
Retry:
|
|
243
|
+
- ErrorEquals:
|
|
244
|
+
- Lambda.ServiceException
|
|
245
|
+
- Lambda.AWSLambdaException
|
|
246
|
+
- Lambda.SdkClientException
|
|
247
|
+
IntervalSeconds: 2
|
|
248
|
+
MaxAttempts: 5
|
|
249
|
+
BackoffRate: 2
|
|
250
|
+
OutputPath: $.Payload[0][0]
|
|
251
|
+
Next: sync_data_all
|
|
252
|
+
sync_data_all:
|
|
253
|
+
Type: Map
|
|
254
|
+
MaxConcurrency: 0
|
|
255
|
+
ItemsPath: $
|
|
256
|
+
Iterator:
|
|
257
|
+
StartAt: sync_data
|
|
258
|
+
States:
|
|
259
|
+
sync_data:
|
|
260
|
+
Type: Task
|
|
261
|
+
Resource: arn:aws:states:::lambda:invoke
|
|
262
|
+
Parameters:
|
|
263
|
+
FunctionName: arn:aws:lambda:ap-northeast-1:101010101010:function:serverless-example-dev-main
|
|
264
|
+
Payload:
|
|
265
|
+
input.$: $
|
|
266
|
+
context.$: $$
|
|
267
|
+
Retry:
|
|
268
|
+
- ErrorEquals:
|
|
269
|
+
- Lambda.ServiceException
|
|
270
|
+
- Lambda.AWSLambdaException
|
|
271
|
+
- Lambda.SdkClientException
|
|
272
|
+
IntervalSeconds: 2
|
|
273
|
+
MaxAttempts: 5
|
|
274
|
+
BackoffRate: 2
|
|
275
|
+
OutputPath: $.Payload[0][0]
|
|
276
|
+
End: true
|
|
277
|
+
Next: finish
|
|
278
|
+
finish:
|
|
279
|
+
Type: Task
|
|
280
|
+
Resource: arn:aws:states:::lambda:invoke
|
|
281
|
+
Parameters:
|
|
282
|
+
FunctionName: arn:aws:lambda:ap-northeast-1:101010101010:function:serverless-example-dev-main
|
|
283
|
+
Payload:
|
|
284
|
+
input.$: $
|
|
285
|
+
context.$: $$
|
|
286
|
+
Retry:
|
|
287
|
+
- ErrorEquals:
|
|
288
|
+
- Lambda.ServiceException
|
|
289
|
+
- Lambda.AWSLambdaException
|
|
290
|
+
- Lambda.SdkClientException
|
|
291
|
+
IntervalSeconds: 2
|
|
292
|
+
MaxAttempts: 5
|
|
293
|
+
BackoffRate: 2
|
|
294
|
+
OutputPath: $.Payload[0][0]
|
|
295
|
+
Next: success
|
|
296
|
+
|
|
297
|
+
resources:
|
|
298
|
+
Resources:
|
|
299
|
+
TaskActionQueue:
|
|
300
|
+
Type: AWS::SQS::Queue
|
|
301
|
+
Properties:
|
|
302
|
+
QueueName: task-action-queue
|
|
303
|
+
NotificationQueue:
|
|
304
|
+
Type: AWS::SQS::Queue
|
|
305
|
+
Properties:
|
|
306
|
+
QueueName: notification-queue
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/nest-cli",
|
|
3
|
+
"collection": "@nestjs/schematics",
|
|
4
|
+
"sourceRoot": "src",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"deleteOutDir": true,
|
|
7
|
+
"plugins": [
|
|
8
|
+
{
|
|
9
|
+
"name": "@nestjs/swagger",
|
|
10
|
+
"options": {
|
|
11
|
+
"introspectComments": true
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
}
|