quidproquo-deploy-awscdk 0.0.86 → 0.0.87
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.
|
@@ -33,17 +33,6 @@ const qpqDeployAwsCdkUtils = __importStar(require("../../../../utils"));
|
|
|
33
33
|
class QpqWebserverApiConstruct extends QpqConstructBlock_1.QpqConstructBlock {
|
|
34
34
|
constructor(scope, id, props) {
|
|
35
35
|
super(scope, id, props);
|
|
36
|
-
// api.service.domain.com or api.domain.com
|
|
37
|
-
const apexDomain = props.apiConfig.onRootDomain
|
|
38
|
-
? quidproquo_webserver_1.qpqWebServerUtils.getBaseDomainName(props.qpqConfig)
|
|
39
|
-
: quidproquo_webserver_1.qpqWebServerUtils.getServiceDomainName(props.qpqConfig);
|
|
40
|
-
// Create subdomain
|
|
41
|
-
const subdomain = new SubdomainName_1.SubdomainName(this, 'subdomain', {
|
|
42
|
-
apexDomain,
|
|
43
|
-
subdomain: props.apiConfig.apiSubdomain,
|
|
44
|
-
qpqConfig: props.qpqConfig,
|
|
45
|
-
awsAccountId: props.awsAccountId,
|
|
46
|
-
});
|
|
47
36
|
// Build Function
|
|
48
37
|
const func = new Function_1.Function(this, 'api-function', {
|
|
49
38
|
buildPath: quidproquo_webserver_1.qpqWebServerUtils.getApiEntryFullPath(props.qpqConfig, props.apiConfig),
|
|
@@ -58,10 +47,6 @@ class QpqWebserverApiConstruct extends QpqConstructBlock_1.QpqConstructBlock {
|
|
|
58
47
|
grantables.forEach((g) => {
|
|
59
48
|
g.grantAll(func.lambdaFunction);
|
|
60
49
|
});
|
|
61
|
-
// const routes = qpqWebServerUtils.getAllRoutesForApi(props.apiConfig.apiName, props.qpqConfig);
|
|
62
|
-
// const apiKeys = routes.reduce((acc, r) => {
|
|
63
|
-
// return [...acc, ...(r.options.routeAuthSettings?.apiKeys || [])];
|
|
64
|
-
// }, [] as ApiKey[]);
|
|
65
50
|
// Create a rest api
|
|
66
51
|
const api = new aws_cdk_lib_1.aws_apigateway.LambdaRestApi(this, 'lambda-rest-api', {
|
|
67
52
|
restApiName: this.resourceName(`${props.apiConfig.apiName}-rest-api`),
|
|
@@ -72,34 +57,28 @@ class QpqWebserverApiConstruct extends QpqConstructBlock_1.QpqConstructBlock {
|
|
|
72
57
|
},
|
|
73
58
|
binaryMediaTypes: ['*/*'],
|
|
74
59
|
proxy: true,
|
|
75
|
-
// defaultMethodOptions: {
|
|
76
|
-
// apiKeyRequired: apiKeys.length > 0,
|
|
77
|
-
// },
|
|
78
|
-
});
|
|
79
|
-
// const usagePlan = api.addUsagePlan(this.qpqResourceName(props.apiConfig.apiName, 'usagePlan'), {
|
|
80
|
-
// apiStages: [
|
|
81
|
-
// {
|
|
82
|
-
// api,
|
|
83
|
-
// stage: api.deploymentStage,
|
|
84
|
-
// },
|
|
85
|
-
// ],
|
|
86
|
-
// });
|
|
87
|
-
// apiKeys.forEach((apiKey) => {
|
|
88
|
-
// const name = `${props.apiConfig.apiName}-${apiKey.name}`;
|
|
89
|
-
// const newApiKey = api.addApiKey(this.qpqResourceName(name, 'apiKey'), {
|
|
90
|
-
// description: apiKey.description,
|
|
91
|
-
// apiKeyName: this.resourceName(name),
|
|
92
|
-
// value: apiKey.value,
|
|
93
|
-
// });
|
|
94
|
-
// // usagePlan.addApiKey(newApiKey);
|
|
95
|
-
// });
|
|
96
|
-
// Map all requests to this service to /serviceName/*
|
|
97
|
-
new aws_cdk_lib_1.aws_apigateway.BasePathMapping(this, 'rest-bpm', {
|
|
98
|
-
domainName: subdomain.domainName,
|
|
99
|
-
restApi: api,
|
|
100
|
-
// the properties below are optional
|
|
101
|
-
// basePath: settings.service,
|
|
102
60
|
});
|
|
61
|
+
// If we have not deprecated this api, then we need to create a subdomain for it
|
|
62
|
+
if (!props.apiConfig.deprecated) {
|
|
63
|
+
// api.service.domain.com or api.domain.com
|
|
64
|
+
const apexDomain = props.apiConfig.onRootDomain
|
|
65
|
+
? quidproquo_webserver_1.qpqWebServerUtils.getBaseDomainName(props.qpqConfig)
|
|
66
|
+
: quidproquo_webserver_1.qpqWebServerUtils.getServiceDomainName(props.qpqConfig);
|
|
67
|
+
// Create subdomain
|
|
68
|
+
const subdomain = new SubdomainName_1.SubdomainName(this, 'subdomain', {
|
|
69
|
+
apexDomain,
|
|
70
|
+
subdomain: props.apiConfig.apiSubdomain,
|
|
71
|
+
qpqConfig: props.qpqConfig,
|
|
72
|
+
awsAccountId: props.awsAccountId,
|
|
73
|
+
});
|
|
74
|
+
// Map all requests to this service to /serviceName/*
|
|
75
|
+
new aws_cdk_lib_1.aws_apigateway.BasePathMapping(this, 'rest-bpm', {
|
|
76
|
+
domainName: subdomain.domainName,
|
|
77
|
+
restApi: api,
|
|
78
|
+
// the properties below are optional
|
|
79
|
+
// basePath: settings.service,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
103
82
|
}
|
|
104
83
|
}
|
|
105
84
|
exports.QpqWebserverApiConstruct = QpqWebserverApiConstruct;
|
|
@@ -106,9 +106,12 @@ const serviceNeedsServiceHostedZone = (qpqConfig) => {
|
|
|
106
106
|
const apiConfigs = quidproquo_core_1.qpqCoreUtils
|
|
107
107
|
.getConfigSettings(qpqConfig, quidproquo_webserver_1.QPQWebServerConfigSettingType.Api)
|
|
108
108
|
.filter((config) => !config.onRootDomain);
|
|
109
|
+
const webEntryConfigs = quidproquo_core_1.qpqCoreUtils
|
|
110
|
+
.getConfigSettings(qpqConfig, quidproquo_webserver_1.QPQWebServerConfigSettingType.WebEntry)
|
|
111
|
+
.filter((config) => !config.domain.onRootDomain);
|
|
109
112
|
// // Or if we are deploying to a feature env ~ like joecoady
|
|
110
113
|
// const hasFeatureName = !!qpqCoreUtils.getApplicationModuleFeature(qpqConfig);
|
|
111
|
-
return apiConfigs.length > 0; // || hasFeatureName;
|
|
114
|
+
return apiConfigs.length > 0 || webEntryConfigs.length > 0; // || hasFeatureName;
|
|
112
115
|
};
|
|
113
116
|
exports.serviceNeedsServiceHostedZone = serviceNeedsServiceHostedZone;
|
|
114
117
|
// Get resources that we can use to grant permissions to lambdas etc
|
package/package.json
CHANGED
|
@@ -19,20 +19,6 @@ export class QpqWebserverApiConstruct extends QpqConstructBlock {
|
|
|
19
19
|
constructor(scope: Construct, id: string, props: QpqWebserverApiConstructProps) {
|
|
20
20
|
super(scope, id, props);
|
|
21
21
|
|
|
22
|
-
// api.service.domain.com or api.domain.com
|
|
23
|
-
const apexDomain = props.apiConfig.onRootDomain
|
|
24
|
-
? qpqWebServerUtils.getBaseDomainName(props.qpqConfig)
|
|
25
|
-
: qpqWebServerUtils.getServiceDomainName(props.qpqConfig);
|
|
26
|
-
|
|
27
|
-
// Create subdomain
|
|
28
|
-
const subdomain = new SubdomainName(this, 'subdomain', {
|
|
29
|
-
apexDomain,
|
|
30
|
-
subdomain: props.apiConfig.apiSubdomain,
|
|
31
|
-
qpqConfig: props.qpqConfig,
|
|
32
|
-
|
|
33
|
-
awsAccountId: props.awsAccountId,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
22
|
// Build Function
|
|
37
23
|
const func = new Function(this, 'api-function', {
|
|
38
24
|
buildPath: qpqWebServerUtils.getApiEntryFullPath(props.qpqConfig, props.apiConfig),
|
|
@@ -59,11 +45,6 @@ export class QpqWebserverApiConstruct extends QpqConstructBlock {
|
|
|
59
45
|
g.grantAll(func.lambdaFunction);
|
|
60
46
|
});
|
|
61
47
|
|
|
62
|
-
// const routes = qpqWebServerUtils.getAllRoutesForApi(props.apiConfig.apiName, props.qpqConfig);
|
|
63
|
-
// const apiKeys = routes.reduce((acc, r) => {
|
|
64
|
-
// return [...acc, ...(r.options.routeAuthSettings?.apiKeys || [])];
|
|
65
|
-
// }, [] as ApiKey[]);
|
|
66
|
-
|
|
67
48
|
// Create a rest api
|
|
68
49
|
const api = new aws_apigateway.LambdaRestApi(this, 'lambda-rest-api', {
|
|
69
50
|
restApiName: this.resourceName(`${props.apiConfig.apiName}-rest-api`),
|
|
@@ -74,38 +55,32 @@ export class QpqWebserverApiConstruct extends QpqConstructBlock {
|
|
|
74
55
|
},
|
|
75
56
|
binaryMediaTypes: ['*/*'],
|
|
76
57
|
proxy: true,
|
|
77
|
-
// defaultMethodOptions: {
|
|
78
|
-
// apiKeyRequired: apiKeys.length > 0,
|
|
79
|
-
// },
|
|
80
58
|
});
|
|
81
59
|
|
|
82
|
-
//
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
// the properties below are optional
|
|
108
|
-
// basePath: settings.service,
|
|
109
|
-
});
|
|
60
|
+
// If we have not deprecated this api, then we need to create a subdomain for it
|
|
61
|
+
if (!props.apiConfig.deprecated) {
|
|
62
|
+
// api.service.domain.com or api.domain.com
|
|
63
|
+
const apexDomain = props.apiConfig.onRootDomain
|
|
64
|
+
? qpqWebServerUtils.getBaseDomainName(props.qpqConfig)
|
|
65
|
+
: qpqWebServerUtils.getServiceDomainName(props.qpqConfig);
|
|
66
|
+
|
|
67
|
+
// Create subdomain
|
|
68
|
+
const subdomain = new SubdomainName(this, 'subdomain', {
|
|
69
|
+
apexDomain,
|
|
70
|
+
subdomain: props.apiConfig.apiSubdomain,
|
|
71
|
+
qpqConfig: props.qpqConfig,
|
|
72
|
+
|
|
73
|
+
awsAccountId: props.awsAccountId,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Map all requests to this service to /serviceName/*
|
|
77
|
+
new aws_apigateway.BasePathMapping(this, 'rest-bpm', {
|
|
78
|
+
domainName: subdomain.domainName,
|
|
79
|
+
restApi: api,
|
|
80
|
+
|
|
81
|
+
// the properties below are optional
|
|
82
|
+
// basePath: settings.service,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
110
85
|
}
|
|
111
86
|
}
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
ApiQPQWebServerConfigSetting,
|
|
16
16
|
QPQWebServerConfigSettingType,
|
|
17
17
|
qpqWebServerUtils,
|
|
18
|
+
WebEntryQPQWebServerConfigSetting,
|
|
18
19
|
} from 'quidproquo-webserver';
|
|
19
20
|
|
|
20
21
|
import {
|
|
@@ -211,10 +212,17 @@ export const serviceNeedsServiceHostedZone = (qpqConfig: QPQConfig) => {
|
|
|
211
212
|
.getConfigSettings<ApiQPQWebServerConfigSetting>(qpqConfig, QPQWebServerConfigSettingType.Api)
|
|
212
213
|
.filter((config) => !config.onRootDomain);
|
|
213
214
|
|
|
215
|
+
const webEntryConfigs = qpqCoreUtils
|
|
216
|
+
.getConfigSettings<WebEntryQPQWebServerConfigSetting>(
|
|
217
|
+
qpqConfig,
|
|
218
|
+
QPQWebServerConfigSettingType.WebEntry,
|
|
219
|
+
)
|
|
220
|
+
.filter((config) => !config.domain.onRootDomain);
|
|
221
|
+
|
|
214
222
|
// // Or if we are deploying to a feature env ~ like joecoady
|
|
215
223
|
// const hasFeatureName = !!qpqCoreUtils.getApplicationModuleFeature(qpqConfig);
|
|
216
224
|
|
|
217
|
-
return apiConfigs.length > 0; // || hasFeatureName;
|
|
225
|
+
return apiConfigs.length > 0 || webEntryConfigs.length > 0; // || hasFeatureName;
|
|
218
226
|
};
|
|
219
227
|
|
|
220
228
|
// Get resources that we can use to grant permissions to lambdas etc
|