@codedazur/cdk-next-app 1.1.1 → 1.1.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @codedazur/cdk-next-app
2
2
 
3
+ ## 1.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`9546c16`](https://github.com/codedazur/toolkit/commit/9546c1604999d28552cda24cb998dae0e5d5cbe3) Thanks [@thijsdaniels](https://github.com/thijsdaniels)! - Cache policies are now configured for the Next.js application.
8
+
9
+ - Updated dependencies [[`2734c9d`](https://github.com/codedazur/toolkit/commit/2734c9d2f1a6fbdbae8e7d676b1e06437200df23), [`62b823b`](https://github.com/codedazur/toolkit/commit/62b823bfb366f0b7b037b0485aafe7084fe3743f)]:
10
+ - @codedazur/cdk-docker-cluster@1.1.2
11
+
3
12
  ## 1.1.1
4
13
 
5
14
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -8,8 +8,9 @@ interface NextAppProps extends DockerClusterProps {
8
8
  * A docker cluster preconfigured for running a Next.js application with support
9
9
  * for private NPM packages using a build-time secret.
10
10
  *
11
- * @todo Add specific distribution behaviors for the various Next.js features.
12
- * @see https://bitbucket.org/codedazur/cdk-constructs/src/v5.14.0/src/NextSite/NextSite.ts
11
+ * @todo Document and standardize a shared cache pool for Next.js applications
12
+ * that run on multiple containers.
13
+ * @see https://nextjs.org/docs/app/guides/self-hosting#configuring-caching
13
14
  */
14
15
  declare class NextApp extends DockerCluster {
15
16
  constructor(scope: Construct, id: string, { source, service: { port, ...service }, distribution, ...props }: NextAppProps);
package/dist/index.d.ts CHANGED
@@ -8,8 +8,9 @@ interface NextAppProps extends DockerClusterProps {
8
8
  * A docker cluster preconfigured for running a Next.js application with support
9
9
  * for private NPM packages using a build-time secret.
10
10
  *
11
- * @todo Add specific distribution behaviors for the various Next.js features.
12
- * @see https://bitbucket.org/codedazur/cdk-constructs/src/v5.14.0/src/NextSite/NextSite.ts
11
+ * @todo Document and standardize a shared cache pool for Next.js applications
12
+ * that run on multiple containers.
13
+ * @see https://nextjs.org/docs/app/guides/self-hosting#configuring-caching
13
14
  */
14
15
  declare class NextApp extends DockerCluster {
15
16
  constructor(scope: Construct, id: string, { source, service: { port, ...service }, distribution, ...props }: NextAppProps);
package/dist/index.js CHANGED
@@ -39,6 +39,7 @@ var import_os = __toESM(require("os"));
39
39
  var import_path = __toESM(require("path"));
40
40
  var import_cdk_docker_cluster = require("@codedazur/cdk-docker-cluster");
41
41
  var import_aws_cdk_lib = require("aws-cdk-lib");
42
+ var import_aws_cloudfront = require("aws-cdk-lib/aws-cloudfront");
42
43
  var import_aws_ecs = require("aws-cdk-lib/aws-ecs");
43
44
  var NextApp = class _NextApp extends import_cdk_docker_cluster.DockerCluster {
44
45
  constructor(scope, id, {
@@ -58,9 +59,47 @@ var NextApp = class _NextApp extends import_cdk_docker_cluster.DockerCluster {
58
59
  ...distribution,
59
60
  behaviors: {
60
61
  ...distribution?.behaviors,
62
+ /**
63
+ * API routes should not be cached by the CDN.
64
+ * @see https://nextjs.org/docs/app/guides/self-hosting#usage-with-cdns
65
+ */
61
66
  "/api/*": {
62
67
  authentication: false,
68
+ allowedMethods: import_aws_cloudfront.AllowedMethods.ALLOW_ALL,
69
+ cachePolicy: import_aws_cloudfront.CachePolicy.CACHING_DISABLED,
63
70
  ...distribution?.behaviors?.["/api/*"]
71
+ },
72
+ /**
73
+ * Statically generated assets with hashes in the filename. These can
74
+ * be cached forever.
75
+ * @see https://nextjs.org/docs/app/guides/self-hosting#automatic-caching
76
+ */
77
+ "/_next/static/*": {
78
+ allowedMethods: import_aws_cloudfront.AllowedMethods.ALLOW_GET_HEAD_OPTIONS,
79
+ cachePolicy: import_aws_cloudfront.CachePolicy.CACHING_OPTIMIZED,
80
+ ...distribution?.behaviors?.["/_next/static/*"]
81
+ },
82
+ /**
83
+ * Assets for Next.js Image Optimization. Caching is based on query
84
+ * strings. This behavior inherits the default cache policy from the
85
+ * DockerCluster, which should be configured to include query
86
+ * strings in the cache key.
87
+ * @see https://nextjs.org/docs/app/guides/self-hosting#image-optimization
88
+ */
89
+ "/_next/image*": {
90
+ allowedMethods: import_aws_cloudfront.AllowedMethods.ALLOW_GET_HEAD_OPTIONS,
91
+ ...distribution?.behaviors?.["/_next/image*"]
92
+ },
93
+ /**
94
+ * Page data for client-side navigation. Caching should be aligned
95
+ * with the corresponding page. This behavior inherits the default
96
+ * cache policy, which should respect the origin's Cache-Control
97
+ * headers.
98
+ * @see https://nextjs.org/docs/app/guides/self-hosting#caching-and-isr
99
+ */
100
+ "/_next/data/*": {
101
+ allowedMethods: import_aws_cloudfront.AllowedMethods.ALLOW_GET_HEAD_OPTIONS,
102
+ ...distribution?.behaviors?.["/_next/data/*"]
64
103
  }
65
104
  }
66
105
  }
package/dist/index.mjs CHANGED
@@ -5,6 +5,7 @@ import {
5
5
  DockerCluster
6
6
  } from "@codedazur/cdk-docker-cluster";
7
7
  import { DockerBuildSecret } from "aws-cdk-lib";
8
+ import { AllowedMethods, CachePolicy } from "aws-cdk-lib/aws-cloudfront";
8
9
  import { ContainerImage } from "aws-cdk-lib/aws-ecs";
9
10
  var NextApp = class _NextApp extends DockerCluster {
10
11
  constructor(scope, id, {
@@ -24,9 +25,47 @@ var NextApp = class _NextApp extends DockerCluster {
24
25
  ...distribution,
25
26
  behaviors: {
26
27
  ...distribution?.behaviors,
28
+ /**
29
+ * API routes should not be cached by the CDN.
30
+ * @see https://nextjs.org/docs/app/guides/self-hosting#usage-with-cdns
31
+ */
27
32
  "/api/*": {
28
33
  authentication: false,
34
+ allowedMethods: AllowedMethods.ALLOW_ALL,
35
+ cachePolicy: CachePolicy.CACHING_DISABLED,
29
36
  ...distribution?.behaviors?.["/api/*"]
37
+ },
38
+ /**
39
+ * Statically generated assets with hashes in the filename. These can
40
+ * be cached forever.
41
+ * @see https://nextjs.org/docs/app/guides/self-hosting#automatic-caching
42
+ */
43
+ "/_next/static/*": {
44
+ allowedMethods: AllowedMethods.ALLOW_GET_HEAD_OPTIONS,
45
+ cachePolicy: CachePolicy.CACHING_OPTIMIZED,
46
+ ...distribution?.behaviors?.["/_next/static/*"]
47
+ },
48
+ /**
49
+ * Assets for Next.js Image Optimization. Caching is based on query
50
+ * strings. This behavior inherits the default cache policy from the
51
+ * DockerCluster, which should be configured to include query
52
+ * strings in the cache key.
53
+ * @see https://nextjs.org/docs/app/guides/self-hosting#image-optimization
54
+ */
55
+ "/_next/image*": {
56
+ allowedMethods: AllowedMethods.ALLOW_GET_HEAD_OPTIONS,
57
+ ...distribution?.behaviors?.["/_next/image*"]
58
+ },
59
+ /**
60
+ * Page data for client-side navigation. Caching should be aligned
61
+ * with the corresponding page. This behavior inherits the default
62
+ * cache policy, which should respect the origin's Cache-Control
63
+ * headers.
64
+ * @see https://nextjs.org/docs/app/guides/self-hosting#caching-and-isr
65
+ */
66
+ "/_next/data/*": {
67
+ allowedMethods: AllowedMethods.ALLOW_GET_HEAD_OPTIONS,
68
+ ...distribution?.behaviors?.["/_next/data/*"]
30
69
  }
31
70
  }
32
71
  }
@@ -0,0 +1,5 @@
1
+ import { cdk, distribution } from "@codedazur/eslint-config";
2
+ import { defineConfig } from "eslint/config";
3
+ import root from "../../eslint.config";
4
+
5
+ export default defineConfig(root, cdk, distribution);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codedazur/cdk-next-app",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "main": ".dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -19,7 +19,7 @@
19
19
  "develop": "tsup src/index.ts --format esm,cjs --dts --watch",
20
20
  "build": "tsup src/index.ts --format esm,cjs --dts",
21
21
  "audit": "npm audit --omit dev --audit-level high",
22
- "lint": "TIMING=1 eslint \"**/*.ts*\"",
22
+ "lint": "eslint .",
23
23
  "types": "tsc --noEmit",
24
24
  "test": "vitest run --passWithNoTests"
25
25
  },
@@ -28,12 +28,12 @@
28
28
  "constructs": ">=10"
29
29
  },
30
30
  "dependencies": {
31
- "@codedazur/cdk-docker-cluster": "^1.1.1"
31
+ "@codedazur/cdk-docker-cluster": "^1.1.2"
32
32
  },
33
33
  "devDependencies": {
34
- "@types/node": "^24.0.3",
35
- "aws-cdk-lib": "^2.201.0",
36
- "constructs": "^10.4.2",
37
- "esbuild": "^0.25.5"
34
+ "@types/node": "^25.0.3",
35
+ "aws-cdk-lib": "^2.233.0",
36
+ "constructs": "^10.4.4",
37
+ "esbuild": "^0.27.2"
38
38
  }
39
39
  }