@digitraffic/common 2024.1.10-1 → 2024.1.23-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/{handler-factory.d.ts → handler-factory.d.mts} +2 -2
- package/dist/aws/infra/api/{handler-factory.js → handler-factory.mjs} +5 -10
- package/dist/aws/infra/api/{integration.d.ts → integration.d.mts} +1 -1
- package/dist/aws/infra/api/{integration.js → integration.mjs} +10 -14
- package/dist/aws/infra/api/{response.d.ts → response.d.mts} +2 -3
- package/dist/aws/infra/api/{response.js → response.mjs} +26 -31
- package/dist/aws/infra/api/{responses.d.ts → responses.d.mts} +2 -3
- package/dist/aws/infra/api/responses.mjs +78 -0
- package/dist/aws/infra/api/{static-integration.d.ts → static-integration.d.mts} +1 -1
- package/dist/aws/infra/api/{static-integration.js → static-integration.mjs} +8 -12
- package/dist/aws/infra/canaries/{canary-alarm.d.ts → canary-alarm.d.mts} +1 -1
- package/dist/aws/infra/canaries/canary-alarm.mjs +20 -0
- package/dist/aws/infra/canaries/canary-keys.mjs +4 -0
- package/dist/aws/infra/canaries/canary-parameters.mjs +2 -0
- package/dist/aws/infra/canaries/{canary-role.js → canary-role.mjs} +9 -13
- package/dist/aws/infra/canaries/{canary.d.ts → canary.d.mts} +2 -2
- package/dist/aws/infra/canaries/canary.mjs +26 -0
- package/dist/aws/infra/canaries/{database-canary.d.ts → database-canary.d.mts} +3 -3
- package/dist/aws/infra/canaries/{database-canary.js → database-canary.mjs} +9 -13
- package/dist/aws/infra/canaries/{database-checker.d.ts → database-checker.d.mts} +1 -1
- package/dist/aws/infra/canaries/{database-checker.js → database-checker.mjs} +12 -18
- package/dist/aws/infra/canaries/{url-canary.d.ts → url-canary.d.mts} +4 -4
- package/dist/aws/infra/canaries/{url-canary.js → url-canary.mjs} +9 -13
- package/dist/aws/infra/canaries/{url-checker.d.ts → url-checker.d.mts} +2 -2
- package/dist/aws/infra/canaries/{url-checker.js → url-checker.mjs} +35 -42
- package/dist/aws/infra/{documentation.js → documentation.mjs} +9 -17
- package/dist/aws/infra/{import-util.js → import-util.mjs} +11 -19
- package/dist/aws/infra/scheduler.mjs +27 -0
- package/dist/aws/infra/{security-rule.js → security-rule.mjs} +5 -9
- package/dist/aws/infra/{sqs-integration.d.ts → sqs-integration.d.mts} +1 -2
- package/dist/aws/infra/{sqs-integration.js → sqs-integration.mjs} +12 -16
- package/dist/aws/infra/{sqs-queue.d.ts → sqs-queue.d.mts} +1 -1
- package/dist/aws/infra/{sqs-queue.js → sqs-queue.mjs} +33 -41
- package/dist/aws/infra/stack/{lambda-configs.d.ts → lambda-configs.d.mts} +2 -2
- package/dist/aws/infra/stack/{lambda-configs.js → lambda-configs.mjs} +15 -21
- package/dist/aws/infra/stack/{monitoredfunction.d.ts → monitoredfunction.d.mts} +3 -3
- package/dist/aws/infra/stack/{monitoredfunction.js → monitoredfunction.mjs} +20 -28
- package/dist/aws/infra/stack/{parameters.d.ts → parameters.d.mts} +1 -1
- package/dist/aws/infra/stack/{parameters.js → parameters.mjs} +6 -11
- package/dist/aws/infra/stack/{rest_apis.d.ts → rest_apis.d.mts} +3 -3
- package/dist/aws/infra/stack/{rest_apis.js → rest_apis.mjs} +42 -55
- package/dist/aws/infra/stack/{stack-checking-aspect.d.ts → stack-checking-aspect.d.mts} +1 -1
- package/dist/aws/infra/stack/{stack-checking-aspect.js → stack-checking-aspect.mjs} +25 -32
- package/dist/aws/infra/stack/{stack.d.ts → stack.d.mts} +3 -4
- package/dist/aws/infra/stack/stack.mjs +63 -0
- package/dist/aws/infra/stack/{subscription.d.ts → subscription.d.mts} +2 -2
- package/dist/aws/infra/stack/{subscription.js → subscription.mjs} +6 -11
- package/dist/aws/infra/stacks/{db-dns-stack.d.ts → db-dns-stack.d.mts} +2 -2
- package/dist/aws/infra/stacks/db-dns-stack.mjs +60 -0
- package/dist/aws/infra/stacks/{db-proxy-stack.d.ts → db-proxy-stack.d.mts} +2 -2
- package/dist/aws/infra/stacks/db-proxy-stack.mjs +73 -0
- package/dist/aws/infra/stacks/{db-stack.d.ts → db-stack.d.mts} +3 -4
- package/dist/aws/infra/stacks/{db-stack.js → db-stack.mjs} +31 -35
- package/dist/aws/infra/stacks/intra-stack-configuration.mjs +2 -0
- package/dist/aws/infra/stacks/{network-stack.d.ts → network-stack.d.mts} +2 -2
- package/dist/aws/infra/stacks/network-stack.mjs +40 -0
- package/dist/aws/infra/{usage-plans.js → usage-plans.mjs} +3 -8
- package/dist/aws/runtime/apikey.mjs +9 -0
- package/dist/aws/runtime/{digitraffic-integration-response.d.ts → digitraffic-integration-response.d.mts} +1 -1
- package/dist/aws/runtime/digitraffic-integration-response.mjs +24 -0
- package/dist/aws/runtime/{dt-logger-default.d.ts → dt-logger-default.d.mts} +2 -2
- package/dist/aws/runtime/dt-logger-default.mjs +6 -0
- package/dist/aws/runtime/{dt-logger.d.ts → dt-logger.d.mts} +1 -1
- package/dist/aws/runtime/{dt-logger.js → dt-logger.mjs} +4 -11
- package/dist/aws/runtime/{environment.js → environment.mjs} +4 -8
- package/dist/aws/runtime/{messaging.js → messaging.mjs} +2 -6
- package/dist/aws/runtime/{s3.js → s3.mjs} +4 -8
- package/dist/aws/runtime/secrets/{dbsecret.d.ts → dbsecret.d.mts} +1 -1
- package/dist/aws/runtime/secrets/{dbsecret.js → dbsecret.mjs} +6 -10
- package/dist/aws/runtime/secrets/proxy-holder.mjs +24 -0
- package/dist/aws/runtime/secrets/rds-holder.mjs +24 -0
- package/dist/aws/runtime/secrets/{secret-holder.d.ts → secret-holder.d.mts} +1 -1
- package/dist/aws/runtime/secrets/{secret-holder.js → secret-holder.mjs} +14 -19
- package/dist/aws/runtime/secrets/{secret.js → secret.mjs} +8 -12
- package/dist/aws/types/errors.mjs +12 -0
- package/dist/aws/types/{lambda-response.js → lambda-response.mjs} +4 -11
- package/dist/aws/types/{mediatypes.js → mediatypes.mjs} +3 -6
- package/dist/aws/types/model-with-reference.mjs +2 -0
- package/dist/aws/types/proxytypes.mjs +2 -0
- package/dist/aws/types/tags.mjs +4 -0
- package/dist/database/{cached.d.ts → cached.d.mts} +1 -1
- package/dist/database/{cached.js → cached.mjs} +10 -15
- package/dist/database/{database.d.ts → database.d.mts} +1 -1
- package/dist/database/{database.js → database.mjs} +17 -24
- package/dist/database/{last-updated.d.ts → last-updated.d.mts} +1 -1
- package/dist/database/{last-updated.js → last-updated.mjs} +9 -18
- package/dist/database/models.mjs +2 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +2 -0
- package/dist/marine/{id_utils.js → id_utils.mjs} +4 -10
- package/dist/marine/rtz.mjs +2 -0
- package/dist/test/{asserter.js → asserter.mjs} +2 -6
- package/dist/test/{db-testutils.d.ts → db-testutils.d.mts} +1 -1
- package/dist/test/db-testutils.mjs +29 -0
- package/dist/test/{httpserver.js → httpserver.mjs} +11 -15
- package/dist/test/secrets-manager.mjs +34 -0
- package/dist/test/testutils.mjs +33 -0
- package/dist/types/async-timeout-error.mjs +6 -0
- package/dist/types/aws-env.mjs +2 -0
- package/dist/types/either.mjs +2 -0
- package/dist/types/http-error.mjs +7 -0
- package/dist/types/input-error.mjs +3 -0
- package/dist/types/language.mjs +7 -0
- package/dist/types/{nullable.d.ts → nullable.d.mts} +1 -1
- package/dist/types/nullable.mjs +2 -0
- package/dist/types/{traffictype.js → traffictype.mjs} +3 -6
- package/dist/types/urn.mjs +2 -0
- package/dist/types/util-types.mjs +2 -0
- package/dist/types/validator.mjs +9 -0
- package/dist/utils/{api-model.d.ts → api-model.d.mts} +1 -1
- package/dist/utils/{api-model.js → api-model.mjs} +18 -28
- package/dist/utils/{base64.d.ts → base64.d.mts} +1 -1
- package/dist/utils/base64.mjs +16 -0
- package/dist/utils/date-utils.mjs +44 -0
- package/dist/utils/geojson-types.mjs +13 -0
- package/dist/utils/{geometry.js → geometry.mjs} +16 -49
- package/dist/utils/{logging.d.ts → logging.d.mts} +1 -1
- package/dist/utils/{logging.js → logging.mjs} +9 -14
- package/dist/utils/{retry.js → retry.mjs} +22 -27
- package/dist/utils/slack.mjs +23 -0
- package/dist/utils/{utils.d.ts → utils.d.mts} +2 -2
- package/dist/utils/{utils.js → utils.mjs} +15 -30
- package/package.json +99 -10
- package/src/aws/infra/api/{handler-factory.ts → handler-factory.mts} +3 -3
- package/src/aws/infra/api/{integration.ts → integration.mts} +2 -2
- package/src/aws/infra/api/{response.ts → response.mts} +3 -3
- package/src/aws/infra/api/{responses.ts → responses.mts} +4 -4
- package/src/aws/infra/api/{static-integration.ts → static-integration.mts} +2 -2
- package/src/aws/infra/canaries/Synthetics.d.mts +21 -0
- package/src/aws/infra/canaries/{canary-alarm.ts → canary-alarm.mts} +1 -1
- package/src/aws/infra/canaries/{canary.ts → canary.mts} +3 -3
- package/src/aws/infra/canaries/{database-canary.ts → database-canary.mts} +3 -3
- package/src/aws/infra/canaries/{database-checker.ts → database-checker.mts} +7 -10
- package/src/aws/infra/canaries/{url-canary.ts → url-canary.mts} +6 -6
- package/src/aws/infra/canaries/{url-checker.ts → url-checker.mts} +9 -29
- package/src/aws/infra/{sqs-integration.ts → sqs-integration.mts} +1 -1
- package/src/aws/infra/{sqs-queue.ts → sqs-queue.mts} +3 -6
- package/src/aws/infra/stack/{lambda-configs.ts → lambda-configs.mts} +2 -2
- package/src/aws/infra/stack/{monitoredfunction.ts → monitoredfunction.mts} +4 -4
- package/src/aws/infra/stack/{parameters.ts → parameters.mts} +1 -1
- package/src/aws/infra/stack/{rest_apis.ts → rest_apis.mts} +6 -6
- package/src/aws/infra/stack/{stack-checking-aspect.ts → stack-checking-aspect.mts} +1 -1
- package/src/aws/infra/stack/{stack.ts → stack.mts} +4 -5
- package/src/aws/infra/stack/{subscription.ts → subscription.mts} +2 -2
- package/src/aws/infra/stacks/{db-dns-stack.ts → db-dns-stack.mts} +4 -4
- package/src/aws/infra/stacks/{db-proxy-stack.ts → db-proxy-stack.mts} +5 -5
- package/src/aws/infra/stacks/{db-stack.ts → db-stack.mts} +5 -5
- package/src/aws/infra/stacks/{network-stack.ts → network-stack.mts} +3 -3
- package/src/aws/runtime/{digitraffic-integration-response.ts → digitraffic-integration-response.mts} +2 -2
- package/src/aws/runtime/{dt-logger-default.ts → dt-logger-default.mts} +2 -2
- package/src/aws/runtime/secrets/{dbsecret.ts → dbsecret.mts} +1 -1
- package/src/aws/runtime/secrets/node-ttl.d.mts +12 -0
- package/src/aws/runtime/secrets/{proxy-holder.ts → proxy-holder.mts} +4 -4
- package/src/aws/runtime/secrets/{rds-holder.ts → rds-holder.mts} +4 -4
- package/src/aws/runtime/secrets/{secret-holder.ts → secret-holder.mts} +8 -9
- package/src/aws/runtime/secrets/{secret.ts → secret.mts} +2 -2
- package/src/database/{cached.ts → cached.mts} +4 -2
- package/src/database/{database.ts → database.mts} +6 -6
- package/src/database/{last-updated.ts → last-updated.mts} +1 -1
- package/src/index.mts +2 -0
- package/src/test/{db-testutils.ts → db-testutils.mts} +2 -2
- package/src/test/{secrets-manager.ts → secrets-manager.mts} +3 -3
- package/src/types/{nullable.ts → nullable.mts} +1 -1
- package/src/utils/{api-model.ts → api-model.mts} +1 -1
- package/src/utils/{geometry.ts → geometry.mts} +5 -3
- package/src/utils/{logging.ts → logging.mts} +2 -2
- package/src/utils/{retry.ts → retry.mts} +3 -3
- package/src/utils/{slack.ts → slack.mts} +2 -2
- package/src/utils/{utils.ts → utils.mts} +3 -3
- package/dist/aws/infra/api/responses.js +0 -84
- package/dist/aws/infra/canaries/canary-alarm.js +0 -24
- package/dist/aws/infra/canaries/canary-keys.js +0 -7
- package/dist/aws/infra/canaries/canary-parameters.js +0 -3
- package/dist/aws/infra/canaries/canary.js +0 -30
- package/dist/aws/infra/scheduler.js +0 -31
- package/dist/aws/infra/stack/stack.js +0 -67
- package/dist/aws/infra/stacks/db-dns-stack.js +0 -64
- package/dist/aws/infra/stacks/db-proxy-stack.js +0 -77
- package/dist/aws/infra/stacks/intra-stack-configuration.js +0 -3
- package/dist/aws/infra/stacks/network-stack.js +0 -44
- package/dist/aws/runtime/apikey.js +0 -13
- package/dist/aws/runtime/digitraffic-integration-response.js +0 -28
- package/dist/aws/runtime/dt-logger-default.js +0 -9
- package/dist/aws/runtime/secrets/proxy-holder.js +0 -28
- package/dist/aws/runtime/secrets/rds-holder.js +0 -28
- package/dist/aws/types/errors.js +0 -16
- package/dist/aws/types/model-with-reference.js +0 -3
- package/dist/aws/types/proxytypes.js +0 -3
- package/dist/aws/types/tags.js +0 -7
- package/dist/database/models.js +0 -3
- package/dist/marine/rtz.js +0 -3
- package/dist/test/db-testutils.js +0 -34
- package/dist/test/secrets-manager.js +0 -62
- package/dist/test/testutils.js +0 -44
- package/dist/types/async-timeout-error.js +0 -10
- package/dist/types/aws-env.js +0 -3
- package/dist/types/either.js +0 -3
- package/dist/types/http-error.js +0 -11
- package/dist/types/input-error.js +0 -7
- package/dist/types/language.js +0 -10
- package/dist/types/nullable.js +0 -3
- package/dist/types/urn.js +0 -3
- package/dist/types/util-types.js +0 -3
- package/dist/types/validator.js +0 -14
- package/dist/utils/base64.js +0 -21
- package/dist/utils/date-utils.js +0 -51
- package/dist/utils/geojson-types.js +0 -18
- package/dist/utils/slack.js +0 -30
- /package/dist/aws/infra/canaries/{canary-keys.d.ts → canary-keys.d.mts} +0 -0
- /package/dist/aws/infra/canaries/{canary-parameters.d.ts → canary-parameters.d.mts} +0 -0
- /package/dist/aws/infra/canaries/{canary-role.d.ts → canary-role.d.mts} +0 -0
- /package/dist/aws/infra/{documentation.d.ts → documentation.d.mts} +0 -0
- /package/dist/aws/infra/{import-util.d.ts → import-util.d.mts} +0 -0
- /package/dist/aws/infra/{scheduler.d.ts → scheduler.d.mts} +0 -0
- /package/dist/aws/infra/{security-rule.d.ts → security-rule.d.mts} +0 -0
- /package/dist/aws/infra/stacks/{intra-stack-configuration.d.ts → intra-stack-configuration.d.mts} +0 -0
- /package/dist/aws/infra/{usage-plans.d.ts → usage-plans.d.mts} +0 -0
- /package/dist/aws/runtime/{apikey.d.ts → apikey.d.mts} +0 -0
- /package/dist/aws/runtime/{environment.d.ts → environment.d.mts} +0 -0
- /package/dist/aws/runtime/{messaging.d.ts → messaging.d.mts} +0 -0
- /package/dist/aws/runtime/{s3.d.ts → s3.d.mts} +0 -0
- /package/dist/aws/runtime/secrets/{proxy-holder.d.ts → proxy-holder.d.mts} +0 -0
- /package/dist/aws/runtime/secrets/{rds-holder.d.ts → rds-holder.d.mts} +0 -0
- /package/dist/aws/runtime/secrets/{secret.d.ts → secret.d.mts} +0 -0
- /package/dist/aws/types/{errors.d.ts → errors.d.mts} +0 -0
- /package/dist/aws/types/{lambda-response.d.ts → lambda-response.d.mts} +0 -0
- /package/dist/aws/types/{mediatypes.d.ts → mediatypes.d.mts} +0 -0
- /package/dist/aws/types/{model-with-reference.d.ts → model-with-reference.d.mts} +0 -0
- /package/dist/aws/types/{proxytypes.d.ts → proxytypes.d.mts} +0 -0
- /package/dist/aws/types/{tags.d.ts → tags.d.mts} +0 -0
- /package/dist/database/{models.d.ts → models.d.mts} +0 -0
- /package/dist/marine/{id_utils.d.ts → id_utils.d.mts} +0 -0
- /package/dist/marine/{rtz.d.ts → rtz.d.mts} +0 -0
- /package/dist/test/{asserter.d.ts → asserter.d.mts} +0 -0
- /package/dist/test/{httpserver.d.ts → httpserver.d.mts} +0 -0
- /package/dist/test/{secrets-manager.d.ts → secrets-manager.d.mts} +0 -0
- /package/dist/test/{testutils.d.ts → testutils.d.mts} +0 -0
- /package/dist/types/{async-timeout-error.d.ts → async-timeout-error.d.mts} +0 -0
- /package/dist/types/{aws-env.d.ts → aws-env.d.mts} +0 -0
- /package/dist/types/{either.d.ts → either.d.mts} +0 -0
- /package/dist/types/{http-error.d.ts → http-error.d.mts} +0 -0
- /package/dist/types/{input-error.d.ts → input-error.d.mts} +0 -0
- /package/dist/types/{language.d.ts → language.d.mts} +0 -0
- /package/dist/types/{traffictype.d.ts → traffictype.d.mts} +0 -0
- /package/dist/types/{urn.d.ts → urn.d.mts} +0 -0
- /package/dist/types/{util-types.d.ts → util-types.d.mts} +0 -0
- /package/dist/types/{validator.d.ts → validator.d.mts} +0 -0
- /package/dist/utils/{date-utils.d.ts → date-utils.d.mts} +0 -0
- /package/dist/utils/{geojson-types.d.ts → geojson-types.d.mts} +0 -0
- /package/dist/utils/{geometry.d.ts → geometry.d.mts} +0 -0
- /package/dist/utils/{retry.d.ts → retry.d.mts} +0 -0
- /package/dist/utils/{slack.d.ts → slack.d.mts} +0 -0
- /package/src/@types/geojson-validation/{index.d.ts → index.d.mts} +0 -0
- /package/src/aws/infra/canaries/{canary-keys.ts → canary-keys.mts} +0 -0
- /package/src/aws/infra/canaries/{canary-parameters.ts → canary-parameters.mts} +0 -0
- /package/src/aws/infra/canaries/{canary-role.ts → canary-role.mts} +0 -0
- /package/src/aws/infra/{documentation.ts → documentation.mts} +0 -0
- /package/src/aws/infra/{import-util.ts → import-util.mts} +0 -0
- /package/src/aws/infra/{scheduler.ts → scheduler.mts} +0 -0
- /package/src/aws/infra/{security-rule.ts → security-rule.mts} +0 -0
- /package/src/aws/infra/stacks/{intra-stack-configuration.ts → intra-stack-configuration.mts} +0 -0
- /package/src/aws/infra/{usage-plans.ts → usage-plans.mts} +0 -0
- /package/src/aws/runtime/{apikey.ts → apikey.mts} +0 -0
- /package/src/aws/runtime/{dt-logger.ts → dt-logger.mts} +0 -0
- /package/src/aws/runtime/{environment.ts → environment.mts} +0 -0
- /package/src/aws/runtime/{messaging.ts → messaging.mts} +0 -0
- /package/src/aws/runtime/{s3.ts → s3.mts} +0 -0
- /package/src/aws/types/{errors.ts → errors.mts} +0 -0
- /package/src/aws/types/{lambda-response.ts → lambda-response.mts} +0 -0
- /package/src/aws/types/{mediatypes.ts → mediatypes.mts} +0 -0
- /package/src/aws/types/{model-with-reference.ts → model-with-reference.mts} +0 -0
- /package/src/aws/types/{proxytypes.ts → proxytypes.mts} +0 -0
- /package/src/aws/types/{tags.ts → tags.mts} +0 -0
- /package/src/database/{models.ts → models.mts} +0 -0
- /package/src/marine/{id_utils.ts → id_utils.mts} +0 -0
- /package/src/marine/{rtz.ts → rtz.mts} +0 -0
- /package/src/test/{asserter.ts → asserter.mts} +0 -0
- /package/src/test/{httpserver.ts → httpserver.mts} +0 -0
- /package/src/test/{testutils.ts → testutils.mts} +0 -0
- /package/src/types/{async-timeout-error.ts → async-timeout-error.mts} +0 -0
- /package/src/types/{aws-env.ts → aws-env.mts} +0 -0
- /package/src/types/{either.ts → either.mts} +0 -0
- /package/src/types/{http-error.ts → http-error.mts} +0 -0
- /package/src/types/{input-error.ts → input-error.mts} +0 -0
- /package/src/types/{language.ts → language.mts} +0 -0
- /package/src/types/{traffictype.ts → traffictype.mts} +0 -0
- /package/src/types/{urn.ts → urn.mts} +0 -0
- /package/src/types/{util-types.ts → util-types.mts} +0 -0
- /package/src/types/{validator.ts → validator.mts} +0 -0
- /package/src/utils/{base64.ts → base64.mts} +0 -0
- /package/src/utils/{date-utils.ts → date-utils.mts} +0 -0
- /package/src/utils/{geojson-types.ts → geojson-types.mts} +0 -0
@@ -1,6 +1,3 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.createDefaultUsagePlan = exports.createUsagePlan = void 0;
|
4
1
|
/**
|
5
2
|
* Creates an usage plan for a REST API with a single API key
|
6
3
|
* @param api The REST API
|
@@ -8,7 +5,7 @@ exports.createDefaultUsagePlan = exports.createUsagePlan = void 0;
|
|
8
5
|
* @param apiKeyName Name for the API key, this is displayed in the AWS Console
|
9
6
|
* @deprecated Creates randomized API key names, use createDefaultUsagePlan instead
|
10
7
|
*/
|
11
|
-
function createUsagePlan(api, apiKeyId, apiKeyName) {
|
8
|
+
export function createUsagePlan(api, apiKeyId, apiKeyName) {
|
12
9
|
const apiKey = api.addApiKey(apiKeyId);
|
13
10
|
const plan = api.addUsagePlan(apiKeyName, {
|
14
11
|
name: apiKeyName,
|
@@ -19,14 +16,13 @@ function createUsagePlan(api, apiKeyId, apiKeyName) {
|
|
19
16
|
plan.addApiKey(apiKey);
|
20
17
|
return apiKey;
|
21
18
|
}
|
22
|
-
exports.createUsagePlan = createUsagePlan;
|
23
19
|
/**
|
24
20
|
* Creates a default usage plan for a REST API with a single API key
|
25
21
|
* @param api The REST API
|
26
22
|
* @param apiName Name of the api. Will generate key: apiName + ' API Key' and plan: apiName + ' API Usage Plan'
|
27
23
|
* @param value Optional value for the API key
|
28
24
|
*/
|
29
|
-
function createDefaultUsagePlan(api, apiName, value) {
|
25
|
+
export function createDefaultUsagePlan(api, apiName, value) {
|
30
26
|
const apiKeyName = apiName + " API Key";
|
31
27
|
const usagePlanName = apiName + " API Usage Plan";
|
32
28
|
const apiKey = api.addApiKey(apiKeyName, { apiKeyName: apiKeyName, value });
|
@@ -39,5 +35,4 @@ function createDefaultUsagePlan(api, apiName, value) {
|
|
39
35
|
plan.addApiKey(apiKey);
|
40
36
|
return apiKey;
|
41
37
|
}
|
42
|
-
|
43
|
-
//# sourceMappingURL=usage-plans.js.map
|
38
|
+
//# sourceMappingURL=usage-plans.mjs.map
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { IntegrationResponse } from "aws-cdk-lib/aws-apigateway";
|
2
|
-
import { MediaType } from "../types/mediatypes";
|
2
|
+
import { MediaType } from "../types/mediatypes.mjs";
|
3
3
|
export declare abstract class DigitrafficIntegrationResponse {
|
4
4
|
static ok(mediaType: MediaType, sunset?: string): IntegrationResponse;
|
5
5
|
static badRequest(mediaType?: MediaType): IntegrationResponse;
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { MediaType } from "../types/mediatypes.mjs";
|
2
|
+
import { getDeprecatedDefaultLambdaResponse, RESPONSE_DEFAULT_LAMBDA, } from "../infra/api/response.mjs";
|
3
|
+
export class DigitrafficIntegrationResponse {
|
4
|
+
static ok(mediaType, sunset) {
|
5
|
+
return this.create("200", mediaType, sunset);
|
6
|
+
}
|
7
|
+
static badRequest(mediaType) {
|
8
|
+
return this.create("400", mediaType ?? MediaType.TEXT_PLAIN);
|
9
|
+
}
|
10
|
+
static notImplemented(mediaType) {
|
11
|
+
return this.create("501", mediaType ?? MediaType.TEXT_PLAIN);
|
12
|
+
}
|
13
|
+
static create(statusCode, mediaType, sunset) {
|
14
|
+
return {
|
15
|
+
statusCode,
|
16
|
+
responseTemplates: {
|
17
|
+
[mediaType]: sunset
|
18
|
+
? getDeprecatedDefaultLambdaResponse(sunset)
|
19
|
+
: RESPONSE_DEFAULT_LAMBDA,
|
20
|
+
},
|
21
|
+
};
|
22
|
+
}
|
23
|
+
}
|
24
|
+
//# sourceMappingURL=digitraffic-integration-response.mjs.map
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import { DtLogger } from "./dt-logger";
|
1
|
+
import { DtLogger } from "./dt-logger.mjs";
|
2
2
|
/**
|
3
3
|
* You can use this for method name definition to match DtLogger LoggableType.method parameter.
|
4
4
|
*/
|
5
|
-
export type { LoggerMethodType } from "./dt-logger";
|
5
|
+
export type { LoggerMethodType } from "./dt-logger.mjs";
|
6
6
|
/**
|
7
7
|
* You can use this for your logging needs or create one locally and configure it as you wish.
|
8
8
|
*/
|
@@ -1,10 +1,4 @@
|
|
1
|
-
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.DtLogger = void 0;
|
7
|
-
const lodash_1 = __importDefault(require("lodash"));
|
1
|
+
import _ from "lodash";
|
8
2
|
/**
|
9
3
|
* Helper class for json-logging.
|
10
4
|
*
|
@@ -14,7 +8,7 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
14
8
|
* * runtime (taken from process environment)
|
15
9
|
* * the actual message (as json or as string)
|
16
10
|
*/
|
17
|
-
class DtLogger {
|
11
|
+
export class DtLogger {
|
18
12
|
/**
|
19
13
|
* Create a new Logger instance.
|
20
14
|
* @constructor
|
@@ -100,8 +94,7 @@ class DtLogger {
|
|
100
94
|
this.writeStream.write(JSON.stringify(logMessage) + "\n");
|
101
95
|
}
|
102
96
|
}
|
103
|
-
exports.DtLogger = DtLogger;
|
104
97
|
function removePrefix(prefix, loggable) {
|
105
|
-
return
|
98
|
+
return _.mapKeys(loggable, (_index, key) => key.startsWith(prefix) ? _.lowerFirst(key.replace(prefix, "")) : key);
|
106
99
|
}
|
107
|
-
//# sourceMappingURL=dt-logger.
|
100
|
+
//# sourceMappingURL=dt-logger.mjs.map
|
@@ -1,16 +1,13 @@
|
|
1
|
-
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.envValue = exports.EnvKeys = void 0;
|
4
|
-
var EnvKeys;
|
1
|
+
export var EnvKeys;
|
5
2
|
(function (EnvKeys) {
|
6
3
|
EnvKeys["AWS_REGION"] = "AWS_REGION";
|
7
4
|
EnvKeys["SECRET_ID"] = "SECRET_ID";
|
8
5
|
EnvKeys["SECRET_OVERRIDE_AWS_REGION"] = "SECRET_OVERRIDE_AWS_REGION";
|
9
|
-
})(EnvKeys || (
|
6
|
+
})(EnvKeys || (EnvKeys = {}));
|
10
7
|
/**
|
11
8
|
* @deprecated Use digitraffic/common/utils/utils#getEnvVariable
|
12
9
|
*/
|
13
|
-
function envValue(key, defaultValue) {
|
10
|
+
export function envValue(key, defaultValue) {
|
14
11
|
const value = process.env[key];
|
15
12
|
if (value == null) {
|
16
13
|
if (defaultValue) {
|
@@ -20,5 +17,4 @@ function envValue(key, defaultValue) {
|
|
20
17
|
}
|
21
18
|
return value;
|
22
19
|
}
|
23
|
-
|
24
|
-
//# sourceMappingURL=environment.js.map
|
20
|
+
//# sourceMappingURL=environment.mjs.map
|
@@ -1,6 +1,3 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.snsPublish = void 0;
|
4
1
|
/**
|
5
2
|
* Utility function for publishing SNS messages.
|
6
3
|
* Made because using *await* with AWS APIs doesn't require calling promise() but nothing works if it isn't called.
|
@@ -9,7 +6,7 @@ exports.snsPublish = void 0;
|
|
9
6
|
* @param topicArn
|
10
7
|
* @param sns
|
11
8
|
*/
|
12
|
-
async function snsPublish(message, topicArn, sns) {
|
9
|
+
export async function snsPublish(message, topicArn, sns) {
|
13
10
|
const publishParams = {
|
14
11
|
Message: message,
|
15
12
|
TopicArn: topicArn,
|
@@ -27,5 +24,4 @@ async function snsPublish(message, topicArn, sns) {
|
|
27
24
|
}
|
28
25
|
}
|
29
26
|
}
|
30
|
-
|
31
|
-
//# sourceMappingURL=messaging.js.map
|
27
|
+
//# sourceMappingURL=messaging.mjs.map
|
@@ -1,9 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
const aws_sdk_1 = require("aws-sdk");
|
5
|
-
async function uploadToS3(bucketName, body, objectName, cannedAcl, contentType) {
|
6
|
-
const s3 = new aws_sdk_1.S3();
|
1
|
+
import { S3 } from "aws-sdk";
|
2
|
+
export async function uploadToS3(bucketName, body, objectName, cannedAcl, contentType) {
|
3
|
+
const s3 = new S3();
|
7
4
|
try {
|
8
5
|
await doUpload(s3, bucketName, body, objectName, cannedAcl, contentType);
|
9
6
|
}
|
@@ -17,7 +14,6 @@ async function uploadToS3(bucketName, body, objectName, cannedAcl, contentType)
|
|
17
14
|
}
|
18
15
|
}
|
19
16
|
}
|
20
|
-
exports.uploadToS3 = uploadToS3;
|
21
17
|
function doUpload(s3, bucketName, body, filename, cannedAcl, contentType) {
|
22
18
|
return s3.upload({
|
23
19
|
Bucket: bucketName,
|
@@ -27,4 +23,4 @@ function doUpload(s3, bucketName, body, filename, cannedAcl, contentType) {
|
|
27
23
|
ContentType: contentType,
|
28
24
|
}).promise();
|
29
25
|
}
|
30
|
-
//# sourceMappingURL=s3.
|
26
|
+
//# sourceMappingURL=s3.mjs.map
|
@@ -1,26 +1,22 @@
|
|
1
|
-
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.checkExpectedSecretKeys = exports.RdsSecretKey = exports.RdsProxySecretKey = void 0;
|
4
|
-
var RdsProxySecretKey;
|
1
|
+
export var RdsProxySecretKey;
|
5
2
|
(function (RdsProxySecretKey) {
|
6
3
|
RdsProxySecretKey["username"] = "username";
|
7
4
|
RdsProxySecretKey["password"] = "password";
|
8
5
|
RdsProxySecretKey["proxy_host"] = "proxy_host";
|
9
6
|
RdsProxySecretKey["proxy_ro_host"] = "proxy_ro_host";
|
10
|
-
})(RdsProxySecretKey || (
|
11
|
-
var RdsSecretKey;
|
7
|
+
})(RdsProxySecretKey || (RdsProxySecretKey = {}));
|
8
|
+
export var RdsSecretKey;
|
12
9
|
(function (RdsSecretKey) {
|
13
10
|
RdsSecretKey["username"] = "username";
|
14
11
|
RdsSecretKey["password"] = "password";
|
15
12
|
RdsSecretKey["host"] = "host";
|
16
13
|
RdsSecretKey["ro_host"] = "ro_host";
|
17
|
-
})(RdsSecretKey || (
|
18
|
-
function checkExpectedSecretKeys(keys, secret) {
|
14
|
+
})(RdsSecretKey || (RdsSecretKey = {}));
|
15
|
+
export function checkExpectedSecretKeys(keys, secret) {
|
19
16
|
const missingKeys = keys.filter((key) => !(key in secret));
|
20
17
|
if (missingKeys.length) {
|
21
18
|
console.error(`method=checkExpectedSecretKeys secret didn't contain the key(s) ${missingKeys.toString()}`);
|
22
19
|
throw new Error("Expected keys were not found");
|
23
20
|
}
|
24
21
|
}
|
25
|
-
|
26
|
-
//# sourceMappingURL=dbsecret.js.map
|
22
|
+
//# sourceMappingURL=dbsecret.mjs.map
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { SecretHolder } from "./secret-holder.mjs";
|
2
|
+
import { RdsProxySecretKey } from "./dbsecret.mjs";
|
3
|
+
import { getEnvVariable } from "../../../utils/utils.mjs";
|
4
|
+
import { DatabaseEnvironmentKeys } from "../../../database/database.mjs";
|
5
|
+
const RDS_PROXY_SECRET_KEYS = Object.values(RdsProxySecretKey);
|
6
|
+
/**
|
7
|
+
* Holds credentials for RDS Proxy access.
|
8
|
+
*/
|
9
|
+
export class ProxyHolder {
|
10
|
+
constructor(secretId) {
|
11
|
+
this.secretHolder = new SecretHolder(secretId, "", RDS_PROXY_SECRET_KEYS);
|
12
|
+
}
|
13
|
+
static create() {
|
14
|
+
return new ProxyHolder(getEnvVariable("SECRET_ID"));
|
15
|
+
}
|
16
|
+
async setCredentials() {
|
17
|
+
const secret = await this.secretHolder.get();
|
18
|
+
process.env[DatabaseEnvironmentKeys.DB_USER] = secret.username;
|
19
|
+
process.env[DatabaseEnvironmentKeys.DB_PASS] = secret.password;
|
20
|
+
process.env[DatabaseEnvironmentKeys.DB_URI] = secret.proxy_host;
|
21
|
+
process.env[DatabaseEnvironmentKeys.DB_RO_URI] = secret.proxy_ro_host;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
//# sourceMappingURL=proxy-holder.mjs.map
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { SecretHolder } from "./secret-holder.mjs";
|
2
|
+
import { RdsSecretKey } from "./dbsecret.mjs";
|
3
|
+
import { getEnvVariable } from "../../../utils/utils.mjs";
|
4
|
+
import { DatabaseEnvironmentKeys } from "../../../database/database.mjs";
|
5
|
+
const RDS_SECRET_KEYS = Object.values(RdsSecretKey);
|
6
|
+
/**
|
7
|
+
* Holds credentials for RDS access.
|
8
|
+
*/
|
9
|
+
export class RdsHolder {
|
10
|
+
constructor(secretId) {
|
11
|
+
this.secretHolder = new SecretHolder(secretId, "", RDS_SECRET_KEYS);
|
12
|
+
}
|
13
|
+
static create() {
|
14
|
+
return new RdsHolder(getEnvVariable("SECRET_ID"));
|
15
|
+
}
|
16
|
+
async setCredentials() {
|
17
|
+
const secret = await this.secretHolder.get();
|
18
|
+
process.env[DatabaseEnvironmentKeys.DB_USER] = secret.username;
|
19
|
+
process.env[DatabaseEnvironmentKeys.DB_PASS] = secret.password;
|
20
|
+
process.env[DatabaseEnvironmentKeys.DB_URI] = secret.host;
|
21
|
+
process.env[DatabaseEnvironmentKeys.DB_RO_URI] = secret.ro_host;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
//# sourceMappingURL=rds-holder.mjs.map
|
@@ -1,12 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
const
|
6
|
-
|
7
|
-
const
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-assignment
|
9
|
-
const NodeTtl = require("node-ttl");
|
1
|
+
import { getSecret } from "./secret.mjs";
|
2
|
+
import { checkExpectedSecretKeys } from "./dbsecret.mjs";
|
3
|
+
import { getEnvVariable } from "../../../utils/utils.mjs";
|
4
|
+
import { logger } from "../dt-logger-default.mjs";
|
5
|
+
const NodeTtlImport = await import("node-ttl");
|
6
|
+
//eslint-disable-next-line
|
7
|
+
const NodeTtl = NodeTtlImport.default;
|
10
8
|
const DEFAULT_PREFIX = "";
|
11
9
|
const DEFAULT_SECRET_KEY = "SECRET";
|
12
10
|
const DEFAULT_CONFIGURATION = {
|
@@ -24,7 +22,7 @@ const DEFAULT_CONFIGURATION = {
|
|
24
22
|
* setting the region with utils setSecretOverideAwsRegionEnv method.
|
25
23
|
*
|
26
24
|
*/
|
27
|
-
class SecretHolder {
|
25
|
+
export class SecretHolder {
|
28
26
|
constructor(secretId, prefix = "", expectedKeys = [], configuration = DEFAULT_CONFIGURATION) {
|
29
27
|
this.secretId = secretId;
|
30
28
|
this.prefix = prefix;
|
@@ -33,8 +31,8 @@ class SecretHolder {
|
|
33
31
|
this.secretCache = new NodeTtl(configuration);
|
34
32
|
}
|
35
33
|
async initSecret() {
|
36
|
-
const secretValue = await
|
37
|
-
|
34
|
+
const secretValue = await getSecret(this.secretId);
|
35
|
+
logger.info({
|
38
36
|
method: "SecretHolder.initSecret",
|
39
37
|
message: "Refreshing secret " + this.secretId,
|
40
38
|
});
|
@@ -42,7 +40,7 @@ class SecretHolder {
|
|
42
40
|
this.secretCache.push(DEFAULT_SECRET_KEY, secretValue);
|
43
41
|
}
|
44
42
|
static create(prefix = DEFAULT_PREFIX, expectedKeys = []) {
|
45
|
-
return new SecretHolder(
|
43
|
+
return new SecretHolder(getEnvVariable("SECRET_ID"), prefix, expectedKeys);
|
46
44
|
}
|
47
45
|
async get() {
|
48
46
|
const secret = await this.getSecret();
|
@@ -50,7 +48,7 @@ class SecretHolder {
|
|
50
48
|
? secret
|
51
49
|
: this.parseSecret(secret, `${this.prefix}.`);
|
52
50
|
if (this.expectedKeys.length > 0) {
|
53
|
-
|
51
|
+
checkExpectedSecretKeys(this.expectedKeys, parsedSecret);
|
54
52
|
}
|
55
53
|
return parsedSecret;
|
56
54
|
}
|
@@ -65,14 +63,11 @@ class SecretHolder {
|
|
65
63
|
return parsed;
|
66
64
|
}
|
67
65
|
async getSecret() {
|
68
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
|
69
66
|
const secret = this.secretCache.get(DEFAULT_SECRET_KEY);
|
70
67
|
if (!secret) {
|
71
68
|
await this.initSecret();
|
72
69
|
}
|
73
|
-
|
74
|
-
return secret ?? this.secretCache.get(DEFAULT_SECRET_KEY);
|
70
|
+
return secret ?? (this.secretCache.get(DEFAULT_SECRET_KEY));
|
75
71
|
}
|
76
72
|
}
|
77
|
-
|
78
|
-
//# sourceMappingURL=secret-holder.js.map
|
73
|
+
//# sourceMappingURL=secret-holder.mjs.map
|
@@ -1,22 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
const aws_sdk_1 = require("aws-sdk");
|
5
|
-
const utils_1 = require("../../../utils/utils");
|
6
|
-
const environment_1 = require("../environment");
|
1
|
+
import { SecretsManager } from "aws-sdk";
|
2
|
+
import { getEnvVariable, getEnvVariableOrElse } from "../../../utils/utils.mjs";
|
3
|
+
import { EnvKeys } from "../environment.mjs";
|
7
4
|
// SECRET_OVERRIDE_AWS_REGION might not have been set before import of
|
8
5
|
// secret, so we need to lazy initialize SecretsManager
|
9
6
|
let smClient;
|
10
7
|
function getSmClient() {
|
11
8
|
if (!smClient) {
|
12
|
-
smClient = new
|
13
|
-
region:
|
14
|
-
|
9
|
+
smClient = new SecretsManager({
|
10
|
+
region: getEnvVariableOrElse(EnvKeys.SECRET_OVERRIDE_AWS_REGION, // this is override secret region
|
11
|
+
getEnvVariable(EnvKeys.AWS_REGION)),
|
15
12
|
});
|
16
13
|
}
|
17
14
|
return smClient;
|
18
15
|
}
|
19
|
-
async function getSecret(secretId, prefix = "") {
|
16
|
+
export async function getSecret(secretId, prefix = "") {
|
20
17
|
const secretObj = await getSmClient()
|
21
18
|
.getSecretValue({
|
22
19
|
SecretId: secretId,
|
@@ -31,7 +28,6 @@ async function getSecret(secretId, prefix = "") {
|
|
31
28
|
}
|
32
29
|
return parseSecret(secret, `${prefix}.`);
|
33
30
|
}
|
34
|
-
exports.getSecret = getSecret;
|
35
31
|
function parseSecret(secret, prefix) {
|
36
32
|
const parsed = {};
|
37
33
|
const skip = prefix.length;
|
@@ -42,4 +38,4 @@ function parseSecret(secret, prefix) {
|
|
42
38
|
}
|
43
39
|
return parsed;
|
44
40
|
}
|
45
|
-
//# sourceMappingURL=secret.
|
41
|
+
//# sourceMappingURL=secret.mjs.map
|
@@ -0,0 +1,12 @@
|
|
1
|
+
// DEPRECATED, remove these!
|
2
|
+
export const NOT_FOUND_MESSAGE = "NOT_FOUND";
|
3
|
+
export const ERROR_MESSAGE = "ERROR";
|
4
|
+
export const OK_MESSAGE = "OK";
|
5
|
+
export const BAD_REQUEST_MESSAGE = "BAD REQUEST";
|
6
|
+
export class ValidationError extends Error {
|
7
|
+
constructor(statusCode, body) {
|
8
|
+
super(body);
|
9
|
+
this.statusCode = statusCode;
|
10
|
+
}
|
11
|
+
}
|
12
|
+
//# sourceMappingURL=errors.mjs.map
|
@@ -1,17 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.LambdaResponse = void 0;
|
7
|
-
const etag_1 = __importDefault(require("etag"));
|
8
|
-
class LambdaResponse {
|
1
|
+
import etag from "etag";
|
2
|
+
export class LambdaResponse {
|
9
3
|
constructor(status, body, fileName, timestamp) {
|
10
4
|
this.status = status;
|
11
5
|
this.body = body;
|
12
6
|
this.fileName = fileName;
|
13
7
|
this.timestamp = timestamp?.toUTCString();
|
14
|
-
this.etag = (
|
8
|
+
this.etag = etag(body); // create strong etag by default
|
15
9
|
}
|
16
10
|
withTimestamp(timestamp) {
|
17
11
|
return new LambdaResponse(this.status, this.body, this.fileName, timestamp);
|
@@ -65,8 +59,7 @@ class LambdaResponse {
|
|
65
59
|
return new LambdaResponse(status, base64Body, fileName);
|
66
60
|
}
|
67
61
|
}
|
68
|
-
exports.LambdaResponse = LambdaResponse;
|
69
62
|
function toBase64(body) {
|
70
63
|
return Buffer.from(body).toString("base64");
|
71
64
|
}
|
72
|
-
//# sourceMappingURL=lambda-response.
|
65
|
+
//# sourceMappingURL=lambda-response.mjs.map
|
@@ -1,8 +1,5 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.MediaType = void 0;
|
4
1
|
// charset=UTF-8 is deprecated but mobile applications sometimes needs it
|
5
|
-
var MediaType;
|
2
|
+
export var MediaType;
|
6
3
|
(function (MediaType) {
|
7
4
|
MediaType["APPLICATION_JSON"] = "application/json";
|
8
5
|
MediaType["APPLICATION_XML"] = "application/xml";
|
@@ -13,5 +10,5 @@ var MediaType;
|
|
13
10
|
MediaType["TEXT_HTML"] = "text/html";
|
14
11
|
MediaType["TEXT_CSV"] = "text/csv";
|
15
12
|
MediaType["APPLICATION_JSON_UTF8"] = "application/json;charset=UTF-8";
|
16
|
-
})(MediaType || (
|
17
|
-
//# sourceMappingURL=mediatypes.
|
13
|
+
})(MediaType || (MediaType = {}));
|
14
|
+
//# sourceMappingURL=mediatypes.mjs.map
|
@@ -1,23 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
const pg_promise_1 = require("pg-promise");
|
5
|
-
const PS_UPDATE_CACHE_VALUE = new pg_promise_1.PreparedStatement({
|
1
|
+
import pg from "pg-promise";
|
2
|
+
const { PreparedStatement } = pg;
|
3
|
+
const PS_UPDATE_CACHE_VALUE = new PreparedStatement({
|
6
4
|
name: "update-cache-value",
|
7
5
|
text: `insert into cached_json(cache_id, content, last_updated)
|
8
6
|
values ($1, $2, $3)
|
9
7
|
on conflict(cache_id) do
|
10
8
|
update set content = $2, last_updated = $3`,
|
11
9
|
});
|
12
|
-
const PS_GET_CACHE_VALUE = new
|
10
|
+
const PS_GET_CACHE_VALUE = new PreparedStatement({
|
13
11
|
name: "get-cache-value",
|
14
12
|
text: "select content, last_updated, modified from cached_json where cache_id = $1",
|
15
13
|
});
|
16
|
-
var JSON_CACHE_KEY;
|
14
|
+
export var JSON_CACHE_KEY;
|
17
15
|
(function (JSON_CACHE_KEY) {
|
18
16
|
JSON_CACHE_KEY["NAUTICAL_WARNINGS_ACTIVE"] = "nautical-warnings-active";
|
19
17
|
JSON_CACHE_KEY["NAUTICAL_WARNINGS_ARCHIVED"] = "nautical-warnings-archived";
|
20
|
-
})(JSON_CACHE_KEY || (
|
18
|
+
})(JSON_CACHE_KEY || (JSON_CACHE_KEY = {}));
|
21
19
|
/**
|
22
20
|
*
|
23
21
|
* @param db
|
@@ -25,22 +23,19 @@ var JSON_CACHE_KEY;
|
|
25
23
|
* @param value
|
26
24
|
* @param lastUpdated time when data was created or updated
|
27
25
|
*/
|
28
|
-
async function updateCachedJson(db, cacheKey, value, lastUpdated) {
|
26
|
+
export async function updateCachedJson(db, cacheKey, value, lastUpdated) {
|
29
27
|
await db.none(PS_UPDATE_CACHE_VALUE, [cacheKey, value, lastUpdated]);
|
30
28
|
}
|
31
|
-
|
32
|
-
function getJsonFromCache(db, cacheKey) {
|
29
|
+
export function getJsonFromCache(db, cacheKey) {
|
33
30
|
return db
|
34
31
|
.oneOrNone(PS_GET_CACHE_VALUE, [cacheKey])
|
35
32
|
.then((value) => value?.content ?? undefined);
|
36
33
|
}
|
37
|
-
|
38
|
-
async function getFromCache(db, cacheKey) {
|
34
|
+
export async function getFromCache(db, cacheKey) {
|
39
35
|
return db
|
40
36
|
.oneOrNone(PS_GET_CACHE_VALUE, [cacheKey])
|
41
37
|
.then((result) => {
|
42
38
|
return result ?? undefined;
|
43
39
|
});
|
44
40
|
}
|
45
|
-
|
46
|
-
//# sourceMappingURL=cached.js.map
|
41
|
+
//# sourceMappingURL=cached.mjs.map
|