quidproquo-deploy-awscdk 0.0.35 → 0.0.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,12 +1,8 @@
1
1
  {
2
2
  "name": "quidproquo-deploy-awscdk",
3
- "version": "0.0.35",
3
+ "version": "0.0.37",
4
4
  "description": "",
5
5
  "main": "./src/index.ts",
6
- "files": [
7
- "lib/**/*",
8
- "src/**/*"
9
- ],
10
6
  "scripts": {
11
7
  "test": "echo \"Error: no test specified\" && exit 1",
12
8
  "clean": "npx rimraf lib",
package/tsconfig.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "quidproquo-tsconfig",
3
+ "compilerOptions": {
4
+ "outDir": "./lib"
5
+ },
6
+ "include": ["src"],
7
+ "exclude": ["node_modules"]
8
+ }
@@ -1,4 +0,0 @@
1
- import { QPQConfig } from 'quidproquo-core';
2
- export interface DeploymentSettings {
3
- qpqConfig: QPQConfig;
4
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +0,0 @@
1
- export declare enum DeploymentType {
2
- Dev = "development",
3
- Staging = "staging",
4
- Prod = "production"
5
- }
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DeploymentType = void 0;
4
- var DeploymentType;
5
- (function (DeploymentType) {
6
- DeploymentType["Dev"] = "development";
7
- DeploymentType["Staging"] = "staging";
8
- DeploymentType["Prod"] = "production";
9
- })(DeploymentType = exports.DeploymentType || (exports.DeploymentType = {}));
package/lib/QPQApp.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import * as cdk from 'aws-cdk-lib';
2
- export declare const createQPQApp: () => cdk.App;
package/lib/QPQApp.js DELETED
@@ -1,31 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.createQPQApp = void 0;
27
- const cdk = __importStar(require("aws-cdk-lib"));
28
- const createQPQApp = () => {
29
- return new cdk.App();
30
- };
31
- exports.createQPQApp = createQPQApp;
@@ -1,14 +0,0 @@
1
- import { DeploymentSettings } from './DeploymentSettings';
2
- import { Stack } from 'aws-cdk-lib';
3
- import { Construct } from 'constructs';
4
- export interface QPQPrototypeStackProps extends DeploymentSettings {
5
- account: string;
6
- region: string;
7
- apiBuildPath: string;
8
- webBuildPath: string;
9
- lambdaAPIGatewayEventPath?: string;
10
- lambdaEventBridgeEventPath?: string;
11
- }
12
- export declare class QPQPrototypeSingleServiceStack extends Stack {
13
- constructor(scope: Construct, id: string, props: QPQPrototypeStackProps);
14
- }
@@ -1,266 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.QPQPrototypeSingleServiceStack = void 0;
27
- const aws_cdk_lib_1 = require("aws-cdk-lib");
28
- const cdk = __importStar(require("aws-cdk-lib"));
29
- const quidproquo_core_1 = require("quidproquo-core");
30
- const quidproquo_webserver_1 = require("quidproquo-webserver");
31
- const createApiDomainName = (stack, id, stackProps) => {
32
- const apexDomain = quidproquo_webserver_1.qpqWebServerUtils.getFeatureDomainName(stackProps.qpqConfig);
33
- const apiDomainName = `api.${apexDomain}`;
34
- const apexHostedZone = aws_cdk_lib_1.aws_route53.HostedZone.fromLookup(stack, `${id}-apex-hostedZone`, {
35
- domainName: apexDomain,
36
- });
37
- const certificate = new aws_cdk_lib_1.aws_certificatemanager.Certificate(stack, `${id}-api-certificate`, {
38
- domainName: apiDomainName,
39
- certificateName: `api-cert-${quidproquo_core_1.qpqCoreUtils.getAppName(stackProps.qpqConfig)}`,
40
- validation: aws_cdk_lib_1.aws_certificatemanager.CertificateValidation.fromDns(apexHostedZone),
41
- });
42
- const domainName = new aws_cdk_lib_1.aws_apigateway.DomainName(stack, `${id}-api-custom-domain`, {
43
- domainName: apiDomainName,
44
- certificate,
45
- securityPolicy: aws_cdk_lib_1.aws_apigateway.SecurityPolicy.TLS_1_2,
46
- endpointType: aws_cdk_lib_1.aws_apigateway.EndpointType.REGIONAL,
47
- });
48
- new aws_cdk_lib_1.aws_route53.ARecord(stack, `${id}-a-record`, {
49
- zone: apexHostedZone,
50
- recordName: apiDomainName,
51
- target: aws_cdk_lib_1.aws_route53.RecordTarget.fromAlias(new aws_cdk_lib_1.aws_route53_targets.ApiGatewayDomain(domainName)),
52
- });
53
- return domainName;
54
- };
55
- const createWebDistribution = (stack, id, stackProps) => {
56
- const environment = quidproquo_core_1.qpqCoreUtils.getAppFeature(stackProps.qpqConfig);
57
- const apexDomain = quidproquo_webserver_1.qpqWebServerUtils.getFeatureDomainName(stackProps.qpqConfig);
58
- const serviceName = quidproquo_core_1.qpqCoreUtils.getAppName(stackProps.qpqConfig);
59
- // create an s3 bucket
60
- const staticWebFilesBucket = new aws_cdk_lib_1.aws_s3.Bucket(stack, `${id}-web`, {
61
- bucketName: `${serviceName}-${environment}-web`,
62
- // Disable public access to this bucket, CloudFront will do that
63
- publicReadAccess: false,
64
- blockPublicAccess: aws_cdk_lib_1.aws_s3.BlockPublicAccess.BLOCK_ALL,
65
- // Default website file
66
- websiteIndexDocument: 'index.html',
67
- // Allow bucket to auto delete upon cdk:Destroy
68
- removalPolicy: cdk.RemovalPolicy.DESTROY,
69
- autoDeleteObjects: true,
70
- });
71
- // Create OriginAccessIdentity for the bucket.
72
- const websiteOAI = new aws_cdk_lib_1.aws_cloudfront.OriginAccessIdentity(stack, `${id}-website-OAI`);
73
- staticWebFilesBucket.grantRead(websiteOAI);
74
- // Grab the hosted zone we want to add
75
- const serviceHostedZone = aws_cdk_lib_1.aws_route53.HostedZone.fromLookup(stack, 'hosted-zone', {
76
- domainName: apexDomain,
77
- });
78
- // Create a certificate for the distribution - Seems to a bug where Route 53 records not cleaned up
79
- // after removing the DNS Validated certificate see: https://github.com/aws/aws-cdk/issues/3333
80
- // `switch over to using the Certificate with the new built-in (CloudFormation-based) DNS validation`
81
- const validationCertificate = aws_cdk_lib_1.aws_certificatemanager.CertificateValidation.fromDns(serviceHostedZone);
82
- const certificate = new aws_cdk_lib_1.aws_certificatemanager.DnsValidatedCertificate(stack, `${id}-viewer-cert`, {
83
- hostedZone: serviceHostedZone,
84
- domainName: apexDomain,
85
- region: 'us-east-1',
86
- validation: validationCertificate,
87
- });
88
- const viewerCertificate = aws_cdk_lib_1.aws_cloudfront.ViewerCertificate.fromAcmCertificate(certificate, {
89
- aliases: [apexDomain],
90
- });
91
- new aws_cdk_lib_1.aws_s3_deployment.BucketDeployment(stack, `${id}-DeployWebsite`, {
92
- sources: [aws_cdk_lib_1.aws_s3_deployment.Source.asset(stackProps.webBuildPath)],
93
- destinationBucket: staticWebFilesBucket,
94
- });
95
- // Create a cloud front distribution
96
- // TODO: use aws_cloudfront.Distribution
97
- const distribution = new aws_cdk_lib_1.aws_cloudfront.CloudFrontWebDistribution(stack, 'cf-distribution', {
98
- originConfigs: [
99
- {
100
- s3OriginSource: {
101
- s3BucketSource: staticWebFilesBucket,
102
- originAccessIdentity: websiteOAI,
103
- },
104
- behaviors: [
105
- ...[
106
- '/remoteEntry.js',
107
- '/index.js',
108
- '/index.html', // Add this if we need it
109
- ].map((pp) => ({
110
- pathPattern: pp,
111
- maxTtl: cdk.Duration.seconds(0),
112
- minTtl: cdk.Duration.seconds(0),
113
- defaultTtl: cdk.Duration.seconds(0),
114
- })),
115
- {
116
- isDefaultBehavior: true,
117
- },
118
- ],
119
- },
120
- ],
121
- viewerCertificate: viewerCertificate,
122
- errorConfigurations: [
123
- {
124
- errorCode: 404,
125
- responseCode: 200,
126
- responsePagePath: '/',
127
- },
128
- ],
129
- });
130
- // Create a cdn link
131
- new aws_cdk_lib_1.aws_route53.ARecord(stack, `${id}-web-alias`, {
132
- zone: serviceHostedZone,
133
- recordName: apexDomain,
134
- target: aws_cdk_lib_1.aws_route53.RecordTarget.fromAlias(new aws_cdk_lib_1.aws_route53_targets.CloudFrontTarget(distribution)),
135
- });
136
- return distribution;
137
- };
138
- class QPQPrototypeSingleServiceStack extends aws_cdk_lib_1.Stack {
139
- constructor(scope, id, props) {
140
- super(scope, id, {
141
- env: {
142
- account: props.account,
143
- region: props.region,
144
- },
145
- });
146
- const settings = {
147
- environment: quidproquo_core_1.qpqCoreUtils.getAppFeature(props.qpqConfig),
148
- service: quidproquo_core_1.qpqCoreUtils.getAppName(props.qpqConfig),
149
- };
150
- const domainName = createApiDomainName(this, id, props);
151
- createWebDistribution(this, `${id}-web-dist`, props);
152
- const resourceName = (name) => {
153
- return `${settings.service}-${settings.environment}-${name}`;
154
- };
155
- const ownedSecrets = quidproquo_core_1.qpqCoreUtils.getOwnedSecrets(props.qpqConfig).map((secret) => {
156
- const realSecretName = `${secret.key}-${settings.service}-${settings.environment}`;
157
- return {
158
- secretName: secret.key,
159
- realName: realSecretName,
160
- secret: new aws_cdk_lib_1.aws_secretsmanager.Secret(this, `${id}-secret-${secret.key}`, {
161
- secretName: realSecretName,
162
- removalPolicy: cdk.RemovalPolicy.DESTROY,
163
- description: `${settings.environment}-${settings.service}`,
164
- }),
165
- };
166
- });
167
- const ownedParameters = quidproquo_core_1.qpqCoreUtils.getOwnedParameters(props.qpqConfig).map((parameter) => {
168
- const realParameterName = `${parameter.key}-${settings.service}-${settings.environment}`;
169
- return {
170
- parameterName: parameter.key,
171
- realName: realParameterName,
172
- parameter: new aws_cdk_lib_1.aws_ssm.StringParameter(this, `${id}-parameter-${parameter.key}`, {
173
- parameterName: realParameterName,
174
- description: `${settings.environment}-${settings.service}`,
175
- stringValue: parameter.value,
176
- // No additional costs ~ 4k max size
177
- tier: aws_cdk_lib_1.aws_ssm.ParameterTier.STANDARD,
178
- }),
179
- };
180
- });
181
- const buckets = quidproquo_core_1.qpqCoreUtils.getStorageDriveNames(props.qpqConfig).map((driveName) => {
182
- const bucketName = resourceName(driveName);
183
- const bucket = new aws_cdk_lib_1.aws_s3.Bucket(this, bucketName, {
184
- bucketName: resourceName(driveName),
185
- // Disable public access to this bucket, CloudFront will do that
186
- publicReadAccess: false,
187
- blockPublicAccess: aws_cdk_lib_1.aws_s3.BlockPublicAccess.BLOCK_ALL,
188
- // Allow bucket to auto delete upon cdk:Destroy
189
- removalPolicy: cdk.RemovalPolicy.DESTROY,
190
- autoDeleteObjects: true,
191
- });
192
- return {
193
- driveName,
194
- bucketName: bucketName,
195
- bucket: bucket,
196
- };
197
- });
198
- // This should be all resource names
199
- const runtimeConfigLambdaConfig = {
200
- qpqConfig: props.qpqConfig,
201
- secretNameMap: ownedSecrets.reduce((acc, os) => (Object.assign(Object.assign({}, acc), { [os.secretName]: os.realName })), {}),
202
- parameterNameMap: ownedParameters.reduce((acc, os) => (Object.assign(Object.assign({}, acc), { [os.parameterName]: os.realName })), {}),
203
- resourceNameMap: buckets.reduce((acc, b) => (Object.assign(Object.assign({}, acc), { [b.driveName]: b.bucketName })), {}),
204
- };
205
- const lambdaHandler = new aws_cdk_lib_1.aws_lambda.Function(this, `${settings.environment}-${settings.service}-lambda-rest`, {
206
- functionName: `lambda-rest-${settings.service}-${settings.environment}`,
207
- timeout: cdk.Duration.seconds(25),
208
- runtime: aws_cdk_lib_1.aws_lambda.Runtime.NODEJS_16_X,
209
- memorySize: 1024,
210
- code: aws_cdk_lib_1.aws_lambda.Code.fromAsset(props.apiBuildPath),
211
- handler: 'lambdaAPIGatewayEvent.executeAPIGatewayEvent',
212
- environment: {
213
- TABLES: JSON.stringify([]),
214
- lambdaRuntimeConfig: JSON.stringify(runtimeConfigLambdaConfig),
215
- },
216
- });
217
- // Grant access to the lambda
218
- buckets.forEach((b) => b.bucket.grantReadWrite(lambdaHandler));
219
- ownedSecrets.forEach((os) => os.secret.grantRead(lambdaHandler));
220
- ownedParameters.forEach((os) => os.parameter.grantRead(lambdaHandler));
221
- // Create a rest api
222
- const api = new aws_cdk_lib_1.aws_apigateway.LambdaRestApi(this, `${settings.environment}-${settings.service}-http-api`, {
223
- restApiName: `${settings.environment}-${settings.service}-http-api`,
224
- handler: lambdaHandler,
225
- deployOptions: {
226
- loggingLevel: aws_cdk_lib_1.aws_apigateway.MethodLoggingLevel.INFO,
227
- dataTraceEnabled: true,
228
- },
229
- proxy: true,
230
- });
231
- // Map all requests to this service to /serviceName/*
232
- new aws_cdk_lib_1.aws_apigateway.BasePathMapping(this, `${id}-rest-bpm`, {
233
- domainName: domainName,
234
- restApi: api,
235
- // the properties below are optional
236
- // basePath: settings.service,
237
- });
238
- quidproquo_core_1.qpqCoreUtils.getScheduleEvents(props.qpqConfig).forEach((se, index) => {
239
- const schedulerFunction = new aws_cdk_lib_1.aws_lambda.Function(this, `${settings.environment}-${settings.service}-SE-${index}`, {
240
- functionName: `SE-${index}-${se.runtime}-${settings.environment}-${settings.service}`,
241
- timeout: cdk.Duration.minutes(15),
242
- runtime: aws_cdk_lib_1.aws_lambda.Runtime.NODEJS_16_X,
243
- memorySize: 1024,
244
- code: aws_cdk_lib_1.aws_lambda.Code.fromAsset(props.apiBuildPath),
245
- handler: 'lambdaEventBridgeEvent.executeEventBridgeEvent',
246
- environment: {
247
- TABLES: JSON.stringify([]),
248
- lambdaRuntimeConfig: JSON.stringify(Object.assign(Object.assign({}, runtimeConfigLambdaConfig), { lambdaRuntimeConfig: {
249
- src: se.src,
250
- runtime: se.runtime,
251
- } })),
252
- },
253
- });
254
- buckets.forEach((b) => b.bucket.grantReadWrite(schedulerFunction));
255
- ownedSecrets.forEach((os) => os.secret.grantRead(schedulerFunction));
256
- ownedParameters.forEach((os) => os.parameter.grantRead(schedulerFunction));
257
- // EventBridge rule which runs every five minutes
258
- const cronRule = new aws_cdk_lib_1.aws_events.Rule(this, `${id}-se-cronrule-${index}`, {
259
- schedule: aws_cdk_lib_1.aws_events.Schedule.expression(`cron(${se.cronExpression})`),
260
- });
261
- // Set the target as lambda function
262
- cronRule.addTarget(new aws_cdk_lib_1.aws_events_targets.LambdaFunction(schedulerFunction));
263
- });
264
- }
265
- }
266
- exports.QPQPrototypeSingleServiceStack = QPQPrototypeSingleServiceStack;
package/lib/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export * from './utils';
2
- export * from './DeploymentType';
3
- export * from './DeploymentSettings';
4
- export * from './QPQApp';
5
- export * from './QPQPrototypeSingleServiceStack';
package/lib/index.js DELETED
@@ -1,21 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./utils"), exports);
18
- __exportStar(require("./DeploymentType"), exports);
19
- __exportStar(require("./DeploymentSettings"), exports);
20
- __exportStar(require("./QPQApp"), exports);
21
- __exportStar(require("./QPQPrototypeSingleServiceStack"), exports);
@@ -1,3 +0,0 @@
1
- export * from './lambdaConfig';
2
- export * from './lambdaAPIGatewayEvent';
3
- export * from './lambdaEventBridgeEvent';
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./lambdaConfig"), exports);
18
- __exportStar(require("./lambdaAPIGatewayEvent"), exports);
19
- __exportStar(require("./lambdaEventBridgeEvent"), exports);
@@ -1,13 +0,0 @@
1
- import { DynamicModuleLoader } from 'quidproquo-actionprocessor-awslambda';
2
- import { Context } from 'aws-lambda';
3
- import { ActionProcessorListResolver } from './lambdaConfig';
4
- export declare const getAPIGatewayEventExecutor: (dynamicModuleLoader: DynamicModuleLoader, getCustomActionProcessors?: ActionProcessorListResolver) => (event: import("aws-lambda").APIGatewayProxyEvent, context: Context) => Promise<{
5
- statusCode: any;
6
- body: string;
7
- headers: any;
8
- }>;
9
- export declare const executeAPIGatewayEvent: (event: import("aws-lambda").APIGatewayProxyEvent, context: Context) => Promise<{
10
- statusCode: any;
11
- body: string;
12
- headers: any;
13
- }>;
@@ -1,77 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.executeAPIGatewayEvent = exports.getAPIGatewayEventExecutor = void 0;
16
- const quidproquo_actionprocessor_node_1 = require("quidproquo-actionprocessor-node");
17
- const quidproquo_actionprocessor_awslambda_1 = require("quidproquo-actionprocessor-awslambda");
18
- const quidproquo_webserver_1 = require("quidproquo-webserver");
19
- const quidproquo_core_1 = require("quidproquo-core");
20
- const lambdaConfig_1 = require("./lambdaConfig");
21
- // @ts-ignore - Special webpack loader
22
- const qpq_dynamic_loader_1 = __importDefault(require("qpq-dynamic-loader!"));
23
- // TODO: Make this a util or something based on server time or something..
24
- const getDateNow = () => new Date().toISOString();
25
- const ErrorTypeHttpResponseMap = {
26
- [quidproquo_core_1.ErrorTypeEnum.BadRequest]: 400,
27
- [quidproquo_core_1.ErrorTypeEnum.Unauthorized]: 401,
28
- [quidproquo_core_1.ErrorTypeEnum.PaymentRequired]: 402,
29
- [quidproquo_core_1.ErrorTypeEnum.Forbidden]: 403,
30
- [quidproquo_core_1.ErrorTypeEnum.NotFound]: 404,
31
- [quidproquo_core_1.ErrorTypeEnum.TimeOut]: 408,
32
- [quidproquo_core_1.ErrorTypeEnum.UnsupportedMediaType]: 415,
33
- [quidproquo_core_1.ErrorTypeEnum.OutOfResources]: 500,
34
- [quidproquo_core_1.ErrorTypeEnum.GenericError]: 500,
35
- [quidproquo_core_1.ErrorTypeEnum.NotImplemented]: 501,
36
- [quidproquo_core_1.ErrorTypeEnum.NoContent]: 204,
37
- [quidproquo_core_1.ErrorTypeEnum.Invalid]: 422,
38
- };
39
- const getAPIGatewayEventExecutor = (dynamicModuleLoader, getCustomActionProcessors = () => ({})) => {
40
- return (event, context) => __awaiter(void 0, void 0, void 0, function* () {
41
- // Build a processor for the session and stuff
42
- // Remove the non route ones ~ let the story execute action add them
43
- const storyActionProcessor = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, quidproquo_actionprocessor_node_1.coreActionProcessor), quidproquo_actionprocessor_node_1.webserverActionProcessor), (0, quidproquo_actionprocessor_awslambda_1.getAPIGatewayEventActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetSecretActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParameterActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParametersActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), (0, quidproquo_actionprocessor_awslambda_1.getSystemActionProcessor)(dynamicModuleLoader)), (0, quidproquo_actionprocessor_awslambda_1.getFileActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), getCustomActionProcessors(lambdaConfig_1.lambdaRuntimeConfig));
44
- const logger = (result) => __awaiter(void 0, void 0, void 0, function* () {
45
- // addResult(
46
- // envConfig.appName,
47
- // getDateNow(),
48
- // doWeCarePath,
49
- // "route-infrastructure",
50
- // "infrastructure",
51
- // "askRoute",
52
- // result
53
- // );
54
- });
55
- // // Run the callback
56
- const resolveStory = (0, quidproquo_core_1.createRuntime)({}, storyActionProcessor, getDateNow, logger, quidproquo_actionprocessor_awslambda_1.awsLambdaUtils.randomGuid);
57
- const result = yield resolveStory(quidproquo_core_1.askProcessEvent, [event, context]);
58
- // Run the callback
59
- if (!result.error) {
60
- return {
61
- statusCode: result.result.statusCode,
62
- body: JSON.stringify(result.result.body),
63
- headers: result.result.headers,
64
- };
65
- }
66
- console.log(JSON.stringify(result));
67
- const code = ErrorTypeHttpResponseMap[result.error.errorType];
68
- return {
69
- statusCode: code || 500,
70
- body: JSON.stringify(result.error),
71
- headers: quidproquo_webserver_1.qpqWebServerUtils.getCorsHeaders(lambdaConfig_1.lambdaRuntimeConfig.qpqConfig, {}, event.headers),
72
- };
73
- });
74
- };
75
- exports.getAPIGatewayEventExecutor = getAPIGatewayEventExecutor;
76
- // Default executor
77
- exports.executeAPIGatewayEvent = (0, exports.getAPIGatewayEventExecutor)(qpq_dynamic_loader_1.default);
@@ -1,4 +0,0 @@
1
- import { ActionProcessorList } from 'quidproquo-core';
2
- import { QPQAWSLambdaConfig } from 'quidproquo-actionprocessor-awslambda';
3
- export declare const lambdaRuntimeConfig: QPQAWSLambdaConfig;
4
- export type ActionProcessorListResolver = (lambdaRuntimeConfig: QPQAWSLambdaConfig) => ActionProcessorList;
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.lambdaRuntimeConfig = void 0;
4
- exports.lambdaRuntimeConfig = JSON.parse(process.env.lambdaRuntimeConfig || '{}');
@@ -1,5 +0,0 @@
1
- import { DynamicModuleLoader } from 'quidproquo-actionprocessor-awslambda';
2
- import { EventBridgeEvent, Context } from 'aws-lambda';
3
- import { ActionProcessorListResolver } from './lambdaConfig';
4
- export declare const getEventBridgeEventExecutor: (dynamicModuleLoader: DynamicModuleLoader, getCustomActionProcessors?: ActionProcessorListResolver) => (event: EventBridgeEvent<string, void>, context: Context) => Promise<void>;
5
- export declare const executeEventBridgeEvent: (event: EventBridgeEvent<string, void>, context: Context) => Promise<void>;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.executeEventBridgeEvent = exports.getEventBridgeEventExecutor = void 0;
16
- const quidproquo_actionprocessor_node_1 = require("quidproquo-actionprocessor-node");
17
- const quidproquo_actionprocessor_awslambda_1 = require("quidproquo-actionprocessor-awslambda");
18
- const quidproquo_core_1 = require("quidproquo-core");
19
- const lambdaConfig_1 = require("./lambdaConfig");
20
- // @ts-ignore - Special webpack loader
21
- const qpq_dynamic_loader_1 = __importDefault(require("qpq-dynamic-loader!"));
22
- // TODO: Make this a util or something based on server time or something..
23
- const getDateNow = () => new Date().toISOString();
24
- const getEventBridgeEventExecutor = (dynamicModuleLoader, getCustomActionProcessors = () => ({})) => {
25
- return (event, context) => __awaiter(void 0, void 0, void 0, function* () {
26
- // Build a processor for the session and stuff
27
- // Remove the non event ones
28
- const storyActionProcessor = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, quidproquo_actionprocessor_node_1.coreActionProcessor), quidproquo_actionprocessor_node_1.webserverActionProcessor), (0, quidproquo_actionprocessor_awslambda_1.getEventBridgeEventActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), (0, quidproquo_actionprocessor_awslambda_1.getSystemActionProcessor)(dynamicModuleLoader)), (0, quidproquo_actionprocessor_awslambda_1.getFileActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetSecretActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParameterActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParametersActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), getCustomActionProcessors(lambdaConfig_1.lambdaRuntimeConfig));
29
- const logger = (result) => __awaiter(void 0, void 0, void 0, function* () { });
30
- // Run the callback
31
- const resolveStory = (0, quidproquo_core_1.createRuntime)({}, storyActionProcessor, getDateNow, logger, quidproquo_actionprocessor_awslambda_1.awsLambdaUtils.randomGuid);
32
- yield resolveStory(quidproquo_core_1.askProcessEvent, [event, context]);
33
- });
34
- };
35
- exports.getEventBridgeEventExecutor = getEventBridgeEventExecutor;
36
- exports.executeEventBridgeEvent = (0, exports.getEventBridgeEventExecutor)(qpq_dynamic_loader_1.default);
package/lib/utils.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { DeploymentSettings } from './DeploymentSettings';
2
- export declare const getStackName: (deploymentSettings: DeploymentSettings) => string;
package/lib/utils.js DELETED
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getStackName = void 0;
4
- const quidproquo_core_1 = require("quidproquo-core");
5
- const getStackName = (deploymentSettings) => {
6
- const appName = quidproquo_core_1.qpqCoreUtils.getAppName(deploymentSettings.qpqConfig);
7
- const environment = quidproquo_core_1.qpqCoreUtils.getAppFeature(deploymentSettings.qpqConfig);
8
- return `${appName}-${environment}`;
9
- };
10
- exports.getStackName = getStackName;