lesgo 0.7.8 → 2.1.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/README.md +5 -4
- package/bin/lesgo-scripts.sh +52 -7
- package/dist/config/app.d.ts +7 -0
- package/dist/config/app.js +9 -0
- package/dist/config/aws.d.ts +5 -0
- package/dist/config/aws.js +4 -0
- package/dist/config/basicAuth.d.ts +7 -0
- package/dist/config/basicAuth.js +8 -0
- package/dist/config/crypto.d.ts +10 -0
- package/dist/config/crypto.js +9 -0
- package/dist/config/dynamodb.d.ts +8 -0
- package/dist/config/dynamodb.js +14 -0
- package/dist/config/elasticache.d.ts +7 -0
- package/dist/config/elasticache.js +6 -0
- package/dist/config/index.d.ts +11 -0
- package/dist/config/index.js +11 -0
- package/dist/config/jwt.d.ts +12 -0
- package/dist/config/jwt.js +16 -0
- package/dist/config/rds.d.ts +12 -0
- package/dist/config/rds.js +13 -0
- package/dist/config/s3.d.ts +5 -0
- package/dist/config/s3.js +5 -0
- package/dist/config/secretsManager.d.ts +4 -0
- package/dist/config/secretsManager.js +4 -0
- package/dist/config/sqs.d.ts +9 -0
- package/dist/config/sqs.js +18 -0
- package/dist/exceptions/LesgoException.d.ts +6 -0
- package/{src → dist}/exceptions/LesgoException.js +5 -4
- package/dist/exceptions/index.d.ts +1 -0
- package/dist/exceptions/index.js +1 -0
- package/dist/middlewares/disconnectMiddleware.d.ts +8 -0
- package/dist/middlewares/disconnectMiddleware.js +78 -0
- package/dist/middlewares/httpMiddleware.d.ts +12 -0
- package/dist/middlewares/httpMiddleware.js +74 -0
- package/dist/middlewares/httpResponseMiddleware.d.ts +7 -0
- package/dist/middlewares/httpResponseMiddleware.js +128 -0
- package/dist/middlewares/index.d.ts +7 -0
- package/dist/middlewares/index.js +7 -0
- package/dist/middlewares/invokeCommandMiddleware.d.ts +12 -0
- package/dist/middlewares/invokeCommandMiddleware.js +70 -0
- package/dist/middlewares/sqsMiddleware.d.ts +10 -0
- package/dist/middlewares/sqsMiddleware.js +70 -0
- package/dist/middlewares/verifyBasicAuthMiddleware.d.ts +8 -0
- package/dist/middlewares/verifyBasicAuthMiddleware.js +59 -0
- package/dist/middlewares/verifyJwtMiddleware.d.ts +6 -0
- package/dist/middlewares/verifyJwtMiddleware.js +37 -0
- package/dist/services/DynamoDbService/deleteRecord.d.ts +8 -0
- package/dist/services/DynamoDbService/deleteRecord.js +69 -0
- package/dist/services/DynamoDbService/getClient.d.ts +7 -0
- package/dist/services/DynamoDbService/getClient.js +30 -0
- package/dist/services/DynamoDbService/getTableName.d.ts +2 -0
- package/dist/services/DynamoDbService/getTableName.js +15 -0
- package/dist/services/DynamoDbService/index.d.ts +6 -0
- package/dist/services/DynamoDbService/index.js +6 -0
- package/dist/services/DynamoDbService/putRecord.d.ts +8 -0
- package/dist/services/DynamoDbService/putRecord.js +64 -0
- package/dist/services/DynamoDbService/query.d.ts +7 -0
- package/dist/services/DynamoDbService/query.js +78 -0
- package/dist/services/DynamoDbService/scan.d.ts +7 -0
- package/dist/services/DynamoDbService/scan.js +60 -0
- package/dist/services/DynamoDbService/updateRecord.d.ts +9 -0
- package/dist/services/DynamoDbService/updateRecord.js +89 -0
- package/dist/services/ElastiCacheRedisService/deleteRedisCache.d.ts +3 -0
- package/dist/services/ElastiCacheRedisService/deleteRedisCache.js +62 -0
- package/dist/services/ElastiCacheRedisService/disconnectElastiCacheRedisClient.d.ts +11 -0
- package/dist/services/ElastiCacheRedisService/disconnectElastiCacheRedisClient.js +69 -0
- package/dist/services/ElastiCacheRedisService/getElastiCacheRedisClient.d.ts +12 -0
- package/dist/services/ElastiCacheRedisService/getElastiCacheRedisClient.js +114 -0
- package/dist/services/ElastiCacheRedisService/getRedisCache.d.ts +3 -0
- package/dist/services/ElastiCacheRedisService/getRedisCache.js +70 -0
- package/dist/services/ElastiCacheRedisService/index.d.ts +5 -0
- package/dist/services/ElastiCacheRedisService/index.js +5 -0
- package/dist/services/ElastiCacheRedisService/setRedisCache.d.ts +6 -0
- package/dist/services/ElastiCacheRedisService/setRedisCache.js +77 -0
- package/dist/services/JWTService/decodeJwt.d.ts +7 -0
- package/dist/services/JWTService/decodeJwt.js +9 -0
- package/dist/services/JWTService/getJwtSecret.d.ts +13 -0
- package/dist/services/JWTService/getJwtSecret.js +54 -0
- package/dist/services/JWTService/index.d.ts +2 -0
- package/dist/services/JWTService/index.js +2 -0
- package/dist/services/JWTService/sign.d.ts +3 -0
- package/dist/services/JWTService/sign.js +31 -0
- package/dist/services/JWTService/verify.d.ts +7 -0
- package/dist/services/JWTService/verify.js +61 -0
- package/dist/services/LoggerService.d.ts +46 -0
- package/{src → dist}/services/LoggerService.js +36 -60
- package/dist/services/RDSAuroraMySQLProxyService/disconnectMySQLProxyClient.d.ts +2 -0
- package/dist/services/RDSAuroraMySQLProxyService/disconnectMySQLProxyClient.js +60 -0
- package/dist/services/RDSAuroraMySQLProxyService/getMySQLProxyClient.d.ts +8 -0
- package/dist/services/RDSAuroraMySQLProxyService/getMySQLProxyClient.js +87 -0
- package/dist/services/RDSAuroraMySQLProxyService/index.d.ts +3 -0
- package/dist/services/RDSAuroraMySQLProxyService/index.js +3 -0
- package/dist/services/RDSAuroraMySQLProxyService/query.d.ts +4 -0
- package/dist/services/RDSAuroraMySQLProxyService/query.js +63 -0
- package/dist/services/S3Service/getClient.d.ts +4 -0
- package/dist/services/S3Service/getClient.js +28 -0
- package/dist/services/S3Service/getDownloadSignedUrl.d.ts +7 -0
- package/dist/services/S3Service/getDownloadSignedUrl.js +58 -0
- package/dist/services/S3Service/getHeadObject.d.ts +13 -0
- package/dist/services/S3Service/getHeadObject.js +83 -0
- package/dist/services/S3Service/getObject.d.ts +10 -0
- package/dist/services/S3Service/getObject.js +89 -0
- package/dist/services/S3Service/getUploadSignedUrl.d.ts +7 -0
- package/dist/services/S3Service/getUploadSignedUrl.js +61 -0
- package/dist/services/S3Service/index.d.ts +6 -0
- package/dist/services/S3Service/index.js +6 -0
- package/dist/services/S3Service/putObject.d.ts +9 -0
- package/dist/services/S3Service/putObject.js +77 -0
- package/dist/services/SQSService/deleteMessage.d.ts +9 -0
- package/dist/services/SQSService/deleteMessage.js +69 -0
- package/dist/services/SQSService/dispatch.d.ts +9 -0
- package/dist/services/SQSService/dispatch.js +71 -0
- package/dist/services/SQSService/getClient.d.ts +4 -0
- package/dist/services/SQSService/getClient.js +28 -0
- package/dist/services/SQSService/getQueueUrl.d.ts +7 -0
- package/dist/services/SQSService/getQueueUrl.js +25 -0
- package/dist/services/SQSService/index.d.ts +4 -0
- package/dist/services/SQSService/index.js +4 -0
- package/dist/services/SQSService/receiveMessages.d.ts +8 -0
- package/dist/services/SQSService/receiveMessages.js +65 -0
- package/dist/services/SecretsManagerService/getClient.d.ts +7 -0
- package/dist/services/SecretsManagerService/getClient.js +28 -0
- package/dist/services/SecretsManagerService/getSecretValue.d.ts +7 -0
- package/dist/services/SecretsManagerService/getSecretValue.js +65 -0
- package/dist/services/SecretsManagerService/index.d.ts +2 -0
- package/dist/services/SecretsManagerService/index.js +2 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.js +1 -0
- package/dist/types/aws.d.ts +8 -0
- package/dist/types/aws.js +1 -0
- package/dist/utils/cache/redis/deleteCache.d.ts +19 -0
- package/dist/utils/cache/redis/deleteCache.js +21 -0
- package/dist/utils/cache/redis/getCache.d.ts +22 -0
- package/dist/utils/cache/redis/getCache.js +24 -0
- package/dist/utils/cache/redis/getClient.d.ts +30 -0
- package/dist/utils/cache/redis/getClient.js +32 -0
- package/dist/utils/cache/redis/index.d.ts +4 -0
- package/dist/utils/cache/redis/index.js +4 -0
- package/dist/utils/cache/redis/setCache.d.ts +25 -0
- package/dist/utils/cache/redis/setCache.js +26 -0
- package/dist/utils/crypto/decrypt.d.ts +33 -0
- package/dist/utils/crypto/decrypt.js +59 -0
- package/dist/utils/crypto/encrypt.d.ts +31 -0
- package/dist/utils/crypto/encrypt.js +41 -0
- package/dist/utils/crypto/hash.d.ts +31 -0
- package/dist/utils/crypto/hash.js +56 -0
- package/dist/utils/crypto/index.d.ts +3 -0
- package/dist/utils/crypto/index.js +3 -0
- package/dist/utils/crypto/validateEncryptionFields.d.ts +19 -0
- package/dist/utils/crypto/validateEncryptionFields.js +71 -0
- package/dist/utils/db/mysql/proxy/disconnect.d.ts +2 -0
- package/dist/utils/db/mysql/proxy/disconnect.js +5 -0
- package/dist/utils/db/mysql/proxy/disconnectDb.d.ts +2 -0
- package/dist/utils/db/mysql/proxy/disconnectDb.js +5 -0
- package/dist/utils/db/mysql/proxy/getClient.d.ts +4 -0
- package/dist/utils/db/mysql/proxy/getClient.js +5 -0
- package/dist/utils/db/mysql/proxy/index.d.ts +3 -0
- package/dist/utils/db/mysql/proxy/index.js +3 -0
- package/dist/utils/db/mysql/proxy/query.d.ts +4 -0
- package/dist/utils/db/mysql/proxy/query.js +45 -0
- package/dist/utils/dynamodb/deleteRecord.d.ts +5 -0
- package/dist/utils/dynamodb/deleteRecord.js +39 -0
- package/dist/utils/dynamodb/getClient.d.ts +3 -0
- package/dist/utils/dynamodb/getClient.js +5 -0
- package/dist/utils/dynamodb/index.d.ts +6 -0
- package/dist/utils/dynamodb/index.js +6 -0
- package/dist/utils/dynamodb/putRecord.d.ts +4 -0
- package/dist/utils/dynamodb/putRecord.js +39 -0
- package/dist/utils/dynamodb/query.d.ts +5 -0
- package/dist/utils/dynamodb/query.js +52 -0
- package/dist/utils/dynamodb/scan.d.ts +4 -0
- package/dist/utils/dynamodb/scan.js +40 -0
- package/dist/utils/dynamodb/updateRecord.d.ts +5 -0
- package/dist/utils/dynamodb/updateRecord.js +53 -0
- package/dist/utils/formatUnixTimestamp.d.ts +8 -0
- package/dist/utils/formatUnixTimestamp.js +17 -0
- package/dist/utils/generateUid.d.ts +13 -0
- package/{src → dist}/utils/generateUid.js +9 -4
- package/dist/utils/getCurrentDatetime.d.ts +2 -0
- package/dist/utils/getCurrentDatetime.js +4 -0
- package/dist/utils/getCurrentTimestamp.d.ts +7 -0
- package/dist/utils/getCurrentTimestamp.js +9 -0
- package/dist/utils/getJwtSubFromAuthHeader.d.ts +9 -0
- package/dist/utils/getJwtSubFromAuthHeader.js +24 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.js +9 -0
- package/dist/utils/isDecimal.d.ts +8 -0
- package/dist/utils/isDecimal.js +9 -0
- package/dist/utils/isEmail.d.ts +9 -0
- package/{src → dist}/utils/isEmail.js +9 -4
- package/dist/utils/isEmpty.d.ts +8 -0
- package/dist/utils/isEmpty.js +19 -0
- package/dist/utils/jwt/index.d.ts +2 -0
- package/dist/utils/jwt/index.js +2 -0
- package/dist/utils/jwt/sign.d.ts +3 -0
- package/dist/utils/jwt/sign.js +5 -0
- package/dist/utils/jwt/verify.d.ts +3 -0
- package/dist/utils/jwt/verify.js +12 -0
- package/dist/utils/logger.d.ts +20 -0
- package/dist/utils/logger.js +38 -0
- package/dist/utils/s3/getClient.d.ts +3 -0
- package/dist/utils/s3/getClient.js +5 -0
- package/dist/utils/s3/getDownloadSignedUrl.d.ts +5 -0
- package/dist/utils/s3/getDownloadSignedUrl.js +39 -0
- package/dist/utils/s3/getHeadObject.d.ts +10 -0
- package/dist/utils/s3/getHeadObject.js +39 -0
- package/dist/utils/s3/getObject.d.ts +13 -0
- package/dist/utils/s3/getObject.js +51 -0
- package/dist/utils/s3/getUploadSignedUrl.d.ts +5 -0
- package/dist/utils/s3/getUploadSignedUrl.js +39 -0
- package/dist/utils/s3/index.d.ts +6 -0
- package/dist/utils/s3/index.js +6 -0
- package/dist/utils/s3/putObject.d.ts +5 -0
- package/dist/utils/s3/putObject.js +39 -0
- package/dist/utils/secretsmanager/getClient.d.ts +3 -0
- package/dist/utils/secretsmanager/getClient.js +5 -0
- package/dist/utils/secretsmanager/getSecretValue.d.ts +4 -0
- package/dist/utils/secretsmanager/getSecretValue.js +68 -0
- package/dist/utils/secretsmanager/index.d.ts +2 -0
- package/dist/utils/secretsmanager/index.js +2 -0
- package/dist/utils/sqs/deleteMessage.d.ts +5 -0
- package/dist/utils/sqs/deleteMessage.js +39 -0
- package/dist/utils/sqs/dispatch.d.ts +5 -0
- package/dist/utils/sqs/dispatch.js +39 -0
- package/dist/utils/sqs/getClient.d.ts +3 -0
- package/dist/utils/sqs/getClient.js +5 -0
- package/dist/utils/sqs/index.d.ts +4 -0
- package/dist/utils/sqs/index.js +4 -0
- package/dist/utils/sqs/receiveMessages.d.ts +5 -0
- package/dist/utils/sqs/receiveMessages.js +39 -0
- package/dist/utils/validateFields.d.ts +22 -0
- package/{src → dist}/utils/validateFields.js +13 -19
- package/package.json +145 -34
- package/CHANGELOG.md +0 -9
- package/src/exceptions/__tests__/LesgoException.spec.js +0 -24
- package/src/exceptions/index.js +0 -4
- package/src/index.js +0 -4
- package/src/middlewares/__mocks__/ValidationErrorException.js +0 -18
- package/src/middlewares/__tests__/basicAuthMiddleware.spec.js +0 -225
- package/src/middlewares/__tests__/clientAuthMiddleware.spec.js +0 -137
- package/src/middlewares/__tests__/errorHttpResponseMiddleware.spec.js +0 -190
- package/src/middlewares/__tests__/gzipHttpResponse.spec.js +0 -185
- package/src/middlewares/__tests__/httpNoOutputMiddleware.spec.js +0 -199
- package/src/middlewares/__tests__/normalizeHttpRequestMiddleware.spec.js +0 -181
- package/src/middlewares/__tests__/normalizeSQSMessageMiddleware.spec.js +0 -120
- package/src/middlewares/__tests__/serverAuthMiddleware.spec.js +0 -170
- package/src/middlewares/__tests__/successHttpResponseMiddleware.spec.js +0 -159
- package/src/middlewares/__tests__/verifyJwtMiddleware.spec.js +0 -222
- package/src/middlewares/basicAuthMiddleware.js +0 -145
- package/src/middlewares/clientAuthMiddleware.js +0 -82
- package/src/middlewares/errorHttpResponseMiddleware.js +0 -99
- package/src/middlewares/gzipHttpResponse.js +0 -98
- package/src/middlewares/httpMiddleware.js +0 -19
- package/src/middlewares/httpNoOutputMiddleware.js +0 -87
- package/src/middlewares/index.js +0 -15
- package/src/middlewares/normalizeHttpRequestMiddleware.js +0 -101
- package/src/middlewares/normalizeSQSMessageMiddleware.js +0 -67
- package/src/middlewares/serverAuthMiddleware.js +0 -29
- package/src/middlewares/successHttpResponseMiddleware.js +0 -83
- package/src/middlewares/verifyJwtMiddleware.js +0 -62
- package/src/services/AuroraDbRDSProxyService.js +0 -182
- package/src/services/AuroraDbService.js +0 -111
- package/src/services/DynamoDbService.js +0 -177
- package/src/services/ElastiCacheService.js +0 -17
- package/src/services/ElasticsearchService.js +0 -181
- package/src/services/FirebaseAdminService.js +0 -108
- package/src/services/JwtService.js +0 -52
- package/src/services/S3Service.js +0 -59
- package/src/services/SQSService.js +0 -65
- package/src/services/__tests__/AuroraDbRDSProxyService.spec.js +0 -278
- package/src/services/__tests__/AuroraDbService.spec.js +0 -211
- package/src/services/__tests__/AwsElasticsearchConnection.spec.js +0 -89
- package/src/services/__tests__/DynamoDbService.spec.js +0 -314
- package/src/services/__tests__/ElasticsearchService.spec.js +0 -201
- package/src/services/__tests__/FirebaseAdminService.spec.js +0 -356
- package/src/services/__tests__/JwtService.spec.js +0 -35
- package/src/services/__tests__/LengthAwarePaginator.spec.js +0 -223
- package/src/services/__tests__/LoggerService.spec.js +0 -252
- package/src/services/__tests__/Paginator.spec.js +0 -383
- package/src/services/__tests__/S3Service.spec.js +0 -55
- package/src/services/__tests__/SQSService.spec.js +0 -47
- package/src/services/__tests__/SignedRequest.spec.js +0 -103
- package/src/services/aws/AwsElasticsearchConnection.js +0 -59
- package/src/services/aws/SignedRequest.js +0 -158
- package/src/services/index.js +0 -19
- package/src/services/pagination/LengthAwarePaginator.js +0 -49
- package/src/services/pagination/Paginator.js +0 -260
- package/src/utils/__mocks__/db.js +0 -109
- package/src/utils/__tests__/cache.spec.js +0 -131
- package/src/utils/__tests__/crypto.spec.js +0 -122
- package/src/utils/__tests__/db.spec.js +0 -70
- package/src/utils/__tests__/dynamodb.spec.js +0 -27
- package/src/utils/__tests__/elasticsearch.spec.js +0 -43
- package/src/utils/__tests__/generateUid.spec.js +0 -36
- package/src/utils/__tests__/getJwtSubFromAuthHeader.spec.js +0 -20
- package/src/utils/__tests__/isDecimal.spec.js +0 -12
- package/src/utils/__tests__/isEmail.spec.js +0 -28
- package/src/utils/__tests__/isEmpty.spec.js +0 -31
- package/src/utils/__tests__/logger.spec.js +0 -11
- package/src/utils/__tests__/objectStore.spec.js +0 -67
- package/src/utils/__tests__/prepSQLInsertParams.spec.js +0 -46
- package/src/utils/__tests__/prepSQLUpdateParams.spec.js +0 -36
- package/src/utils/__tests__/queue.spec.js +0 -54
- package/src/utils/__tests__/validateFields.spec.js +0 -374
- package/src/utils/cache.js +0 -215
- package/src/utils/crypto.js +0 -77
- package/src/utils/db.js +0 -17
- package/src/utils/dynamodb.js +0 -6
- package/src/utils/elasticsearch.js +0 -20
- package/src/utils/getJwtSubFromAuthHeader.js +0 -18
- package/src/utils/index.js +0 -26
- package/src/utils/isDecimal.js +0 -2
- package/src/utils/isEmpty.js +0 -6
- package/src/utils/logger.js +0 -25
- package/src/utils/objectStore.js +0 -11
- package/src/utils/prepSQLInsertParams.js +0 -21
- package/src/utils/prepSQLUpdateParams.js +0 -25
- package/src/utils/queue.js +0 -11
package/README.md
CHANGED
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
|
|
6
6
|
Bootstrap your next microservice with a lightweight node.js serverless framework.
|
|
7
7
|
|
|
8
|
-
> Note: This repository contains the core code of the Lesgo! framework. If you want to build an application using Lesgo!, visit the
|
|
8
|
+
> Note: This repository contains the core code of the Lesgo! framework. If you want to build an application using Lesgo!, visit the [docs](https://reflex-media.github.io/lesgo-docs).
|
|
9
9
|
|
|
10
10
|
## Unit Test
|
|
11
11
|
|
|
12
12
|
This framework uses Jest test framework for unit testing.
|
|
13
13
|
|
|
14
|
-
All test files exist in the respective `src
|
|
14
|
+
All test files exist in the respective `src/**/__tests__/*.test.ts` directory.
|
|
15
15
|
|
|
16
16
|
**Install dependencies**
|
|
17
17
|
|
|
@@ -35,8 +35,9 @@ View the generated html report in `coverage/index.html`.
|
|
|
35
35
|
|
|
36
36
|
### Testing environment
|
|
37
37
|
|
|
38
|
-
Declare testing environment configurations in `
|
|
38
|
+
Declare testing environment configurations in `jest.setup.ts` directory.
|
|
39
39
|
|
|
40
40
|
## Contributing
|
|
41
41
|
|
|
42
|
-
You may contribute to the core framework by submitting a PR to the `develop` branch. Refer to the official [Docs](https://reflex-media.github.io/lesgo-docs/
|
|
42
|
+
You may contribute to the core framework by submitting a PR to the `develop` branch. Refer to the official [Docs](https://reflex-media.github.io/lesgo-docs/stable/prologue/contribution-guide/) for more information.
|
|
43
|
+
|
package/bin/lesgo-scripts.sh
CHANGED
|
@@ -93,6 +93,21 @@ NC='\033[0m';
|
|
|
93
93
|
# FUNCTION DECLARATIONS #
|
|
94
94
|
# #
|
|
95
95
|
###############################################################################
|
|
96
|
+
LOCAL_SERVERLESS_VERSION=`npm ls --depth=0 serverless | grep -o "serverless@.*" || true`
|
|
97
|
+
GLOBAL_SERVERLESS_VERSION=`npm ls -g --depth=0 serverless | grep -o "serverless@.*" || true`
|
|
98
|
+
LATEST_SERVERLESS_VERSION_NUMBER=3
|
|
99
|
+
|
|
100
|
+
if [ -z "$LOCAL_SERVERLESS_VERSION" ]
|
|
101
|
+
then
|
|
102
|
+
CURRENT_SERVERLESS_VERSION=$GLOBAL_SERVERLESS_VERSION
|
|
103
|
+
else
|
|
104
|
+
CURRENT_SERVERLESS_VERSION=$LOCAL_SERVERLESS_VERSION
|
|
105
|
+
fi
|
|
106
|
+
SERVERLESS_VERSION=${CURRENT_SERVERLESS_VERSION#*@}
|
|
107
|
+
SERVERLESS_VERSION_NUMBER=${SERVERLESS_VERSION%%.*}
|
|
108
|
+
|
|
109
|
+
echo -e "Running Serverless version:\n${CURRENT_SERVERLESS_VERSION}\n"
|
|
110
|
+
echo -e "Current Serverless version: ${SERVERLESS_VERSION_NUMBER}\n"
|
|
96
111
|
|
|
97
112
|
function deploy_func_check ()
|
|
98
113
|
{
|
|
@@ -106,7 +121,12 @@ function deploy_func_check ()
|
|
|
106
121
|
function deploy_func ()
|
|
107
122
|
{
|
|
108
123
|
echo -e "${YELLOW}Deploying ${FUNCTION} to ${STAGE}${NC} using ${CONFIG}"
|
|
109
|
-
|
|
124
|
+
|
|
125
|
+
if [ ${SERVERLESS_VERSION_NUMBER} -ge ${LATEST_SERVERLESS_VERSION_NUMBER} ]; then
|
|
126
|
+
sls deploy function -f ${FUNCTION} --stage ${STAGE} --param="env=${ENVFILE}" --config ${CONFIG}
|
|
127
|
+
else
|
|
128
|
+
sls deploy -f ${FUNCTION} --stage ${STAGE} --env ${ENVFILE} --config ${CONFIG}
|
|
129
|
+
fi
|
|
110
130
|
}
|
|
111
131
|
|
|
112
132
|
function prompt_confirmation_deploy_all ()
|
|
@@ -140,29 +160,50 @@ function prompt_confirmation_deploy_function ()
|
|
|
140
160
|
function deploy_full ()
|
|
141
161
|
{
|
|
142
162
|
echo -e "${YELLOW}Deploying service to ${STAGE}${NC}"
|
|
143
|
-
|
|
163
|
+
if [ ${SERVERLESS_VERSION_NUMBER} -ge ${LATEST_SERVERLESS_VERSION_NUMBER} ]; then
|
|
164
|
+
sls deploy --stage ${STAGE} --param="env=${ENVFILE}" --config ${CONFIG}
|
|
165
|
+
else
|
|
166
|
+
sls deploy --stage ${STAGE} --env ${ENVFILE} --config ${CONFIG}
|
|
167
|
+
fi
|
|
144
168
|
}
|
|
145
169
|
|
|
146
170
|
function invoke_func ()
|
|
147
171
|
{
|
|
148
172
|
echo -e "${YELLOW}Invoking function ${FUNCTION} on ${STAGE}${NC} using ${CONFIG}"
|
|
149
173
|
if [ ${INVOKE_LOCAL} == 1 ]; then
|
|
150
|
-
|
|
174
|
+
if [ ${SERVERLESS_VERSION_NUMBER} -ge ${LATEST_SERVERLESS_VERSION_NUMBER} ]; then
|
|
175
|
+
sls invoke local -f ${FUNCTION} --stage ${STAGE} --param="env=${ENVFILE}" -d ${DATA} -l --config ${CONFIG}
|
|
176
|
+
else
|
|
177
|
+
sls invoke local -f ${FUNCTION} --stage ${STAGE} --env ${ENVFILE} -d ${DATA} -l --config ${CONFIG}
|
|
178
|
+
fi
|
|
179
|
+
|
|
151
180
|
else
|
|
152
|
-
|
|
181
|
+
if [ ${SERVERLESS_VERSION_NUMBER} -ge ${LATEST_SERVERLESS_VERSION_NUMBER} ]; then
|
|
182
|
+
sls invoke -f ${FUNCTION} --stage ${STAGE} --param="env=${ENVFILE}" -d ${DATA} -l --config ${CONFIG}
|
|
183
|
+
else
|
|
184
|
+
sls invoke -f ${FUNCTION} --stage ${STAGE} --env ${ENVFILE} -d ${DATA} -l --config ${CONFIG}
|
|
185
|
+
fi
|
|
153
186
|
fi
|
|
154
187
|
}
|
|
155
188
|
|
|
156
189
|
function log_stream_func ()
|
|
157
190
|
{
|
|
158
191
|
echo -e "${YELLOW}Log Streaming function ${FUNCTION} on ${STAGE}${NC} using ${CONFIG}"
|
|
159
|
-
|
|
192
|
+
if [ ${SERVERLESS_VERSION_NUMBER} -ge ${LATEST_SERVERLESS_VERSION_NUMBER} ]; then
|
|
193
|
+
sls logs -f ${FUNCTION} --stage ${STAGE} --param="env=${ENVFILE}" -t --config ${CONFIG}
|
|
194
|
+
else
|
|
195
|
+
sls logs -f ${FUNCTION} --stage ${STAGE} --env ${ENVFILE} -t --config ${CONFIG}
|
|
196
|
+
fi
|
|
160
197
|
}
|
|
161
198
|
|
|
162
199
|
function build ()
|
|
163
200
|
{
|
|
164
201
|
echo -e "${YELLOW}Building bundle without deployment${NC} using ${CONFIG}"
|
|
165
|
-
|
|
202
|
+
if [ ${SERVERLESS_VERSION_NUMBER} -ge ${LATEST_SERVERLESS_VERSION_NUMBER} ]; then
|
|
203
|
+
sls webpack --stage ${STAGE} --param="env=${ENVFILE}" --config ${CONFIG}
|
|
204
|
+
else
|
|
205
|
+
sls webpack --stage ${STAGE} --env ${ENVFILE} --config ${CONFIG}
|
|
206
|
+
fi
|
|
166
207
|
}
|
|
167
208
|
|
|
168
209
|
function prompt_confirmation_destroy_service ()
|
|
@@ -180,7 +221,11 @@ function prompt_confirmation_destroy_service ()
|
|
|
180
221
|
function destroy_service ()
|
|
181
222
|
{
|
|
182
223
|
echo -e "${YELLOW}Removing service to ${STAGE}${NC}"
|
|
183
|
-
|
|
224
|
+
if [ ${SERVERLESS_VERSION_NUMBER} -ge ${LATEST_SERVERLESS_VERSION_NUMBER} ]; then
|
|
225
|
+
sls remove --stage ${STAGE} --param="env=${ENVFILE}" --config ${CONFIG}
|
|
226
|
+
else
|
|
227
|
+
sls remove --stage ${STAGE} --env ${ENVFILE} --config ${CONFIG}
|
|
228
|
+
fi
|
|
184
229
|
}
|
|
185
230
|
|
|
186
231
|
###############################################################################
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import appConfig from './app';
|
|
3
|
+
import awsConfig from './aws';
|
|
4
|
+
const dynamodbTableAliases =
|
|
5
|
+
((_a = process.env.LESGO_AWS_DYNAMODB_TABLE_ALIASES) === null || _a === void 0
|
|
6
|
+
? void 0
|
|
7
|
+
: _a.split(',')) || [];
|
|
8
|
+
export default {
|
|
9
|
+
region: process.env.LESGO_AWS_DYNAMODB_REGION || awsConfig.region,
|
|
10
|
+
tables: dynamodbTableAliases.map(t => ({
|
|
11
|
+
alias: t,
|
|
12
|
+
name: `${appConfig.stackName}-${t}`,
|
|
13
|
+
})),
|
|
14
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { default as app } from './app';
|
|
2
|
+
export { default as aws } from './aws';
|
|
3
|
+
export { default as basicAuth } from './basicAuth';
|
|
4
|
+
export { default as crypto } from './crypto';
|
|
5
|
+
export { default as dynamodb } from './dynamodb';
|
|
6
|
+
export { default as elasticache } from './elasticache';
|
|
7
|
+
export { default as jwt } from './jwt';
|
|
8
|
+
export { default as rds } from './rds';
|
|
9
|
+
export { default as s3 } from './s3';
|
|
10
|
+
export { default as secretsmanager } from './secretsmanager';
|
|
11
|
+
export { default as sqs } from './sqs';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { default as app } from './app';
|
|
2
|
+
export { default as aws } from './aws';
|
|
3
|
+
export { default as basicAuth } from './basicAuth';
|
|
4
|
+
export { default as crypto } from './crypto';
|
|
5
|
+
export { default as dynamodb } from './dynamodb';
|
|
6
|
+
export { default as elasticache } from './elasticache';
|
|
7
|
+
export { default as jwt } from './jwt';
|
|
8
|
+
export { default as rds } from './rds';
|
|
9
|
+
export { default as s3 } from './s3';
|
|
10
|
+
export { default as secretsmanager } from './secretsmanager';
|
|
11
|
+
export { default as sqs } from './sqs';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const secretKeys = process.env.LESGO_JWT_SECRET_KEYS || '';
|
|
2
|
+
const secrets = secretKeys.split(',').map(key => {
|
|
3
|
+
if (!key.includes(':')) {
|
|
4
|
+
return { keyid: '0', secret: key };
|
|
5
|
+
}
|
|
6
|
+
const [keyid, secret] = key.split(':');
|
|
7
|
+
return { keyid, secret };
|
|
8
|
+
});
|
|
9
|
+
export default {
|
|
10
|
+
algorithm: process.env.LESGO_JWT_ALGORITHM || 'HS256',
|
|
11
|
+
secrets,
|
|
12
|
+
expiresIn: process.env.LESGO_JWT_EXPIRES_IN || '1h',
|
|
13
|
+
issuer: process.env.LESGO_JWT_ISSUER,
|
|
14
|
+
audience: process.env.LESGO_JWT_AUDIENCE,
|
|
15
|
+
validateClaims: process.env.LESGO_JWT_VALIDATE_CLAIMS !== 'false',
|
|
16
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import awsConfig from './aws';
|
|
2
|
+
export default {
|
|
3
|
+
aurora: {
|
|
4
|
+
mysql: {
|
|
5
|
+
region: process.env.LESGO_AWS_RDS_AURORA_MYSQL_REGION || awsConfig.region,
|
|
6
|
+
databaseName: process.env.LESGO_AWS_RDS_AURORA_MYSQL_DB_NAME,
|
|
7
|
+
proxy: {
|
|
8
|
+
dbCredentialsSecretId:
|
|
9
|
+
process.env.LESGO_AWS_RDS_AURORA_MYSQL_PROXY_DB_CREDENTIALS_SECRET_ID,
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import awsConfig from './aws';
|
|
3
|
+
import appConfig from './app';
|
|
4
|
+
const sqsQueueAliases =
|
|
5
|
+
((_a = process.env.LESGO_AWS_SQS_QUEUE_ALIASES) === null || _a === void 0
|
|
6
|
+
? void 0
|
|
7
|
+
: _a.split(',')) || [];
|
|
8
|
+
const region = process.env.LESGO_AWS_SQS_REGION || awsConfig.region;
|
|
9
|
+
export default {
|
|
10
|
+
region: process.env.LESGO_AWS_SQS_REGION || awsConfig.region,
|
|
11
|
+
queues: sqsQueueAliases.map(q => ({
|
|
12
|
+
alias: q,
|
|
13
|
+
name: `${appConfig.stackName}-${q}`,
|
|
14
|
+
url: `https://sqs.${region}.amazonaws.com/${
|
|
15
|
+
awsConfig.accountId
|
|
16
|
+
}/${`${appConfig.stackName}-${q}`}`,
|
|
17
|
+
})),
|
|
18
|
+
};
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
+
import isEmpty from '../utils/isEmpty';
|
|
1
2
|
export default class LesgoException extends Error {
|
|
2
3
|
constructor(
|
|
3
4
|
message,
|
|
4
5
|
errorCode = 'LESGO_EXCEPTION',
|
|
5
6
|
httpStatusCode = 500,
|
|
6
|
-
extra
|
|
7
|
+
extra = {}
|
|
7
8
|
) {
|
|
8
9
|
super();
|
|
9
10
|
this.name = 'LesgoException';
|
|
10
11
|
this.message = message;
|
|
11
12
|
this.statusCode = httpStatusCode;
|
|
12
13
|
this.code = errorCode;
|
|
13
|
-
|
|
14
14
|
Error.captureStackTrace(this, this.constructor);
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
if (!isEmpty(extra)) {
|
|
16
|
+
this.extra = extra;
|
|
17
|
+
}
|
|
17
18
|
}
|
|
18
19
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as LesgoException } from './LesgoException';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as LesgoException } from './LesgoException';
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
var __awaiter =
|
|
2
|
+
(this && this.__awaiter) ||
|
|
3
|
+
function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) {
|
|
5
|
+
return value instanceof P
|
|
6
|
+
? value
|
|
7
|
+
: new P(function (resolve) {
|
|
8
|
+
resolve(value);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
12
|
+
function fulfilled(value) {
|
|
13
|
+
try {
|
|
14
|
+
step(generator.next(value));
|
|
15
|
+
} catch (e) {
|
|
16
|
+
reject(e);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function rejected(value) {
|
|
20
|
+
try {
|
|
21
|
+
step(generator['throw'](value));
|
|
22
|
+
} catch (e) {
|
|
23
|
+
reject(e);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function step(result) {
|
|
27
|
+
result.done
|
|
28
|
+
? resolve(result.value)
|
|
29
|
+
: adopt(result.value).then(fulfilled, rejected);
|
|
30
|
+
}
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
import logger from '../utils/logger';
|
|
35
|
+
const FILE = 'lesgo.middlewares.disconnectMiddleware';
|
|
36
|
+
const disconnectMiddleware = opts => {
|
|
37
|
+
const disconnect = () =>
|
|
38
|
+
__awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
+
var _a;
|
|
40
|
+
logger.debug(`${FILE}::PREPARING_TO_DISCONNECT`);
|
|
41
|
+
const disconnect = [];
|
|
42
|
+
if (
|
|
43
|
+
(opts === null || opts === void 0 ? void 0 : opts.clients) &&
|
|
44
|
+
((_a = opts === null || opts === void 0 ? void 0 : opts.clients) ===
|
|
45
|
+
null || _a === void 0
|
|
46
|
+
? void 0
|
|
47
|
+
: _a.length) > 0
|
|
48
|
+
) {
|
|
49
|
+
opts.clients.forEach(client => {
|
|
50
|
+
disconnect.push(client());
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (disconnect.length > 0) {
|
|
54
|
+
const results = yield Promise.allSettled(disconnect);
|
|
55
|
+
results.forEach(result => {
|
|
56
|
+
if (result.status === 'fulfilled') {
|
|
57
|
+
logger.debug(`${FILE}::DISCONNECT_SUCCESS`, { result });
|
|
58
|
+
} else if (result.status === 'rejected') {
|
|
59
|
+
logger.error(`${FILE}::DISCONNECT_ERROR`, { result });
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
logger.debug(`${FILE}::DISCONNECT_COMPLETED`, opts);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
const disconnectMiddlewareAfter = () =>
|
|
66
|
+
__awaiter(void 0, void 0, void 0, function* () {
|
|
67
|
+
yield disconnect();
|
|
68
|
+
});
|
|
69
|
+
const disconnectMiddlewareOnError = () =>
|
|
70
|
+
__awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
+
yield disconnect();
|
|
72
|
+
});
|
|
73
|
+
return {
|
|
74
|
+
after: disconnectMiddlewareAfter,
|
|
75
|
+
onError: disconnectMiddlewareOnError,
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
export default disconnectMiddleware;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import middy from '@middy/core';
|
|
2
|
+
export interface HttpMiddlewareOptions {
|
|
3
|
+
debugMode?: boolean;
|
|
4
|
+
headers?: Record<string, string>;
|
|
5
|
+
isBase64Encoded?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare const httpMiddleware: (opts?: HttpMiddlewareOptions) => {
|
|
8
|
+
before: (handler: middy.Request) => Promise<void>;
|
|
9
|
+
after: (handler: middy.Request) => Promise<void>;
|
|
10
|
+
onError: (handler: middy.Request) => Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
export default httpMiddleware;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
var __awaiter =
|
|
2
|
+
(this && this.__awaiter) ||
|
|
3
|
+
function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) {
|
|
5
|
+
return value instanceof P
|
|
6
|
+
? value
|
|
7
|
+
: new P(function (resolve) {
|
|
8
|
+
resolve(value);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
12
|
+
function fulfilled(value) {
|
|
13
|
+
try {
|
|
14
|
+
step(generator.next(value));
|
|
15
|
+
} catch (e) {
|
|
16
|
+
reject(e);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function rejected(value) {
|
|
20
|
+
try {
|
|
21
|
+
step(generator['throw'](value));
|
|
22
|
+
} catch (e) {
|
|
23
|
+
reject(e);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function step(result) {
|
|
27
|
+
result.done
|
|
28
|
+
? resolve(result.value)
|
|
29
|
+
: adopt(result.value).then(fulfilled, rejected);
|
|
30
|
+
}
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
import jsonBodyParser from '@middy/http-json-body-parser';
|
|
35
|
+
import eventNormalizer from '@middy/http-event-normalizer';
|
|
36
|
+
import doNotWaitForEmptyEventLoop from '@middy/do-not-wait-for-empty-event-loop';
|
|
37
|
+
import httpHeaderNormalizer from '@middy/http-header-normalizer';
|
|
38
|
+
import httpResponseMiddleware from './httpResponseMiddleware';
|
|
39
|
+
const httpMiddleware = (opts = {}) => {
|
|
40
|
+
const middlewarePackages = [
|
|
41
|
+
doNotWaitForEmptyEventLoop(),
|
|
42
|
+
eventNormalizer(),
|
|
43
|
+
httpHeaderNormalizer(),
|
|
44
|
+
jsonBodyParser({ disableContentTypeError: true }),
|
|
45
|
+
httpResponseMiddleware(opts),
|
|
46
|
+
];
|
|
47
|
+
return {
|
|
48
|
+
before: handler =>
|
|
49
|
+
__awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
+
for (const middleware of middlewarePackages) {
|
|
51
|
+
if (middleware.before) {
|
|
52
|
+
yield middleware.before(handler);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}),
|
|
56
|
+
after: handler =>
|
|
57
|
+
__awaiter(void 0, void 0, void 0, function* () {
|
|
58
|
+
for (const middleware of middlewarePackages) {
|
|
59
|
+
if (middleware.after) {
|
|
60
|
+
yield middleware.after(handler);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}),
|
|
64
|
+
onError: handler =>
|
|
65
|
+
__awaiter(void 0, void 0, void 0, function* () {
|
|
66
|
+
for (const middleware of middlewarePackages) {
|
|
67
|
+
if (middleware.onError) {
|
|
68
|
+
yield middleware.onError(handler);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}),
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
export default httpMiddleware;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import middy from '@middy/core';
|
|
2
|
+
import { HttpMiddlewareOptions } from './httpMiddleware';
|
|
3
|
+
declare const httpResponseMiddleware: (opts?: HttpMiddlewareOptions) => {
|
|
4
|
+
after: (request: middy.Request) => Promise<void>;
|
|
5
|
+
onError: (request: middy.Request) => Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
export default httpResponseMiddleware;
|