@digitraffic/common 2022.11.23-test-2 → 2022.11.25-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/api/integration.d.ts +1 -1
- package/dist/aws/infra/api/integration.js +8 -4
- package/dist/aws/infra/api/integration.js.map +1 -0
- package/dist/aws/infra/api/response.d.ts +10 -4
- package/dist/aws/infra/api/response.js +53 -18
- package/dist/aws/infra/api/response.js.map +1 -0
- package/dist/aws/infra/api/responses.d.ts +8 -0
- package/dist/aws/infra/api/responses.js +8 -0
- package/dist/aws/infra/api/responses.js.map +1 -0
- package/dist/aws/infra/api/static-integration.js +12 -6
- package/dist/aws/infra/api/static-integration.js.map +1 -0
- package/dist/aws/infra/canaries/canary-alarm.js.map +1 -0
- package/dist/aws/infra/canaries/canary-keys.js.map +1 -0
- package/dist/aws/infra/canaries/canary-parameters.js.map +1 -0
- package/dist/aws/infra/canaries/canary-role.js.map +1 -0
- package/dist/aws/infra/canaries/canary.js.map +1 -0
- package/dist/aws/infra/canaries/database-canary.js.map +1 -0
- package/dist/aws/infra/canaries/database-checker.js.map +1 -0
- package/dist/aws/infra/canaries/url-canary.js.map +1 -0
- package/dist/aws/infra/canaries/url-checker.js.map +1 -0
- package/dist/aws/infra/documentation.js.map +1 -0
- package/dist/aws/infra/import-util.js.map +1 -0
- package/dist/aws/infra/scheduler.js.map +1 -0
- package/dist/aws/infra/security-rule.js.map +1 -0
- package/dist/aws/infra/sqs-integration.js.map +1 -0
- package/dist/aws/infra/sqs-queue.js.map +1 -0
- package/dist/aws/infra/stack/lambda-configs.js.map +1 -0
- package/dist/aws/infra/stack/monitoredfunction.js.map +1 -0
- package/dist/aws/infra/stack/rest_apis.js.map +1 -0
- package/dist/aws/infra/stack/stack-checking-aspect.js.map +1 -0
- package/dist/aws/infra/stack/stack.js.map +1 -0
- package/dist/aws/infra/stack/subscription.js.map +1 -0
- package/dist/aws/infra/stacks/db-dns-stack.js.map +1 -0
- package/dist/aws/infra/stacks/db-proxy-stack.js.map +1 -0
- package/dist/aws/infra/stacks/db-stack.js.map +1 -0
- package/dist/aws/infra/stacks/intra-stack-configuration.js.map +1 -0
- package/dist/aws/infra/stacks/network-stack.js.map +1 -0
- package/dist/aws/infra/usage-plans.js.map +1 -0
- package/dist/aws/runtime/apikey.js.map +1 -0
- package/dist/aws/runtime/digitraffic-integration-response.js.map +1 -0
- package/dist/aws/runtime/environment.js.map +1 -0
- package/dist/aws/runtime/messaging.js.map +1 -0
- package/dist/aws/runtime/s3.js.map +1 -0
- package/dist/aws/runtime/secrets/dbsecret.js.map +1 -0
- package/dist/aws/runtime/secrets/proxy-holder.js.map +1 -0
- package/dist/aws/runtime/secrets/rds-holder.js.map +1 -0
- package/dist/aws/runtime/secrets/secret-holder.js.map +1 -0
- package/dist/aws/runtime/secrets/secret.js.map +1 -0
- package/dist/aws/types/errors.js.map +1 -0
- package/dist/aws/types/lambda-response.d.ts +9 -0
- package/dist/aws/types/lambda-response.js +11 -0
- package/dist/aws/types/lambda-response.js.map +1 -0
- package/dist/aws/types/mediatypes.js.map +1 -0
- package/dist/aws/types/model-with-reference.js.map +1 -0
- package/dist/aws/types/proxytypes.js.map +1 -0
- package/dist/aws/types/tags.js.map +1 -0
- package/dist/database/cached.js.map +1 -0
- package/dist/database/database.js.map +1 -0
- package/dist/database/last-updated.js.map +1 -0
- package/dist/database/models.js.map +1 -0
- package/dist/marine/id_utils.js.map +1 -0
- package/dist/marine/rtz.js.map +1 -0
- package/dist/test/asserter.js.map +1 -0
- package/dist/test/db-testutils.js.map +1 -0
- package/dist/test/httpserver.js.map +1 -0
- package/dist/test/secret.js.map +1 -0
- package/dist/test/secrets-manager.js.map +1 -0
- package/dist/test/testutils.js.map +1 -0
- package/dist/types/either.js.map +1 -0
- package/dist/types/input-error.js.map +1 -0
- package/dist/types/language.js.map +1 -0
- package/dist/types/traffictype.js.map +1 -0
- package/dist/types/validator.js.map +1 -0
- package/dist/utils/api-model.js.map +1 -0
- package/dist/utils/base64.js.map +1 -0
- package/dist/utils/date-utils.js.map +1 -0
- package/dist/utils/geojson-types.js.map +1 -0
- package/dist/utils/geometry.js.map +1 -0
- package/dist/utils/retry.js.map +1 -0
- package/dist/utils/slack.js.map +1 -0
- package/dist/utils/utils.js.map +1 -0
- package/package.json +31 -29
- package/src/aws/infra/api/integration.ts +30 -14
- package/src/aws/infra/api/response.ts +111 -26
- package/src/aws/infra/api/responses.ts +8 -0
- package/src/aws/infra/api/static-integration.ts +48 -14
- package/src/aws/types/lambda-response.ts +12 -0
- package/src/database/database.ts +1 -1
@@ -1,13 +1,17 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
1
|
+
import {
|
2
|
+
MockIntegration,
|
3
|
+
PassthroughBehavior,
|
4
|
+
Resource,
|
5
|
+
} from "aws-cdk-lib/aws-apigateway";
|
6
|
+
import { MediaType } from "../../types/mediatypes";
|
7
|
+
import { corsMethod, RESPONSE_CORS_INTEGRATION } from "./responses";
|
4
8
|
|
5
9
|
const INTEGRATION_RESPONSE_200 = `{
|
6
10
|
"statusCode": 200
|
7
11
|
}`;
|
8
12
|
|
9
13
|
const METHOD_RESPONSE_200 = {
|
10
|
-
statusCode:
|
14
|
+
statusCode: "200",
|
11
15
|
};
|
12
16
|
|
13
17
|
/**
|
@@ -19,9 +23,18 @@ const METHOD_RESPONSE_200 = {
|
|
19
23
|
*/
|
20
24
|
export class DigitrafficStaticIntegration extends MockIntegration {
|
21
25
|
constructor(
|
22
|
-
resource: Resource,
|
26
|
+
resource: Resource,
|
27
|
+
mediaType: MediaType,
|
28
|
+
response: string,
|
29
|
+
enableCors = true,
|
30
|
+
apiKeyRequired = true
|
23
31
|
) {
|
24
|
-
const integrationResponse =
|
32
|
+
const integrationResponse =
|
33
|
+
DigitrafficStaticIntegration.createIntegrationResponse(
|
34
|
+
response,
|
35
|
+
mediaType,
|
36
|
+
enableCors
|
37
|
+
);
|
25
38
|
|
26
39
|
super({
|
27
40
|
passthroughBehavior: PassthroughBehavior.WHEN_NO_TEMPLATES,
|
@@ -31,32 +44,53 @@ export class DigitrafficStaticIntegration extends MockIntegration {
|
|
31
44
|
integrationResponses: [integrationResponse],
|
32
45
|
});
|
33
46
|
|
34
|
-
[
|
47
|
+
["GET", "HEAD"].forEach((httpMethod) => {
|
35
48
|
resource.addMethod(httpMethod, this, {
|
36
49
|
apiKeyRequired,
|
37
|
-
methodResponses: [
|
50
|
+
methodResponses: [
|
51
|
+
DigitrafficStaticIntegration.createMethodResponse(
|
52
|
+
enableCors
|
53
|
+
),
|
54
|
+
],
|
38
55
|
});
|
39
56
|
});
|
40
57
|
}
|
41
58
|
|
42
|
-
static json<K>(
|
59
|
+
static json<K>(
|
60
|
+
resource: Resource,
|
61
|
+
response: K,
|
62
|
+
enableCors = true,
|
63
|
+
apiKeyRequired = true
|
64
|
+
) {
|
43
65
|
return new DigitrafficStaticIntegration(
|
44
|
-
resource,
|
66
|
+
resource,
|
67
|
+
MediaType.APPLICATION_JSON,
|
68
|
+
JSON.stringify(response),
|
69
|
+
enableCors,
|
70
|
+
apiKeyRequired
|
45
71
|
);
|
46
72
|
}
|
47
73
|
|
48
|
-
private static createIntegrationResponse(
|
74
|
+
private static createIntegrationResponse(
|
75
|
+
response: string,
|
76
|
+
mediaType: MediaType,
|
77
|
+
enableCors: boolean
|
78
|
+
) {
|
49
79
|
const integrationResponse = {
|
50
|
-
statusCode:
|
80
|
+
statusCode: "200",
|
51
81
|
responseTemplates: {
|
52
82
|
[mediaType]: response,
|
53
83
|
},
|
54
84
|
};
|
55
85
|
|
56
|
-
return enableCors
|
86
|
+
return enableCors
|
87
|
+
? { ...integrationResponse, ...RESPONSE_CORS_INTEGRATION }
|
88
|
+
: integrationResponse;
|
57
89
|
}
|
58
90
|
|
59
91
|
private static createMethodResponse(enableCors: boolean) {
|
60
|
-
return enableCors
|
92
|
+
return enableCors
|
93
|
+
? corsMethod(METHOD_RESPONSE_200)
|
94
|
+
: METHOD_RESPONSE_200;
|
61
95
|
}
|
62
96
|
}
|
@@ -9,6 +9,18 @@ export class LambdaResponse<T> {
|
|
9
9
|
this.fileName = fileName;
|
10
10
|
}
|
11
11
|
|
12
|
+
/**
|
13
|
+
* When you want to return binary, use LambdaResponse with base64-encoded string and then binary:
|
14
|
+
* LambdaResponse.ok(base64EncodedBinary).binary()
|
15
|
+
*/
|
16
|
+
binary() {
|
17
|
+
return {
|
18
|
+
status: this.status,
|
19
|
+
binary: this.body,
|
20
|
+
fileName: this.fileName,
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
12
24
|
static ok<T>(body: T, fileName?: string) {
|
13
25
|
return this.create(200, body, fileName);
|
14
26
|
}
|
package/src/database/database.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { IDatabase, ITask } from "pg-promise";
|
2
2
|
import { DatabaseEnvironmentKeys } from "../aws/runtime/secrets/dbsecret";
|
3
|
-
import { getEnvVariable
|
3
|
+
import { getEnvVariable } from "../utils/utils";
|
4
4
|
import { envValue } from "../aws/runtime/environment";
|
5
5
|
|
6
6
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|