@digitraffic/common 2022.11.10-1 → 2022.11.22-1
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/dist/aws/infra/canaries/database-checker.js +4 -3
- package/dist/aws/infra/stack/lambda-configs.js +7 -7
- package/dist/aws/infra/stack/monitoredfunction.js +31 -31
- package/dist/aws/runtime/secrets/dbsecret.js +4 -4
- package/package.json +27 -16
- package/src/aws/infra/canaries/database-checker.ts +11 -13
- package/src/aws/infra/stack/lambda-configs.ts +7 -16
- package/src/aws/runtime/secrets/dbsecret.ts +54 -23
- package/src/aws/runtime/secrets/secret-holder.ts +3 -6
- package/dist/aws/infra/api/integration.d.ts +0 -21
- package/dist/aws/infra/api/integration.js.map +0 -1
- package/dist/aws/infra/api/response.d.ts +0 -22
- package/dist/aws/infra/api/response.js.map +0 -1
- package/dist/aws/infra/api/responses.d.ts +0 -39
- package/dist/aws/infra/api/responses.js.map +0 -1
- package/dist/aws/infra/api/static-integration.d.ts +0 -15
- package/dist/aws/infra/api/static-integration.js.map +0 -1
- package/dist/aws/infra/canaries/canary-alarm.d.ts +0 -6
- package/dist/aws/infra/canaries/canary-alarm.js.map +0 -1
- package/dist/aws/infra/canaries/canary-keys.d.ts +0 -3
- package/dist/aws/infra/canaries/canary-keys.js.map +0 -1
- package/dist/aws/infra/canaries/canary-parameters.d.ts +0 -18
- package/dist/aws/infra/canaries/canary-parameters.js.map +0 -1
- package/dist/aws/infra/canaries/canary-role.d.ts +0 -6
- package/dist/aws/infra/canaries/canary-role.js.map +0 -1
- package/dist/aws/infra/canaries/canary.d.ts +0 -8
- package/dist/aws/infra/canaries/canary.js.map +0 -1
- package/dist/aws/infra/canaries/database-canary.d.ts +0 -18
- package/dist/aws/infra/canaries/database-canary.js.map +0 -1
- package/dist/aws/infra/canaries/database-checker.d.ts +0 -35
- package/dist/aws/infra/canaries/database-checker.js.map +0 -1
- package/dist/aws/infra/canaries/url-canary.d.ts +0 -16
- package/dist/aws/infra/canaries/url-canary.js.map +0 -1
- package/dist/aws/infra/canaries/url-checker.d.ts +0 -46
- package/dist/aws/infra/canaries/url-checker.js.map +0 -1
- package/dist/aws/infra/documentation.d.ts +0 -56
- package/dist/aws/infra/documentation.js.map +0 -1
- package/dist/aws/infra/import-util.d.ts +0 -21
- package/dist/aws/infra/import-util.js.map +0 -1
- package/dist/aws/infra/scheduler.d.ts +0 -12
- package/dist/aws/infra/scheduler.js.map +0 -1
- package/dist/aws/infra/security-rule.d.ts +0 -12
- package/dist/aws/infra/security-rule.js.map +0 -1
- package/dist/aws/infra/sqs-integration.d.ts +0 -7
- package/dist/aws/infra/sqs-integration.js.map +0 -1
- package/dist/aws/infra/sqs-queue.d.ts +0 -16
- package/dist/aws/infra/sqs-queue.js.map +0 -1
- package/dist/aws/infra/stack/lambda-configs.d.ts +0 -72
- package/dist/aws/infra/stack/lambda-configs.js.map +0 -1
- package/dist/aws/infra/stack/monitoredfunction.d.ts +0 -84
- package/dist/aws/infra/stack/monitoredfunction.js.map +0 -1
- package/dist/aws/infra/stack/rest_apis.d.ts +0 -41
- package/dist/aws/infra/stack/rest_apis.js.map +0 -1
- package/dist/aws/infra/stack/stack-checking-aspect.d.ts +0 -21
- package/dist/aws/infra/stack/stack-checking-aspect.js.map +0 -1
- package/dist/aws/infra/stack/stack.d.ts +0 -45
- package/dist/aws/infra/stack/stack.js.map +0 -1
- package/dist/aws/infra/stack/subscription.d.ts +0 -17
- package/dist/aws/infra/stack/subscription.js.map +0 -1
- package/dist/aws/infra/stacks/db-dns-stack.d.ts +0 -11
- package/dist/aws/infra/stacks/db-dns-stack.js.map +0 -1
- package/dist/aws/infra/stacks/db-proxy-stack.d.ts +0 -19
- package/dist/aws/infra/stacks/db-proxy-stack.js.map +0 -1
- package/dist/aws/infra/stacks/db-stack.d.ts +0 -31
- package/dist/aws/infra/stacks/db-stack.js.map +0 -1
- package/dist/aws/infra/stacks/intra-stack-configuration.d.ts +0 -5
- package/dist/aws/infra/stacks/intra-stack-configuration.js.map +0 -1
- package/dist/aws/infra/stacks/network-stack.d.ts +0 -12
- package/dist/aws/infra/stacks/network-stack.js.map +0 -1
- package/dist/aws/infra/usage-plans.d.ts +0 -16
- package/dist/aws/infra/usage-plans.js.map +0 -1
- package/dist/aws/runtime/apikey.d.ts +0 -2
- package/dist/aws/runtime/apikey.js.map +0 -1
- package/dist/aws/runtime/digitraffic-integration-response.d.ts +0 -8
- package/dist/aws/runtime/digitraffic-integration-response.js.map +0 -1
- package/dist/aws/runtime/environment.d.ts +0 -1
- package/dist/aws/runtime/environment.js.map +0 -1
- package/dist/aws/runtime/messaging.d.ts +0 -10
- package/dist/aws/runtime/messaging.js.map +0 -1
- package/dist/aws/runtime/s3.d.ts +0 -2
- package/dist/aws/runtime/s3.js.map +0 -1
- package/dist/aws/runtime/secrets/dbsecret.d.ts +0 -54
- package/dist/aws/runtime/secrets/dbsecret.js.map +0 -1
- package/dist/aws/runtime/secrets/proxy-holder.d.ts +0 -9
- package/dist/aws/runtime/secrets/proxy-holder.js.map +0 -1
- package/dist/aws/runtime/secrets/rds-holder.d.ts +0 -9
- package/dist/aws/runtime/secrets/rds-holder.js.map +0 -1
- package/dist/aws/runtime/secrets/secret-holder.d.ts +0 -26
- package/dist/aws/runtime/secrets/secret-holder.js.map +0 -1
- package/dist/aws/runtime/secrets/secret.d.ts +0 -8
- package/dist/aws/runtime/secrets/secret.js.map +0 -1
- package/dist/aws/types/errors.d.ts +0 -8
- package/dist/aws/types/errors.js.map +0 -1
- package/dist/aws/types/lambda-response.d.ts +0 -13
- package/dist/aws/types/lambda-response.js.map +0 -1
- package/dist/aws/types/mediatypes.d.ts +0 -11
- package/dist/aws/types/mediatypes.js.map +0 -1
- package/dist/aws/types/model-with-reference.d.ts +0 -7
- package/dist/aws/types/model-with-reference.js.map +0 -1
- package/dist/aws/types/proxytypes.d.ts +0 -26
- package/dist/aws/types/proxytypes.js.map +0 -1
- package/dist/aws/types/tags.d.ts +0 -2
- package/dist/aws/types/tags.js.map +0 -1
- package/dist/database/cached.d.ts +0 -7
- package/dist/database/cached.js.map +0 -1
- package/dist/database/database.d.ts +0 -19
- package/dist/database/database.js.map +0 -1
- package/dist/database/last-updated.d.ts +0 -16
- package/dist/database/last-updated.js.map +0 -1
- package/dist/database/models.d.ts +0 -6
- package/dist/database/models.js.map +0 -1
- package/dist/marine/id_utils.d.ts +0 -3
- package/dist/marine/id_utils.js.map +0 -1
- package/dist/marine/rtz.d.ts +0 -48
- package/dist/marine/rtz.js.map +0 -1
- package/dist/test/asserter.d.ts +0 -11
- package/dist/test/asserter.js.map +0 -1
- package/dist/test/db-testutils.d.ts +0 -3
- package/dist/test/db-testutils.js.map +0 -1
- package/dist/test/httpserver.d.ts +0 -19
- package/dist/test/httpserver.js.map +0 -1
- package/dist/test/secret.d.ts +0 -3
- package/dist/test/secret.js.map +0 -1
- package/dist/test/secrets-manager.d.ts +0 -9
- package/dist/test/secrets-manager.js.map +0 -1
- package/dist/test/testutils.d.ts +0 -12
- package/dist/test/testutils.js.map +0 -1
- package/dist/types/either.d.ts +0 -9
- package/dist/types/either.js.map +0 -1
- package/dist/types/input-error.d.ts +0 -2
- package/dist/types/input-error.js.map +0 -1
- package/dist/types/language.d.ts +0 -5
- package/dist/types/language.js.map +0 -1
- package/dist/types/traffictype.d.ts +0 -8
- package/dist/types/traffictype.js.map +0 -1
- package/dist/types/validator.d.ts +0 -4
- package/dist/types/validator.js.map +0 -1
- package/dist/utils/api-model.d.ts +0 -87
- package/dist/utils/api-model.js.map +0 -1
- package/dist/utils/base64.d.ts +0 -12
- package/dist/utils/base64.js.map +0 -1
- package/dist/utils/date-utils.d.ts +0 -17
- package/dist/utils/date-utils.js.map +0 -1
- package/dist/utils/geojson-types.d.ts +0 -14
- package/dist/utils/geojson-types.js.map +0 -1
- package/dist/utils/geometry.d.ts +0 -36
- package/dist/utils/geometry.js.map +0 -1
- package/dist/utils/retry.d.ts +0 -13
- package/dist/utils/retry.js.map +0 -1
- package/dist/utils/slack.d.ts +0 -5
- package/dist/utils/slack.js.map +0 -1
- package/dist/utils/utils.d.ts +0 -46
- package/dist/utils/utils.js.map +0 -1
@@ -17,7 +17,8 @@ class DatabaseCheck {
|
|
17
17
|
class CountDatabaseCheck extends DatabaseCheck {
|
18
18
|
constructor(name, sql, minCount, maxCount) {
|
19
19
|
super(name, sql);
|
20
|
-
if (!sql.toLowerCase().includes("select
|
20
|
+
if (!sql.toLowerCase().includes("select") ||
|
21
|
+
!sql.toLowerCase().includes("count")) {
|
21
22
|
throw new Error("sql must contain select count(*)");
|
22
23
|
}
|
23
24
|
if (minCount == null && maxCount == null) {
|
@@ -51,12 +52,12 @@ const stepConfig = {
|
|
51
52
|
};
|
52
53
|
/**
|
53
54
|
* Checker for sql that checks the count. Meaning that the
|
54
|
-
* sql must be structured as select(*) from table where something.
|
55
|
+
* sql must be structured as "select count(*) from <table> where <something>".
|
55
56
|
*/
|
56
57
|
class DatabaseCountChecker {
|
57
58
|
constructor(credentialsFunction) {
|
58
|
-
this.credentialsFunction = credentialsFunction;
|
59
59
|
this.checks = [];
|
60
|
+
this.credentialsFunction = credentialsFunction;
|
60
61
|
synthetics.getConfiguration().disableRequestMetrics();
|
61
62
|
synthetics.getConfiguration().withFailedCanaryMetric(true);
|
62
63
|
}
|
@@ -22,7 +22,7 @@ function databaseFunctionProps(stack, environment, lambdaName, simpleLambdaName,
|
|
22
22
|
exports.databaseFunctionProps = databaseFunctionProps;
|
23
23
|
function lambdaFunctionProps(stack, environment, lambdaName, simpleLambdaName, config) {
|
24
24
|
return {
|
25
|
-
runtime: config?.runtime ?? aws_lambda_1.Runtime.
|
25
|
+
runtime: config?.runtime ?? aws_lambda_1.Runtime.NODEJS_16_X,
|
26
26
|
architecture: config?.architecture ?? aws_lambda_1.Architecture.ARM_64,
|
27
27
|
memorySize: config?.memorySize ?? 128,
|
28
28
|
functionName: lambdaName,
|
@@ -51,14 +51,14 @@ function getAssetCode(simpleLambdaName, isSingleLambda) {
|
|
51
51
|
*/
|
52
52
|
function dbLambdaConfiguration(vpc, lambdaDbSg, props, config) {
|
53
53
|
return {
|
54
|
-
runtime: props.runtime
|
55
|
-
memorySize: props.memorySize
|
54
|
+
runtime: props.runtime ?? aws_lambda_1.Runtime.NODEJS_16_X,
|
55
|
+
memorySize: props.memorySize ?? config.memorySize ?? 1024,
|
56
56
|
functionName: config.functionName,
|
57
57
|
code: config.code,
|
58
58
|
role: config.role,
|
59
59
|
handler: config.handler,
|
60
|
-
timeout: aws_cdk_lib_1.Duration.seconds(config.timeout
|
61
|
-
environment: config.environment
|
60
|
+
timeout: aws_cdk_lib_1.Duration.seconds(config.timeout ?? props.defaultLambdaDurationSeconds ?? 60),
|
61
|
+
environment: config.environment ?? {
|
62
62
|
DB_USER: props.dbProps?.username ?? "",
|
63
63
|
DB_PASS: props.dbProps?.password ?? "",
|
64
64
|
DB_URI: (config.readOnly
|
@@ -71,13 +71,13 @@ function dbLambdaConfiguration(vpc, lambdaDbSg, props, config) {
|
|
71
71
|
subnets: vpc.privateSubnets,
|
72
72
|
},
|
73
73
|
securityGroups: [lambdaDbSg],
|
74
|
-
reservedConcurrentExecutions: config.reservedConcurrentExecutions
|
74
|
+
reservedConcurrentExecutions: config.reservedConcurrentExecutions ?? 3,
|
75
75
|
};
|
76
76
|
}
|
77
77
|
exports.dbLambdaConfiguration = dbLambdaConfiguration;
|
78
78
|
function defaultLambdaConfiguration(config) {
|
79
79
|
const props = {
|
80
|
-
runtime: aws_lambda_1.Runtime.
|
80
|
+
runtime: aws_lambda_1.Runtime.NODEJS_16_X,
|
81
81
|
memorySize: config.memorySize ?? 128,
|
82
82
|
functionName: config.functionName,
|
83
83
|
handler: config.handler,
|
@@ -11,6 +11,37 @@ const subscription_1 = require("../stack/subscription");
|
|
11
11
|
* Creates a Lambda function that monitors default CloudWatch Lambda metrics with CloudWatch Alarms.
|
12
12
|
*/
|
13
13
|
class MonitoredFunction extends aws_lambda_1.Function {
|
14
|
+
/**
|
15
|
+
* Create new MonitoredFunction. Use topics from given DigitrafficStack.
|
16
|
+
*
|
17
|
+
* @param stack DigitrafficStack
|
18
|
+
* @param id Lambda construct Id
|
19
|
+
* @param functionProps Lambda function properties
|
20
|
+
* @param props Monitored function properties
|
21
|
+
*/
|
22
|
+
static create(stack, id, functionProps, props) {
|
23
|
+
if (props === MonitoredFunction.DISABLE_ALARMS &&
|
24
|
+
stack.configuration.production) {
|
25
|
+
throw new Error(`Function ${functionProps.functionName} has DISABLE_ALARMS. Remove before installing to production or define your own properties!`);
|
26
|
+
}
|
27
|
+
return new MonitoredFunction(stack, id, functionProps, stack.alarmTopic, stack.warningTopic, stack.configuration.production, stack.configuration.trafficType, props);
|
28
|
+
}
|
29
|
+
/**
|
30
|
+
* Create new MonitoredFunction. Use topics from given DigitrafficStack. Generate names from given name and configuration shortName.
|
31
|
+
*
|
32
|
+
* For example, shortName FOO and given name update-things will create function FOO-UpdateThings and use code from lambda/update-things/update-things.ts method handler.
|
33
|
+
*
|
34
|
+
* @param stack DigitrafficStack
|
35
|
+
* @param name param-case name
|
36
|
+
* @param environment Lambda environment
|
37
|
+
* @param functionParameters Lambda function parameters
|
38
|
+
*/
|
39
|
+
static createV2(stack, name, environment, functionParameters) {
|
40
|
+
const functionName = functionParameters?.functionName ||
|
41
|
+
`${stack.configuration.shortName}-${(0, change_case_1.pascalCase)(name)}`;
|
42
|
+
const functionProps = (0, lambda_configs_1.databaseFunctionProps)(stack, environment, functionName, name, functionParameters);
|
43
|
+
return MonitoredFunction.create(stack, functionName, functionProps, functionParameters);
|
44
|
+
}
|
14
45
|
/**
|
15
46
|
* @param scope Stack
|
16
47
|
* @param id Lambda construct Id
|
@@ -48,37 +79,6 @@ class MonitoredFunction extends aws_lambda_1.Function {
|
|
48
79
|
this.createAlarm(scope, this.metricThrottles(), "Throttles", "Throttles alarm", "Has throttled", trafficType, this.getAlarmActionForEnv(alarmSnsAction, warningSnsAction, production), 0, 1, 1, aws_cloudwatch_1.ComparisonOperator.GREATER_THAN_THRESHOLD, props?.throttleAlarmProps);
|
49
80
|
}
|
50
81
|
}
|
51
|
-
/**
|
52
|
-
* Create new MonitoredFunction. Use topics from given DigitrafficStack.
|
53
|
-
*
|
54
|
-
* @param stack DigitrafficStack
|
55
|
-
* @param id Lambda construct Id
|
56
|
-
* @param functionProps Lambda function properties
|
57
|
-
* @param props Monitored function properties
|
58
|
-
*/
|
59
|
-
static create(stack, id, functionProps, props) {
|
60
|
-
if (props === MonitoredFunction.DISABLE_ALARMS &&
|
61
|
-
stack.configuration.production) {
|
62
|
-
throw new Error(`Function ${functionProps.functionName} has DISABLE_ALARMS. Remove before installing to production or define your own properties!`);
|
63
|
-
}
|
64
|
-
return new MonitoredFunction(stack, id, functionProps, stack.alarmTopic, stack.warningTopic, stack.configuration.production, stack.configuration.trafficType, props);
|
65
|
-
}
|
66
|
-
/**
|
67
|
-
* Create new MonitoredFunction. Use topics from given DigitrafficStack. Generate names from given name and configuration shortName.
|
68
|
-
*
|
69
|
-
* For example, shortName FOO and given name update-things will create function FOO-UpdateThings and use code from lambda/update-things/update-things.ts method handler.
|
70
|
-
*
|
71
|
-
* @param stack DigitrafficStack
|
72
|
-
* @param name param-case name
|
73
|
-
* @param environment Lambda environment
|
74
|
-
* @param functionParameters Lambda function parameters
|
75
|
-
*/
|
76
|
-
static createV2(stack, name, environment, functionParameters) {
|
77
|
-
const functionName = functionParameters?.functionName ||
|
78
|
-
`${stack.configuration.shortName}-${(0, change_case_1.pascalCase)(name)}`;
|
79
|
-
const functionProps = (0, lambda_configs_1.databaseFunctionProps)(stack, environment, functionName, name, functionParameters);
|
80
|
-
return MonitoredFunction.create(stack, functionName, functionProps, functionParameters);
|
81
|
-
}
|
82
82
|
createAlarm(stack, metric, alarmId, alarmName, alarmDescription, trafficType, alarmSnsAction, threshold, evaluationPeriods, datapointsToAlarm, comparisonOperator, alarmProps) {
|
83
83
|
metric
|
84
84
|
.createAlarm(stack, `${this.node.id}-${alarmId}`, {
|
@@ -33,7 +33,7 @@ function setDbSecret(secret) {
|
|
33
33
|
// cached at Lambda container level
|
34
34
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
35
35
|
let cachedSecret;
|
36
|
-
const missingSecretErrorText =
|
36
|
+
const missingSecretErrorText = "Missing or empty secretId";
|
37
37
|
/**
|
38
38
|
* Run the given function with secret retrieved from Secrets Manager. Also injects database-credentials into environment.
|
39
39
|
*
|
@@ -75,7 +75,7 @@ async function withDbSecret(secretId, fn, options) {
|
|
75
75
|
return fn(cachedSecret);
|
76
76
|
}
|
77
77
|
catch (error) {
|
78
|
-
console.error(
|
78
|
+
console.error("method=withDbSecret Caught an error, refreshing secret", error);
|
79
79
|
// try to refetch secret in case it has changed
|
80
80
|
await (0, secret_1.withSecret)(secretId, (fetchedSecret) => {
|
81
81
|
setDbSecret(fetchedSecret);
|
@@ -86,10 +86,10 @@ async function withDbSecret(secretId, fn, options) {
|
|
86
86
|
}
|
87
87
|
exports.withDbSecret = withDbSecret;
|
88
88
|
function checkExpectedSecretKeys(keys, secret) {
|
89
|
-
const missingKeys = keys.filter(key => !(key in secret));
|
89
|
+
const missingKeys = keys.filter((key) => !(key in secret));
|
90
90
|
if (missingKeys.length) {
|
91
91
|
console.error(`method=checkExpectedSecretKeys secret didn't contain the key(s) ${missingKeys}`);
|
92
|
-
throw new Error(
|
92
|
+
throw new Error("Expected keys were not found");
|
93
93
|
}
|
94
94
|
}
|
95
95
|
exports.checkExpectedSecretKeys = checkExpectedSecretKeys;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@digitraffic/common",
|
3
|
-
"version": "2022.11.
|
3
|
+
"version": "2022.11.22-1",
|
4
4
|
"description": "",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -10,36 +10,40 @@
|
|
10
10
|
"node": ">=14 <17",
|
11
11
|
"yarn": ">1.2 <2"
|
12
12
|
},
|
13
|
-
"scripts": {
|
14
|
-
"build": "tsc",
|
15
|
-
"lint": "eslint --cache .",
|
16
|
-
"eslint-report": "eslint . --format html",
|
17
|
-
"clean": "rimraf dist output",
|
18
|
-
"test": "jest --detectOpenHandles --forceExit --coverage --coverageDirectory=output/coverage/jest",
|
19
|
-
"prepare": "husky install",
|
20
|
-
"prepublishOnly": "yarn clean && yarn build && yarn test"
|
21
|
-
},
|
22
13
|
"license": "EUPL-1.2",
|
23
14
|
"private": false,
|
24
15
|
"files": [
|
25
16
|
"dist/**/*.js",
|
26
17
|
"src/**/*.ts"
|
27
18
|
],
|
28
|
-
"
|
19
|
+
"peerDependencies": {
|
20
|
+
"pg-promise": "^10.12.0",
|
21
|
+
"spex": "^3.0.0",
|
22
|
+
"constructs": "^10.1.131",
|
29
23
|
"@aws-cdk/aws-synthetics-alpha": "2.50.0-alpha.0",
|
30
24
|
"@types/geojson": "^7946.0.10",
|
31
25
|
"aws-cdk-lib": "2.50.0",
|
32
26
|
"aws-sdk": "2.1241.0",
|
33
27
|
"axios": "^0.21.1",
|
34
28
|
"change-case": "4.1.2",
|
35
|
-
"constructs": "10.1.131",
|
36
29
|
"geojson-validation": "^1.0.2",
|
37
30
|
"moment": "^2.29.4",
|
38
31
|
"node-ttl": "^0.2.0",
|
39
|
-
"pg-native": "^3.0.1"
|
40
|
-
"pg-promise": "^10.12.0"
|
32
|
+
"pg-native": "^3.0.1"
|
41
33
|
},
|
42
34
|
"devDependencies": {
|
35
|
+
"@aws-cdk/aws-synthetics-alpha": "2.50.0-alpha.0",
|
36
|
+
"@types/geojson": "^7946.0.10",
|
37
|
+
"aws-cdk-lib": "2.50.0",
|
38
|
+
"aws-sdk": "2.1241.0",
|
39
|
+
"axios": "^0.21.1",
|
40
|
+
"change-case": "4.1.2",
|
41
|
+
"constructs": "10.1.131",
|
42
|
+
"geojson-validation": "^1.0.2",
|
43
|
+
"moment": "^2.29.4",
|
44
|
+
"node-ttl": "^0.2.0",
|
45
|
+
"pg-native": "^3.0.1",
|
46
|
+
"pg-promise": "^10.12.0",
|
43
47
|
"@types/aws-lambda": "^8.10.106",
|
44
48
|
"@types/jest": "^29.0.3",
|
45
49
|
"@types/node": "^18.7.23",
|
@@ -58,7 +62,7 @@
|
|
58
62
|
"rimraf": "^3.0.2",
|
59
63
|
"sinon": "^14.0.0",
|
60
64
|
"ts-jest": "^29.0.2",
|
61
|
-
"typescript": "^4.
|
65
|
+
"typescript": "^4.7.4"
|
62
66
|
},
|
63
67
|
"externals": [
|
64
68
|
"aws-sdk",
|
@@ -66,5 +70,12 @@
|
|
66
70
|
],
|
67
71
|
"lint-staged": {
|
68
72
|
"*.{js,ts,css,md,yml,yaml,json}": "prettier --write"
|
73
|
+
},
|
74
|
+
"scripts": {
|
75
|
+
"build": "tsc",
|
76
|
+
"lint": "eslint --cache .",
|
77
|
+
"eslint-report": "eslint . --format html",
|
78
|
+
"clean": "rimraf dist output",
|
79
|
+
"test": "jest --detectOpenHandles --forceExit --coverage --coverageDirectory=output/coverage/jest"
|
69
80
|
}
|
70
|
-
}
|
81
|
+
}
|
@@ -2,6 +2,7 @@ import { DTDatabase, inDatabaseReadonly } from "../../../database/database";
|
|
2
2
|
import { ProxyHolder } from "../../runtime/secrets/proxy-holder";
|
3
3
|
import { RdsHolder } from "../../runtime/secrets/rds-holder";
|
4
4
|
import { getEnvVariable } from "../../../utils/utils";
|
5
|
+
import { Countable } from "../../../database/models";
|
5
6
|
|
6
7
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
7
8
|
const synthetics = require("Synthetics");
|
@@ -20,11 +21,7 @@ abstract class DatabaseCheck<T> {
|
|
20
21
|
abstract check(value: T): void;
|
21
22
|
}
|
22
23
|
|
23
|
-
|
24
|
-
count: number;
|
25
|
-
}
|
26
|
-
|
27
|
-
class CountDatabaseCheck extends DatabaseCheck<CountResponse> {
|
24
|
+
class CountDatabaseCheck extends DatabaseCheck<Countable> {
|
28
25
|
readonly minCount: number | null;
|
29
26
|
readonly maxCount: number | null;
|
30
27
|
|
@@ -36,7 +33,10 @@ class CountDatabaseCheck extends DatabaseCheck<CountResponse> {
|
|
36
33
|
) {
|
37
34
|
super(name, sql);
|
38
35
|
|
39
|
-
if (
|
36
|
+
if (
|
37
|
+
!sql.toLowerCase().includes("select") ||
|
38
|
+
!sql.toLowerCase().includes("count")
|
39
|
+
) {
|
40
40
|
throw new Error("sql must contain select count(*)");
|
41
41
|
}
|
42
42
|
|
@@ -48,7 +48,7 @@ class CountDatabaseCheck extends DatabaseCheck<CountResponse> {
|
|
48
48
|
this.maxCount = maxCount;
|
49
49
|
}
|
50
50
|
|
51
|
-
check(value:
|
51
|
+
check(value: Countable) {
|
52
52
|
if ("count" in value) {
|
53
53
|
if (this.minCount && value.count < this.minCount) {
|
54
54
|
this.failed = true;
|
@@ -79,18 +79,16 @@ const stepConfig = {
|
|
79
79
|
|
80
80
|
/**
|
81
81
|
* Checker for sql that checks the count. Meaning that the
|
82
|
-
* sql must be structured as select(*) from table where something.
|
82
|
+
* sql must be structured as "select count(*) from <table> where <something>".
|
83
83
|
*/
|
84
84
|
export class DatabaseCountChecker {
|
85
|
-
credentialsFunction: () => Promise<void>;
|
86
|
-
checks: DatabaseCheck<
|
85
|
+
readonly credentialsFunction: () => Promise<void>;
|
86
|
+
readonly checks: DatabaseCheck<Countable>[] = [];
|
87
87
|
|
88
88
|
private constructor(credentialsFunction: () => Promise<void>) {
|
89
89
|
this.credentialsFunction = credentialsFunction;
|
90
|
-
this.checks = [];
|
91
90
|
|
92
91
|
synthetics.getConfiguration().disableRequestMetrics();
|
93
|
-
|
94
92
|
synthetics.getConfiguration().withFailedCanaryMetric(true);
|
95
93
|
}
|
96
94
|
|
@@ -143,7 +141,7 @@ export class DatabaseCountChecker {
|
|
143
141
|
for (const check of this.checks) {
|
144
142
|
console.info("canary checking sql " + check.sql);
|
145
143
|
|
146
|
-
const value = await db.one<
|
144
|
+
const value = await db.one<Countable>(check.sql);
|
147
145
|
const checkFunction = () => {
|
148
146
|
check.check(value);
|
149
147
|
};
|
@@ -76,7 +76,7 @@ export function lambdaFunctionProps(
|
|
76
76
|
config?: Partial<FunctionParameters>
|
77
77
|
): FunctionProps {
|
78
78
|
return {
|
79
|
-
runtime: config?.runtime ?? Runtime.
|
79
|
+
runtime: config?.runtime ?? Runtime.NODEJS_16_X,
|
80
80
|
architecture: config?.architecture ?? Architecture.ARM_64,
|
81
81
|
memorySize: config?.memorySize ?? 128,
|
82
82
|
functionName: lambdaName,
|
@@ -115,16 +115,16 @@ export function dbLambdaConfiguration(
|
|
115
115
|
config: FunctionParameters
|
116
116
|
): FunctionProps {
|
117
117
|
return {
|
118
|
-
runtime: props.runtime
|
119
|
-
memorySize: props.memorySize
|
118
|
+
runtime: props.runtime ?? Runtime.NODEJS_16_X,
|
119
|
+
memorySize: props.memorySize ?? config.memorySize ?? 1024,
|
120
120
|
functionName: config.functionName,
|
121
121
|
code: config.code,
|
122
122
|
role: config.role,
|
123
123
|
handler: config.handler,
|
124
124
|
timeout: Duration.seconds(
|
125
|
-
config.timeout
|
125
|
+
config.timeout ?? props.defaultLambdaDurationSeconds ?? 60
|
126
126
|
),
|
127
|
-
environment: config.environment
|
127
|
+
environment: config.environment ?? {
|
128
128
|
DB_USER: props.dbProps?.username ?? "",
|
129
129
|
DB_PASS: props.dbProps?.password ?? "",
|
130
130
|
DB_URI:
|
@@ -138,7 +138,7 @@ export function dbLambdaConfiguration(
|
|
138
138
|
subnets: vpc.privateSubnets,
|
139
139
|
},
|
140
140
|
securityGroups: [lambdaDbSg],
|
141
|
-
reservedConcurrentExecutions: config.reservedConcurrentExecutions
|
141
|
+
reservedConcurrentExecutions: config.reservedConcurrentExecutions ?? 3,
|
142
142
|
};
|
143
143
|
}
|
144
144
|
|
@@ -146,7 +146,7 @@ export function defaultLambdaConfiguration(
|
|
146
146
|
config: FunctionParameters
|
147
147
|
): FunctionProps {
|
148
148
|
const props: FunctionProps = {
|
149
|
-
runtime: Runtime.
|
149
|
+
runtime: Runtime.NODEJS_16_X,
|
150
150
|
memorySize: config.memorySize ?? 128,
|
151
151
|
functionName: config.functionName,
|
152
152
|
handler: config.handler,
|
@@ -191,15 +191,6 @@ export interface FunctionParameters {
|
|
191
191
|
}
|
192
192
|
|
193
193
|
export type MonitoredFunctionParameters = FunctionParameters & {
|
194
|
-
readonly memorySize?: number;
|
195
|
-
readonly timeout?: number;
|
196
|
-
readonly functionName?: string;
|
197
|
-
readonly reservedConcurrentExecutions?: number;
|
198
|
-
readonly role?: Role;
|
199
|
-
readonly runtime?: Runtime;
|
200
|
-
readonly architecture?: Architecture;
|
201
|
-
readonly singleLambda?: boolean;
|
202
|
-
|
203
194
|
readonly durationAlarmProps?: MonitoredFunctionAlarmProps;
|
204
195
|
readonly durationWarningProps?: MonitoredFunctionAlarmProps;
|
205
196
|
readonly errorAlarmProps?: MonitoredFunctionAlarmProps;
|
@@ -1,18 +1,24 @@
|
|
1
|
-
import {withSecret, withSecretAndPrefix} from "./secret";
|
1
|
+
import { GenericSecret, withSecret, withSecretAndPrefix } from "./secret";
|
2
2
|
|
3
3
|
export type DbSecret = {
|
4
|
-
readonly username: string
|
5
|
-
readonly password: string
|
6
|
-
readonly host: string
|
7
|
-
readonly ro_host: string
|
4
|
+
readonly username: string;
|
5
|
+
readonly password: string;
|
6
|
+
readonly host: string;
|
7
|
+
readonly ro_host: string;
|
8
8
|
};
|
9
9
|
|
10
10
|
export enum RdsProxySecretKey {
|
11
|
-
username = "username",
|
11
|
+
username = "username",
|
12
|
+
password = "password",
|
13
|
+
proxy_host = "proxy_host",
|
14
|
+
proxy_ro_host = "proxy_ro_host",
|
12
15
|
}
|
13
16
|
|
14
17
|
export enum RdsSecretKey {
|
15
|
-
username = "username",
|
18
|
+
username = "username",
|
19
|
+
password = "password",
|
20
|
+
host = "host",
|
21
|
+
ro_host = "ro_host",
|
16
22
|
}
|
17
23
|
|
18
24
|
export type RdsProxySecret = Record<RdsProxySecretKey, string>;
|
@@ -37,7 +43,7 @@ function setDbSecret(secret: DbSecret) {
|
|
37
43
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
38
44
|
let cachedSecret: any;
|
39
45
|
|
40
|
-
const missingSecretErrorText =
|
46
|
+
const missingSecretErrorText = "Missing or empty secretId";
|
41
47
|
|
42
48
|
/**
|
43
49
|
* You can give the following options for retrieving a secret:
|
@@ -48,13 +54,22 @@ const missingSecretErrorText = 'Missing or empty secretId';
|
|
48
54
|
|
49
55
|
*/
|
50
56
|
export type SecretOptions = {
|
51
|
-
readonly expectedKeys?: string[]
|
52
|
-
readonly prefix?: string
|
53
|
-
}
|
57
|
+
readonly expectedKeys?: string[];
|
58
|
+
readonly prefix?: string;
|
59
|
+
};
|
54
60
|
|
55
|
-
export type SecretToPromiseFunction<Secret, Response = void> = (
|
56
|
-
|
57
|
-
|
61
|
+
export type SecretToPromiseFunction<Secret, Response = void> = (
|
62
|
+
secret: Secret
|
63
|
+
) => Promise<Response> | void;
|
64
|
+
export type SecretFunction<Secret, Response = void> = (
|
65
|
+
secretId: string,
|
66
|
+
fn: SecretToPromiseFunction<Secret, Response>,
|
67
|
+
options?: SecretOptions
|
68
|
+
) => Promise<Response | void>;
|
69
|
+
export type EmptySecretFunction<Response = void> = SecretFunction<
|
70
|
+
DbSecret,
|
71
|
+
Response
|
72
|
+
>;
|
58
73
|
|
59
74
|
/**
|
60
75
|
* Run the given function with secret retrieved from Secrets Manager. Also injects database-credentials into environment.
|
@@ -66,7 +81,11 @@ export type EmptySecretFunction<Response = void> = SecretFunction<DbSecret, Resp
|
|
66
81
|
* @param {function} fn
|
67
82
|
* @param {SecretOptions} options
|
68
83
|
*/
|
69
|
-
export async function withDbSecret<Secret, Response>(
|
84
|
+
export async function withDbSecret<Secret, Response>(
|
85
|
+
secretId: string,
|
86
|
+
fn: SecretToPromiseFunction<Secret, Response>,
|
87
|
+
options?: SecretOptions
|
88
|
+
): Promise<Response | void> {
|
70
89
|
if (!secretId) {
|
71
90
|
console.error(missingSecretErrorText);
|
72
91
|
return Promise.reject(missingSecretErrorText);
|
@@ -81,9 +100,13 @@ export async function withDbSecret<Secret, Response>(secretId: string, fn: Secre
|
|
81
100
|
});
|
82
101
|
|
83
102
|
// then actual secret
|
84
|
-
await withSecretAndPrefix(
|
85
|
-
|
86
|
-
|
103
|
+
await withSecretAndPrefix(
|
104
|
+
secretId,
|
105
|
+
options.prefix,
|
106
|
+
(fetchedSecret: Secret) => {
|
107
|
+
cachedSecret = fetchedSecret;
|
108
|
+
}
|
109
|
+
);
|
87
110
|
} else {
|
88
111
|
await withSecret(secretId, (fetchedSecret: DbSecret) => {
|
89
112
|
setDbSecret(fetchedSecret);
|
@@ -97,7 +120,10 @@ export async function withDbSecret<Secret, Response>(secretId: string, fn: Secre
|
|
97
120
|
}
|
98
121
|
return fn(cachedSecret);
|
99
122
|
} catch (error) {
|
100
|
-
console.error(
|
123
|
+
console.error(
|
124
|
+
"method=withDbSecret Caught an error, refreshing secret",
|
125
|
+
error
|
126
|
+
);
|
101
127
|
// try to refetch secret in case it has changed
|
102
128
|
await withSecret(secretId, (fetchedSecret: DbSecret) => {
|
103
129
|
setDbSecret(fetchedSecret);
|
@@ -107,10 +133,15 @@ export async function withDbSecret<Secret, Response>(secretId: string, fn: Secre
|
|
107
133
|
}
|
108
134
|
}
|
109
135
|
|
110
|
-
export function checkExpectedSecretKeys<Secret>(
|
111
|
-
|
136
|
+
export function checkExpectedSecretKeys<Secret extends GenericSecret>(
|
137
|
+
keys: string[],
|
138
|
+
secret: Secret
|
139
|
+
) {
|
140
|
+
const missingKeys = keys.filter((key) => !(key in secret));
|
112
141
|
if (missingKeys.length) {
|
113
|
-
console.error(
|
114
|
-
|
142
|
+
console.error(
|
143
|
+
`method=checkExpectedSecretKeys secret didn't contain the key(s) ${missingKeys}`
|
144
|
+
);
|
145
|
+
throw new Error("Expected keys were not found");
|
115
146
|
}
|
116
147
|
}
|
@@ -23,7 +23,7 @@ const DEFAULT_CONFIGURATION = {
|
|
23
23
|
*
|
24
24
|
* Supports setting the database environment paramaters from the secret too.
|
25
25
|
*/
|
26
|
-
export class SecretHolder<Secret> {
|
26
|
+
export class SecretHolder<Secret extends GenericSecret> {
|
27
27
|
private readonly secretId: string;
|
28
28
|
private readonly prefix: string;
|
29
29
|
private readonly expectedKeys: string[];
|
@@ -51,7 +51,7 @@ export class SecretHolder<Secret> {
|
|
51
51
|
this.secretCache.push(DEFAULT_SECRET_KEY, secretValue);
|
52
52
|
}
|
53
53
|
|
54
|
-
public static create<S>(
|
54
|
+
public static create<S extends GenericSecret>(
|
55
55
|
prefix = DEFAULT_PREFIX,
|
56
56
|
expectedKeys: string[] = []
|
57
57
|
) {
|
@@ -67,10 +67,7 @@ export class SecretHolder<Secret> {
|
|
67
67
|
const parsedSecret =
|
68
68
|
this.prefix === DEFAULT_PREFIX
|
69
69
|
? secret
|
70
|
-
: this.parseSecret(
|
71
|
-
secret as unknown as GenericSecret,
|
72
|
-
`${this.prefix}.`
|
73
|
-
);
|
70
|
+
: this.parseSecret(secret, `${this.prefix}.`);
|
74
71
|
|
75
72
|
if (this.expectedKeys.length > 0) {
|
76
73
|
checkExpectedSecretKeys(this.expectedKeys, parsedSecret);
|
@@ -1,21 +0,0 @@
|
|
1
|
-
import { IntegrationResponse, LambdaIntegration } from "aws-cdk-lib/aws-apigateway";
|
2
|
-
import { IFunction } from "aws-cdk-lib/aws-lambda";
|
3
|
-
import { MediaType } from "../../types/mediatypes";
|
4
|
-
declare type ParameterType = 'path' | 'querystring';
|
5
|
-
interface ApiParameter {
|
6
|
-
type: ParameterType;
|
7
|
-
name: string;
|
8
|
-
}
|
9
|
-
export declare class DigitrafficIntegration {
|
10
|
-
readonly lambda: IFunction;
|
11
|
-
readonly mediaType: MediaType;
|
12
|
-
readonly parameters: ApiParameter[];
|
13
|
-
constructor(lambda: IFunction, mediaType?: MediaType);
|
14
|
-
addPathParameter(...names: string[]): DigitrafficIntegration;
|
15
|
-
addQueryParameter(...names: string[]): DigitrafficIntegration;
|
16
|
-
build(): LambdaIntegration;
|
17
|
-
createRequestParameters(): Record<string, string>;
|
18
|
-
createRequestTemplates(): Record<string, string>;
|
19
|
-
createResponses(): IntegrationResponse[];
|
20
|
-
}
|
21
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"integration.js","sourceRoot":"","sources":["../../../../src/aws/infra/api/integration.ts"],"names":[],"mappings":";;;AAAA,+DAAuG;AAEvG,uDAAiD;AACjD,qGAA8F;AAS9F,MAAa,sBAAsB;IAM/B,YAAY,MAAiB,EAAE,SAAS,GAAG,sBAAS,CAAC,UAAU;QAFtD,eAAU,GAAmB,EAAE,CAAC;QAGrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;IAED,gBAAgB,CAAC,GAAG,KAAe;QAC/B,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC;QAElE,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,iBAAiB,CAAC,GAAG,KAAe;QAChC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,aAAa,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC;QAEzE,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,KAAK;QACD,MAAM,oBAAoB,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QAEpD,OAAO,IAAI,kCAAiB,CAAC,IAAI,CAAC,MAAM,EAAE;YACtC,KAAK,EAAE,KAAK;YACZ,oBAAoB;YACpB,iBAAiB,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,uBAAuB,EAAE;YAC3F,gBAAgB,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,sBAAsB,EAAE;YACzF,mBAAmB,EAAE,oCAAmB,CAAC,aAAa;SACzD,CAAC,CAAC;IACP,CAAC;IAED,uBAAuB;QACnB,MAAM,iBAAiB,GAA2B,EAAE,CAAC;QAErD,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,SAAuB,EAAE,EAAE;YAChD,iBAAiB,CAAC,uBAAuB,SAAS,CAAC,IAAI,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC,GAAG,kBAAkB,SAAS,CAAC,IAAI,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC;QACxI,CAAC,CAAC,CAAC;QAEH,OAAO,iBAAiB,CAAC;IAC7B,CAAC;IAED,sBAAsB;QAClB,MAAM,WAAW,GAA2B,EAAE,CAAC;QAE/C,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,SAAuB,EAAE,EAAE;YAChD,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,yCAAyC,SAAS,CAAC,IAAI,KAAK,CAAC;QAC/F,CAAC,CAAC,CAAC;QAEH,OAAO;YACH,CAAC,sBAAS,CAAC,gBAAgB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;SAC5D,CAAC;IACN,CAAC;IAED,eAAe;QACX,OAAO,CAAC,iEAA8B,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAC/D,CAAC;CACJ;AA5DD,wDA4DC"}
|
@@ -1,22 +0,0 @@
|
|
1
|
-
import apigateway = require('aws-cdk-lib/aws-apigateway');
|
2
|
-
import { MediaType } from "../../types/mediatypes";
|
3
|
-
/**
|
4
|
-
* This is velocity-script, that assumes the response to be LambdaResponse(status and body).
|
5
|
-
* It will always return the body and status, but if status in something else than 200 OK the content-type
|
6
|
-
* will be overridden to text/plain. (it's assumed, that lambda will return error text).
|
7
|
-
*
|
8
|
-
* If fileName is set, then Content-Disposition-header will be set to use it
|
9
|
-
*/
|
10
|
-
export declare const RESPONSE_DEFAULT_LAMBDA = "#set($inputRoot = $input.path('$'))\n$inputRoot.body\n#if ($inputRoot.status != 200)\n#set ($context.responseOverride.status = $inputRoot.status)\n#set ($context.responseOverride.header.Content-Type = 'text/plain')\n#end\n#set ($context.responseOverride.header.Access-Control-Allow-Origin = '*')\n#if (\"$!inputRoot.fileName\" != \"\")\n#set ($disposition = 'attachment; filename=\"FN\"')\n#set ($context.responseOverride.header.Content-Disposition = $disposition.replaceAll('FN', $inputRoot.fileName))\n#end\n";
|
11
|
-
export declare const MessageModel: {
|
12
|
-
contentType: MediaType;
|
13
|
-
modelName: string;
|
14
|
-
schema: apigateway.JsonSchema;
|
15
|
-
};
|
16
|
-
export declare const NotFoundResponse: string;
|
17
|
-
export declare const BadRequestResponseTemplate: Record<string, string>;
|
18
|
-
export declare const NotFoundResponseTemplate: Record<string, string>;
|
19
|
-
export declare const XmlResponseTemplate: Record<string, string>;
|
20
|
-
export declare const SvgResponseTemplate: Record<string, string>;
|
21
|
-
export declare const InternalServerErrorResponseTemplate: Record<string, string>;
|
22
|
-
export declare function createResponses<T>(key: MediaType, value: T): Record<string, T>;
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../../../src/aws/infra/api/response.ts"],"names":[],"mappings":";;;AAAA,yDAA0D;AAC1D,uDAAiD;AAEjD;;;;;;GAMG;AACU,QAAA,uBAAuB,GAAG;;;;;;;;;;;CAWtC,CAAC;AAEF,MAAM,oBAAoB,GAAG,uBAAuB,CAAC;AAErD,aAAa;AACb,MAAM,aAAa,GAA0B;IACzC,MAAM,EAAE,UAAU,CAAC,iBAAiB,CAAC,MAAM;IAC3C,IAAI,EAAE,UAAU,CAAC,cAAc,CAAC,MAAM;IACtC,WAAW,EAAE,uBAAuB;IACpC,UAAU,EAAE;QACR,OAAO,EAAE;YACL,IAAI,EAAE,UAAU,CAAC,cAAc,CAAC,MAAM;YACtC,WAAW,EAAE,kBAAkB;SAClC;KACJ;CACJ,CAAC;AAEF,aAAa;AACA,QAAA,YAAY,GAAG;IACxB,WAAW,EAAE,sBAAS,CAAC,gBAAgB;IACvC,SAAS,EAAE,sBAAsB;IACjC,MAAM,EAAE,aAAa;CACxB,CAAC;AAEF,MAAM,eAAe,GAAG,WAAW,CAAC;AACvB,QAAA,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAC,EAAC,OAAO,EAAE,eAAe,EAAC,CAAC,CAAC;AAE3E,MAAM,0BAA0B,GAAG,OAAO,CAAC;AAC3C,MAAM,2BAA2B,GAAG,IAAI,CAAC,SAAS,CAAC,EAAC,OAAO,EAAE,0BAA0B,EAAC,CAAC,CAAC;AAE1F,MAAM,iBAAiB,GAAG,aAAa,CAAC;AACxC,MAAM,kBAAkB,GAAG,IAAI,CAAC,SAAS,CAAC,EAAC,OAAO,EAAE,iBAAiB,EAAC,CAAC,CAAC;AAE3D,QAAA,0BAA0B,GAAG,eAAe,CAAC,sBAAS,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;AAC7F,QAAA,wBAAwB,GAAG,eAAe,CAAC,sBAAS,CAAC,gBAAgB,EAAE,wBAAgB,CAAC,CAAC;AACzF,QAAA,mBAAmB,GAAG,eAAe,CAAC,sBAAS,CAAC,eAAe,EAAE,oBAAoB,CAAC,CAAC;AACvF,QAAA,mBAAmB,GAAG,eAAe,CAAC,sBAAS,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;AACjF,QAAA,mCAAmC,GAAG,eAAe,CAAC,sBAAS,CAAC,gBAAgB,EAAE,2BAA2B,CAAC,CAAC;AAE5H,SAAgB,eAAe,CAAI,GAAc,EAAE,KAAQ;IACvD,MAAM,GAAG,GAAsB,EAAE,CAAC;IAElC,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAEjB,OAAO,GAAG,CAAC;AACf,CAAC;AAND,0CAMC"}
|
@@ -1,39 +0,0 @@
|
|
1
|
-
import { LambdaIntegration, MethodResponse, IntegrationResponse, PassthroughBehavior } from "aws-cdk-lib/aws-apigateway";
|
2
|
-
import { Function as AWSFunction } from "aws-cdk-lib/aws-lambda";
|
3
|
-
import { IModel } from "aws-cdk-lib/aws-apigateway/lib/model";
|
4
|
-
import { MediaType } from "../../types/mediatypes";
|
5
|
-
export declare const RESPONSE_200_OK: IntegrationResponse;
|
6
|
-
export declare const RESPONSE_400_BAD_REQUEST: IntegrationResponse;
|
7
|
-
export declare const RESPONSE_500_SERVER_ERROR: IntegrationResponse;
|
8
|
-
export declare const RESPONSE_CORS_INTEGRATION: {
|
9
|
-
responseParameters: {
|
10
|
-
"method.response.header.Access-Control-Allow-Origin": string;
|
11
|
-
};
|
12
|
-
};
|
13
|
-
export declare const RESPONSE_404_NOT_FOUND: {
|
14
|
-
statusCode: string;
|
15
|
-
selectionPattern: string;
|
16
|
-
responseTemplates: Record<string, string>;
|
17
|
-
};
|
18
|
-
export declare function methodResponse(status: string, contentType: MediaType, model: IModel, parameters?: Record<string, boolean>): MethodResponse;
|
19
|
-
export declare function corsMethod(response: MethodResponse): MethodResponse;
|
20
|
-
interface IntegrationOptions {
|
21
|
-
requestParameters?: {
|
22
|
-
[dest: string]: string;
|
23
|
-
};
|
24
|
-
requestTemplates?: {
|
25
|
-
[contentType: string]: string;
|
26
|
-
};
|
27
|
-
responses?: IntegrationResponse[];
|
28
|
-
disableCors?: boolean;
|
29
|
-
xml?: boolean;
|
30
|
-
passthroughBehavior?: PassthroughBehavior;
|
31
|
-
}
|
32
|
-
/**
|
33
|
-
* Creates a default Lambda integration for a REST API resource _root_
|
34
|
-
* @param lambdaFunction The Lambda function
|
35
|
-
* @param options Options
|
36
|
-
*/
|
37
|
-
export declare function defaultIntegration(lambdaFunction: AWSFunction, options?: IntegrationOptions): LambdaIntegration;
|
38
|
-
export declare function getResponse(response: IntegrationResponse, options?: IntegrationOptions): IntegrationResponse;
|
39
|
-
export {};
|