@fy-stack/app-construct 0.0.144 → 0.0.145

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.
@@ -11,6 +11,7 @@ export declare class NextAppRouterConstruct extends Construct implements AppCons
11
11
  container: ecs.ContainerDefinition;
12
12
  queue: sqs.Queue | undefined;
13
13
  private readonly static;
14
+ private readonly files;
14
15
  constructor(scope: Construct, id: string, props: NextAppRouterProps);
15
16
  cloudfront(path: string): Record<string, cloudfront.BehaviorOptions>;
16
17
  cloudfrontPolicy(distributionId: string): void;
@@ -1 +1 @@
1
- {"version":3,"file":"next-app-router-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/ecs/apps/next-app-router-construct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAE3C,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AASvC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEvD,KAAK,kBAAkB,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;AAEjD,qBAAa,sBAAuB,SAAQ,SAAU,YAAW,YAAY;IAMjC,OAAO,CAAC,KAAK;IALhD,SAAS,EAAE,GAAG,CAAC,mBAAmB,CAAC;IACnC,KAAK,EAAE,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC;IAEpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;gBAEvB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAU,KAAK,EAAE,kBAAkB;IAe3E,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,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E,MAAM;IAIvC,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC;IAI3C,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;IAO7C,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO;CAG7B"}
@@ -10,17 +10,20 @@ class NextAppRouterConstruct extends constructs_1.Construct {
10
10
  container;
11
11
  queue;
12
12
  static;
13
+ files;
13
14
  constructor(scope, id, props) {
14
15
  super(scope, id);
15
16
  this.props = props;
16
- this.static = (0, next_app_router_1.staticDeployment)(this, props.output);
17
+ const deployment = (0, next_app_router_1.staticDeployment)(this, props.output);
18
+ this.static = deployment.staticBucket;
19
+ this.files = deployment.files;
17
20
  this.container = (0, taskDefinitionImage_1.taskDefinitionImage)(`${props.appName}AppContainer`, {
18
21
  taskDefinition: props.taskDefinition,
19
22
  port: props.port,
20
23
  env: props.env,
21
24
  output: props.output,
22
25
  container: props.container,
23
- environmentPath: props.environmentPath
26
+ environmentPath: props.environmentPath,
24
27
  });
25
28
  }
26
29
  cloudfront(path) {
@@ -28,10 +31,7 @@ class NextAppRouterConstruct extends constructs_1.Construct {
28
31
  if (!origin)
29
32
  throw new Error('No server origin');
30
33
  this.container.addEnvironment('BASE_PATH', basePath);
31
- return {
32
- ...(0, next_app_router_1.serverCloudfrontBehaviour)(this, origin, path),
33
- ...(0, next_app_router_1.staticCloudfrontBehaviour)(this.static, path),
34
- };
34
+ return (0, next_app_router_1.cloudfrontBehaviours)(this, this.static, origin, path, this.files);
35
35
  }
36
36
  cloudfrontPolicy(distributionId) {
37
37
  throw new Error(`cloudfrontPolicy not supported for ${this}`);
@@ -1 +1 @@
1
- {"version":3,"file":"ecs-server-construct.d.ts","sourceRoot":"","sources":["../../../src/lib/ecs/ecs-server-construct.ts"],"names":[],"mappings":"AAGA,OAAO,EAAW,KAAK,EAAE,SAAS,EAAgB,MAAM,iBAAiB,CAAC;AAG1E,OAAO,KAAK,GAAG,MAA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C3C,OAAO,KAAK,KAAK,MAAM,wCAAwC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAO1D,KAAK,uBAAuB,GAAG,iBAAiB,CAAC,QAAQ,CAAC,GAAG;IAC3D,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC;CACtB,CAAC;AAEF,qBAAa,kBAAmB,SAAQ,SAAU,YAAW,KAAK;IAY9D,OAAO,CAAC,KAAK;IAXR,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAM;IACxC,UAAU,EAAE,GAAG,CAAC,cAAc,CAAC;IAE/B,YAAY,CAAC,EAAE;QACpB,GAAG,EAAE,KAAK,CAAC,wBAAwB,CAAC;QACpC,QAAQ,EAAE,KAAK,CAAC,oBAAoB,CAAC;KACtC,CAAC;gBAGA,KAAK,EAAE,SAAS,EAChB,EAAE,EAAE,MAAM,EACF,KAAK,EAAE,uBAAuB;IAsExC,KAAK,CAAC,GAAG,UAAU,EAAE,SAAS,EAAE,GAAG,IAAI;IAMvC,OAAO,CAAC,YAAY;IA8CpB,gBAAgB;;;;IAuChB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;CA+CxC"}
@@ -49,6 +49,7 @@ class EcsServerConstruct extends constructs_1.Construct {
49
49
  : ec2.SubnetType.PRIVATE_WITH_EGRESS,
50
50
  },
51
51
  securityGroups: [appSecurityGroup],
52
+ propagateTags: ecs.PropagatedTagSource.SERVICE,
52
53
  ...serverProps,
53
54
  });
54
55
  const serverOrigin = (port, containerName, appPath, healthPath) => this.serverOrigin(service, port, containerName, appPath, healthPath);
@@ -18,6 +18,7 @@ export declare class NextAppRouterConstruct extends Construct implements AppCons
18
18
  function: lambda.Function;
19
19
  queue: sqs.Queue | undefined;
20
20
  private readonly static;
21
+ private readonly files;
21
22
  constructor(scope: Construct, id: string, props: AppProperties<z.infer<typeof BuildParamsSchema>>);
22
23
  cloudfront(path: string): Record<string, cloudfront.BehaviorOptions>;
23
24
  cloudfrontPolicy(distributionId: string): void;
@@ -1 +1 @@
1
- {"version":3,"file":"next-app-router-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/lambda/apps/next-app-router-construct.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AAEzD,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAIvD,QAAA,MAAM,iBAAiB;;;;;;EAErB,CAAC;AAEH,qBAAa,sBAAuB,SAAQ,SAAU,YAAW,YAAY;IACpE,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC1B,KAAK,EAAE,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC;IAEpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;gBAGjC,KAAK,EAAE,SAAS,EAChB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAqCzD,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,eAAe,CAA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CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAwCzD,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,eAAe,CAAC;IAiBpE,gBAAgB,CAAC,cAAc,EAAE,MAAM;IAIvC,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC;IAI3C,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;IAI7C,KAAK,CAAC,GAAG,MAAM,EAAE,SAAS,EAAE;IAI5B,YAAY,IAAI,kBAAkB;IAIlC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO;;;CAG7B"}
@@ -19,10 +19,13 @@ class NextAppRouterConstruct extends constructs_1.Construct {
19
19
  function;
20
20
  queue;
21
21
  static;
22
+ files;
22
23
  constructor(scope, id, props) {
23
24
  super(scope, id);
24
25
  const region = cdk.Stack.of(this).region;
25
- this.static = (0, next_app_router_1.staticDeployment)(this, props.output);
26
+ const deployment = (0, next_app_router_1.staticDeployment)(this, props.output);
27
+ this.static = deployment.staticBucket;
28
+ this.files = deployment.files;
26
29
  const webAdapterLayer = lambda.LayerVersion.fromLayerVersionArn(this, 'WebAdapterLayer', `arn:aws:lambda:${region}:753240598075:layer:LambdaAdapterLayerX86:25`);
27
30
  const environment = {
28
31
  AWS_LAMBDA_EXEC_WRAPPER: '/opt/bootstrap',
@@ -50,10 +53,7 @@ class NextAppRouterConstruct extends constructs_1.Construct {
50
53
  invokeMode: lambda.InvokeMode.RESPONSE_STREAM,
51
54
  });
52
55
  const serverOrigin = new cloudfrontOrigin.FunctionUrlOrigin(webUrl);
53
- return {
54
- ...(0, next_app_router_1.serverCloudfrontBehaviour)(this, serverOrigin, path),
55
- ...(0, next_app_router_1.staticCloudfrontBehaviour)(this.static, path),
56
- };
56
+ return (0, next_app_router_1.cloudfrontBehaviours)(this, this.static, serverOrigin, path, this.files);
57
57
  }
58
58
  cloudfrontPolicy(distributionId) {
59
59
  throw new Error(`cloudfrontPolicy not supported for ${this}`);
@@ -1,12 +1,20 @@
1
1
  import * as cdk from 'aws-cdk-lib';
2
2
  import * as cloudfront from 'aws-cdk-lib/aws-cloudfront';
3
3
  import * as s3 from 'aws-cdk-lib/aws-s3';
4
+ import * as s3Deploy from 'aws-cdk-lib/aws-s3-deployment';
4
5
  import { Construct } from 'constructs';
5
- export declare function staticDeployment(app: Construct, output: string): cdk.aws_s3.Bucket;
6
- export declare function staticCloudfrontBehaviour(staticBucket: s3.Bucket, basePath: string): {
7
- [x: string]: cdk.aws_cloudfront.BehaviorOptions;
6
+ export type AppFile = {
7
+ staticFiles: s3Deploy.ISource;
8
+ publicFiles: s3Deploy.ISource;
9
+ };
10
+ export declare function staticDeployment(app: Construct, output: string): {
11
+ staticBucket: cdk.aws_s3.Bucket;
12
+ files: {
13
+ staticFiles: cdk.aws_s3_deployment.ISource;
14
+ publicFiles: cdk.aws_s3_deployment.ISource;
15
+ };
8
16
  };
9
- export declare function serverCloudfrontBehaviour(app: Construct, serverOrigin: cloudfront.IOrigin, basePath: string): {
17
+ export declare function cloudfrontBehaviours(app: Construct, staticBucket: s3.Bucket, serverOrigin: cloudfront.IOrigin, basePath: string, files: AppFile): {
10
18
  [x: string]: cdk.aws_cloudfront.BehaviorOptions;
11
19
  };
12
20
  //# sourceMappingURL=next-app-router.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"next-app-router.d.ts","sourceRoot":"","sources":["../../../src/lib/shared/next-app-router.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AACnC,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AAEzD,OAAO,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,qBAgC9D;AAED,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,EAAE,CAAC,MAAM,EACvB,QAAQ,EAAE,MAAM;;EAqBjB;AAED,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,SAAS,EACd,YAAY,EAAE,UAAU,CAAC,OAAO,EAChC,QAAQ,EAAE,MAAM;;EA6BjB"}
1
+ {"version":3,"file":"next-app-router.d.ts","sourceRoot":"","sources":["../../../src/lib/shared/next-app-router.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AACnC,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AAEzD,OAAO,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,KAAK,QAAQ,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,MAAM,OAAO,GAAG;IACpB,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC;IAC9B,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC;CAC/B,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM;;;;;;EAsC9D;AAED,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,SAAS,EACd,YAAY,EAAE,EAAE,CAAC,MAAM,EACvB,YAAY,EAAE,UAAU,CAAC,OAAO,EAChC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO;;EA+Df"}
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.staticDeployment = staticDeployment;
4
- exports.staticCloudfrontBehaviour = staticCloudfrontBehaviour;
5
- exports.serverCloudfrontBehaviour = serverCloudfrontBehaviour;
4
+ exports.cloudfrontBehaviours = cloudfrontBehaviours;
6
5
  const tslib_1 = require("tslib");
7
6
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
8
7
  const cdk = tslib_1.__importStar(require("aws-cdk-lib"));
@@ -26,21 +25,41 @@ function staticDeployment(app, output) {
26
25
  },
27
26
  ],
28
27
  });
28
+ const staticFiles = s3Deploy.Source.asset(node_path_1.default.join(output, '/.next/static'));
29
+ const publicFiles = s3Deploy.Source.asset(node_path_1.default.join(output, '/public'));
29
30
  new s3Deploy.BucketDeployment(app, `StaticDeployment`, {
30
31
  destinationBucket: staticBucket,
31
- sources: [s3Deploy.Source.asset(node_path_1.default.join(output, '/.next/static'))],
32
+ sources: [staticFiles],
32
33
  destinationKeyPrefix: '_next/static',
33
34
  retainOnDelete: false,
34
35
  });
35
36
  new s3Deploy.BucketDeployment(app, `PublicDeployment`, {
36
37
  destinationBucket: staticBucket,
37
- sources: [s3Deploy.Source.asset(node_path_1.default.join(output, '/public'))],
38
+ sources: [publicFiles],
38
39
  destinationKeyPrefix: '',
39
40
  retainOnDelete: false,
40
41
  });
41
- return staticBucket;
42
+ return {
43
+ staticBucket,
44
+ files: { staticFiles, publicFiles },
45
+ };
42
46
  }
43
- function staticCloudfrontBehaviour(staticBucket, basePath) {
47
+ function cloudfrontBehaviours(app, staticBucket, serverOrigin, basePath, files) {
48
+ if (basePath) {
49
+ // redeploy files for apps hosted in sub path
50
+ new s3Deploy.BucketDeployment(app, `${basePath}StaticDeployment`, {
51
+ destinationBucket: staticBucket,
52
+ sources: [files.staticFiles],
53
+ destinationKeyPrefix: `${basePath}/_next/static`,
54
+ retainOnDelete: false,
55
+ });
56
+ new s3Deploy.BucketDeployment(app, `${basePath}PublicDeployment`, {
57
+ destinationBucket: staticBucket,
58
+ sources: [files.publicFiles],
59
+ destinationKeyPrefix: basePath,
60
+ retainOnDelete: false,
61
+ });
62
+ }
44
63
  const staticOrigin = new cloudfrontOrigin.S3StaticWebsiteOrigin(staticBucket);
45
64
  const staticBehavior = {
46
65
  origin: staticOrigin,
@@ -50,16 +69,6 @@ function staticCloudfrontBehaviour(staticBucket, basePath) {
50
69
  compress: true,
51
70
  viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
52
71
  };
53
- return {
54
- [`${basePath}/_next/*`]: staticBehavior,
55
- [`${basePath}/*.ico`]: staticBehavior,
56
- [`${basePath}/*.png`]: staticBehavior,
57
- [`${basePath}/*.svg`]: staticBehavior,
58
- [`${basePath}/*.jpg`]: staticBehavior,
59
- [`${basePath}/*.jpeg`]: staticBehavior,
60
- };
61
- }
62
- function serverCloudfrontBehaviour(app, serverOrigin, basePath) {
63
72
  const imageCachePolicy = new cloudfront.CachePolicy(app, 'ImagePolicy', {
64
73
  queryStringBehavior: cloudfront.CacheQueryStringBehavior.all(),
65
74
  maxTtl: cdk.Duration.days(365),
@@ -77,11 +86,17 @@ function serverCloudfrontBehaviour(app, serverOrigin, basePath) {
77
86
  .CORS_ALLOW_ALL_ORIGINS_WITH_PREFLIGHT_AND_SECURITY_HEADERS,
78
87
  };
79
88
  return {
80
- [`${basePath}/*`]: appBehaviour,
81
89
  [`${basePath}/_next/image`]: {
82
90
  ...appBehaviour,
83
91
  cachePolicy: imageCachePolicy,
84
92
  allowedMethods: cloudfront.AllowedMethods.ALLOW_GET_HEAD,
85
93
  },
94
+ [`${basePath}/_next/*`]: staticBehavior,
95
+ [`${basePath}/*.ico`]: staticBehavior,
96
+ [`${basePath}/*.png`]: staticBehavior,
97
+ [`${basePath}/*.svg`]: staticBehavior,
98
+ [`${basePath}/*.jpg`]: staticBehavior,
99
+ [`${basePath}/*.jpeg`]: staticBehavior,
100
+ [`${basePath}/*`]: appBehaviour,
86
101
  };
87
102
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@fy-stack/app-construct",
3
- "version": "0.0.144",
3
+ "version": "0.0.145",
4
4
  "repository": "https://github.com/festusyuma/fy-stack",
5
5
  "dependencies": {
6
- "@fy-stack/types": "0.0.144",
6
+ "@fy-stack/types": "0.0.145",
7
7
  "tslib": "^2.3.0",
8
8
  "zod": "^3.24.1"
9
9
  },