@jaypie/constructs 1.2.0 → 1.2.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.
@@ -2,9 +2,23 @@ import { IHostedZone } from "aws-cdk-lib/aws-route53";
2
2
  import * as secretsmanager from "aws-cdk-lib/aws-secretsmanager";
3
3
  import { Construct } from "constructs";
4
4
  import { EnvironmentInput, SecretsArrayItem } from "./helpers";
5
+ export interface DomainNameConfig {
6
+ component?: string;
7
+ domain?: string;
8
+ env?: string;
9
+ subdomain?: string;
10
+ }
5
11
  export interface JaypieNextjsProps {
6
12
  datadogApiKeyArn?: string;
7
- domainName?: string;
13
+ /**
14
+ * Domain name for the Next.js application.
15
+ *
16
+ * Supports both string and config object:
17
+ * - String: used directly as the domain name
18
+ * - Object: passed to envHostname() to construct the domain name
19
+ * - { component, domain, env, subdomain }
20
+ */
21
+ domainName?: string | DomainNameConfig;
8
22
  /**
9
23
  * Environment variables for the Next.js application.
10
24
  *
@@ -390,7 +390,8 @@ function envHostname({ component, domain, env, subdomain, } = {}) {
390
390
  throw new errors.ConfigurationError("No hostname `domain` provided. Set CDK_ENV_DOMAIN or CDK_ENV_HOSTED_ZONE to use environment domain");
391
391
  }
392
392
  const resolvedComponent = component === "@" || component === "" ? undefined : component;
393
- const resolvedSubdomain = subdomain || process.env.CDK_ENV_SUBDOMAIN;
393
+ const providedSubdomain = subdomain === "@" || subdomain === "" ? undefined : subdomain;
394
+ const resolvedSubdomain = providedSubdomain || process.env.CDK_ENV_SUBDOMAIN;
394
395
  const resolvedEnv = env || process.env.PROJECT_ENV;
395
396
  const filteredEnv = resolvedEnv === CDK$2.ENV.PRODUCTION ? undefined : resolvedEnv;
396
397
  const parts = [
@@ -2595,7 +2596,9 @@ class JaypieMongoDbSecret extends JaypieEnvSecret {
2595
2596
  class JaypieNextJs extends constructs.Construct {
2596
2597
  constructor(scope, id, props) {
2597
2598
  super(scope, id);
2598
- const domainName = props?.domainName || envHostname();
2599
+ const domainName = typeof props?.domainName === "string"
2600
+ ? props.domainName
2601
+ : envHostname(props?.domainName);
2599
2602
  this.domainName = domainName;
2600
2603
  const domainNameSanitized = domainName
2601
2604
  .replace(/\./g, "-")