@codedazur/cdk-next-app 1.1.1 → 2.0.0

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,25 @@
1
1
  # @codedazur/cdk-next-app
2
2
 
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [`4f12708`](https://github.com/codedazur/toolkit/commit/4f12708f7b35ce7e96af62c10a6f637e347c3c69) Thanks [@thijsdaniels](https://github.com/thijsdaniels)! - Custom domain names with external DNS registry are now supported. A HostedZone will no longer be looked up and must be provided instead if needed.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`4f12708`](https://github.com/codedazur/toolkit/commit/4f12708f7b35ce7e96af62c10a6f637e347c3c69)]:
12
+ - @codedazur/cdk-docker-cluster@2.0.0
13
+
14
+ ## 1.1.2
15
+
16
+ ### Patch Changes
17
+
18
+ - [`9546c16`](https://github.com/codedazur/toolkit/commit/9546c1604999d28552cda24cb998dae0e5d5cbe3) Thanks [@thijsdaniels](https://github.com/thijsdaniels)! - Cache policies are now configured for the Next.js application.
19
+
20
+ - Updated dependencies [[`2734c9d`](https://github.com/codedazur/toolkit/commit/2734c9d2f1a6fbdbae8e7d676b1e06437200df23), [`62b823b`](https://github.com/codedazur/toolkit/commit/62b823bfb366f0b7b037b0485aafe7084fe3743f)]:
21
+ - @codedazur/cdk-docker-cluster@1.1.2
22
+
3
23
  ## 1.1.1
4
24
 
5
25
  ### Patch Changes
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
@@ -1,46 +1,13 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
- var index_exports = {};
32
- __export(index_exports, {
33
- NextApp: () => NextApp
34
- });
35
- module.exports = __toCommonJS(index_exports);
36
-
37
1
  // src/constructs/NextApp.ts
38
- var import_os = __toESM(require("os"));
39
- var import_path = __toESM(require("path"));
40
- var import_cdk_docker_cluster = require("@codedazur/cdk-docker-cluster");
41
- var import_aws_cdk_lib = require("aws-cdk-lib");
42
- var import_aws_ecs = require("aws-cdk-lib/aws-ecs");
43
- var NextApp = class _NextApp extends import_cdk_docker_cluster.DockerCluster {
2
+ import os from "os";
3
+ import path from "path";
4
+ import {
5
+ DockerCluster
6
+ } from "@codedazur/cdk-docker-cluster";
7
+ import { DockerBuildSecret } from "aws-cdk-lib";
8
+ import { AllowedMethods, CachePolicy } from "aws-cdk-lib/aws-cloudfront";
9
+ import { ContainerImage } from "aws-cdk-lib/aws-ecs";
10
+ var NextApp = class _NextApp extends DockerCluster {
44
11
  constructor(scope, id, {
45
12
  source,
46
13
  service: { port = 3e3, ...service } = {},
@@ -58,16 +25,54 @@ var NextApp = class _NextApp extends import_cdk_docker_cluster.DockerCluster {
58
25
  ...distribution,
59
26
  behaviors: {
60
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
+ */
61
32
  "/api/*": {
62
33
  authentication: false,
34
+ allowedMethods: AllowedMethods.ALLOW_ALL,
35
+ cachePolicy: CachePolicy.CACHING_DISABLED,
63
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/*"]
64
69
  }
65
70
  }
66
71
  }
67
72
  });
68
73
  }
69
74
  static withNpmSecret(source) {
70
- if (source instanceof import_aws_ecs.ContainerImage) {
75
+ if (source instanceof ContainerImage) {
71
76
  return source;
72
77
  }
73
78
  if (typeof source === "string") {
@@ -87,10 +92,9 @@ var NextApp = class _NextApp extends import_cdk_docker_cluster.DockerCluster {
87
92
  };
88
93
  }
89
94
  static npmSecret() {
90
- return import_aws_cdk_lib.DockerBuildSecret.fromSrc(import_path.default.join(import_os.default.homedir(), ".npmrc"));
95
+ return DockerBuildSecret.fromSrc(path.join(os.homedir(), ".npmrc"));
91
96
  }
92
97
  };
93
- // Annotate the CommonJS export names for ESM import in node:
94
- 0 && (module.exports = {
98
+ export {
95
99
  NextApp
96
- });
100
+ };
@@ -0,0 +1,6 @@
1
+ import { distribution } from "@codedazur/eslint-config";
2
+ import { cdk } from "@codedazur/eslint-config/cdk";
3
+ import { defineConfig } from "eslint/config";
4
+ import root from "../../eslint.config";
5
+
6
+ export default defineConfig(root, cdk, distribution);
package/package.json CHANGED
@@ -1,25 +1,20 @@
1
1
  {
2
2
  "name": "@codedazur/cdk-next-app",
3
- "version": "1.1.1",
4
- "main": ".dist/index.js",
5
- "module": "./dist/index.mjs",
3
+ "version": "2.0.0",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
- "exports": {
8
- ".": {
9
- "require": "./dist/index.js",
10
- "import": "./dist/index.mjs"
11
- }
12
- },
7
+ "exports": "./dist/index.js",
13
8
  "publishConfig": {
14
9
  "access": "public"
15
10
  },
16
11
  "license": "MIT",
17
12
  "sideEffects": false,
18
13
  "scripts": {
19
- "develop": "tsup src/index.ts --format esm,cjs --dts --watch",
20
- "build": "tsup src/index.ts --format esm,cjs --dts",
14
+ "develop": "tsup src/index.ts --clean --format esm --dts --watch",
15
+ "build": "tsup src/index.ts --clean --format esm --dts",
21
16
  "audit": "npm audit --omit dev --audit-level high",
22
- "lint": "TIMING=1 eslint \"**/*.ts*\"",
17
+ "lint": "eslint .",
23
18
  "types": "tsc --noEmit",
24
19
  "test": "vitest run --passWithNoTests"
25
20
  },
@@ -28,12 +23,12 @@
28
23
  "constructs": ">=10"
29
24
  },
30
25
  "dependencies": {
31
- "@codedazur/cdk-docker-cluster": "^1.1.1"
26
+ "@codedazur/cdk-docker-cluster": "^2.0.0"
32
27
  },
33
28
  "devDependencies": {
34
- "@types/node": "^24.0.3",
35
- "aws-cdk-lib": "^2.201.0",
36
- "constructs": "^10.4.2",
37
- "esbuild": "^0.25.5"
29
+ "@types/node": "^25.0.9",
30
+ "aws-cdk-lib": "^2.235.1",
31
+ "constructs": "^10.4.5",
32
+ "esbuild": "^0.27.2"
38
33
  }
39
34
  }
package/dist/index.d.mts DELETED
@@ -1,28 +0,0 @@
1
- import { DockerClusterProps, DockerCluster } from '@codedazur/cdk-docker-cluster';
2
- import { ContainerImage } from 'aws-cdk-lib/aws-ecs';
3
- import { Construct } from 'constructs';
4
-
5
- interface NextAppProps extends DockerClusterProps {
6
- }
7
- /**
8
- * A docker cluster preconfigured for running a Next.js application with support
9
- * for private NPM packages using a build-time secret.
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
13
- */
14
- declare class NextApp extends DockerCluster {
15
- constructor(scope: Construct, id: string, { source, service: { port, ...service }, distribution, ...props }: NextAppProps);
16
- protected static withNpmSecret(source: NextAppProps["source"]): ContainerImage | {
17
- secrets: {
18
- npmrc: string;
19
- };
20
- directory: string;
21
- exclude?: string[];
22
- file?: string;
23
- arguments?: Record<string, string>;
24
- };
25
- protected static npmSecret(): string;
26
- }
27
-
28
- export { NextApp, type NextAppProps };
package/dist/index.mjs DELETED
@@ -1,61 +0,0 @@
1
- // src/constructs/NextApp.ts
2
- import os from "os";
3
- import path from "path";
4
- import {
5
- DockerCluster
6
- } from "@codedazur/cdk-docker-cluster";
7
- import { DockerBuildSecret } from "aws-cdk-lib";
8
- import { ContainerImage } from "aws-cdk-lib/aws-ecs";
9
- var NextApp = class _NextApp extends DockerCluster {
10
- constructor(scope, id, {
11
- source,
12
- service: { port = 3e3, ...service } = {},
13
- distribution,
14
- ...props
15
- }) {
16
- super(scope, id, {
17
- source: _NextApp.withNpmSecret(source),
18
- ...props,
19
- service: {
20
- port,
21
- ...service
22
- },
23
- distribution: {
24
- ...distribution,
25
- behaviors: {
26
- ...distribution?.behaviors,
27
- "/api/*": {
28
- authentication: false,
29
- ...distribution?.behaviors?.["/api/*"]
30
- }
31
- }
32
- }
33
- });
34
- }
35
- static withNpmSecret(source) {
36
- if (source instanceof ContainerImage) {
37
- return source;
38
- }
39
- if (typeof source === "string") {
40
- return {
41
- directory: source,
42
- secrets: {
43
- npmrc: _NextApp.npmSecret()
44
- }
45
- };
46
- }
47
- return {
48
- ...source,
49
- secrets: {
50
- npmrc: _NextApp.npmSecret(),
51
- ...source.secrets
52
- }
53
- };
54
- }
55
- static npmSecret() {
56
- return DockerBuildSecret.fromSrc(path.join(os.homedir(), ".npmrc"));
57
- }
58
- };
59
- export {
60
- NextApp
61
- };