@fy-stack/cdn-construct 0.0.145 → 0.0.147-0-preview
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cdn-construct.d.ts","sourceRoot":"","sources":["../../src/lib/cdn-construct.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,iBAAiB,CAAC;AAE/D,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AAGzD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"cdn-construct.d.ts","sourceRoot":"","sources":["../../src/lib/cdn-construct.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,iBAAiB,CAAC;AAE/D,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AAGzD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,iBAAiB,EAAc,MAAM,SAAS,CAAC;AAExD;;;GAGG;AACH,qBAAa,YAAa,SAAQ,SAAU,YAAW,UAAU;IACxD,YAAY,EAAE,UAAU,CAAC,YAAY,CAAC;IACtC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;gBAE1B,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB;IA8HlE,OAAO,CAAC,WAAW;IAKnB,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAKrC"}
|
|
@@ -18,20 +18,21 @@ class CDNConstruct extends constructs_1.Construct {
|
|
|
18
18
|
super(scope, id);
|
|
19
19
|
const routes = {};
|
|
20
20
|
Object.assign(routes, Object.fromEntries(Object.entries(props.routes).map(([key, val]) => {
|
|
21
|
-
const
|
|
22
|
-
if (!
|
|
23
|
-
throw new Error(`"${val.$resource}"
|
|
24
|
-
return [key,
|
|
21
|
+
const resource = props.resources?.[val.$resource];
|
|
22
|
+
if (!resource)
|
|
23
|
+
throw new Error(`"${val.$resource}" resource not found`);
|
|
24
|
+
return [key, { resource, ...val }];
|
|
25
25
|
})));
|
|
26
26
|
const { '/*': base, ...otherRoutes } = routes;
|
|
27
27
|
if (!base)
|
|
28
28
|
throw new Error('no base route');
|
|
29
|
-
const { '/*': defaultBehavior, ...additionalDefaultBehaviors } = base.cloudfront('');
|
|
29
|
+
const { '/*': defaultBehavior, ...additionalDefaultBehaviors } = base.resource.cloudfront('');
|
|
30
30
|
if (!defaultBehavior)
|
|
31
31
|
throw new Error('no default behaviour');
|
|
32
32
|
const additionalBehaviors = {};
|
|
33
33
|
for (const i in otherRoutes) {
|
|
34
|
-
|
|
34
|
+
const routeBehaviour = otherRoutes[i]?.resource.cloudfront(i);
|
|
35
|
+
Object.assign(additionalBehaviors, routeBehaviour);
|
|
35
36
|
}
|
|
36
37
|
Object.assign(additionalBehaviors, additionalDefaultBehaviors);
|
|
37
38
|
let certificate;
|
|
@@ -72,6 +73,7 @@ class CDNConstruct extends constructs_1.Construct {
|
|
|
72
73
|
? [this.domainName, ...subjectAlternativeNames]
|
|
73
74
|
: undefined,
|
|
74
75
|
priceClass: cloudfront.PriceClass.PRICE_CLASS_100,
|
|
76
|
+
enableLogging: true,
|
|
75
77
|
});
|
|
76
78
|
if (props.domains) {
|
|
77
79
|
const distributionTarget = new route53Targets.CloudFrontTarget(this.distribution);
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { CDNResource, ResourceRef } from '@fy-stack/types';
|
|
2
|
+
export type RouteProps = {
|
|
3
|
+
public?: false;
|
|
4
|
+
keys?: string[];
|
|
5
|
+
};
|
|
2
6
|
export interface CDNConstructProps {
|
|
3
7
|
/**
|
|
4
8
|
* A mapping of route paths to resource references
|
|
5
9
|
* */
|
|
6
|
-
routes: Record<string, ResourceRef>;
|
|
10
|
+
routes: Record<string, ResourceRef & RouteProps>;
|
|
7
11
|
/**
|
|
8
12
|
* An optional mapping of resource names to CDN resources.
|
|
9
13
|
* */
|
package/dist/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEhE,MAAM,WAAW,iBAAiB;IAChC;;SAEK;IACL,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEhE,MAAM,MAAM,UAAU,GAAG;IAAE,MAAM,CAAC,EAAE,KAAK,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAE7D,MAAM,WAAW,iBAAiB;IAChC;;SAEK;IACL,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,UAAU,CAAC,CAAC;IACjD;;SAEK;IACL,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAAC,CAAC;IACpD;;SAEK;IACL,OAAO,CAAC,EAAE;QACR;;aAEK;QACL,MAAM,EAAE,MAAM,CAAC;QACf;;;aAGK;QACL,OAAO,EAAE,MAAM,EAAE,CAAC;KACnB,EAAE,CAAC;CACL"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fy-stack/cdn-construct",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.147-0-preview",
|
|
4
4
|
"repository": "https://github.com/festusyuma/fy-stack",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@fy-stack/types": "0.0.
|
|
6
|
+
"@fy-stack/types": "0.0.147-0-preview",
|
|
7
7
|
"tslib": "^2.3.0"
|
|
8
8
|
},
|
|
9
9
|
"peerDependencies": {
|