@jaypie/constructs 1.1.59 → 1.1.61
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/dist/cjs/JaypieEnvSecret.d.ts +1 -1
- package/dist/cjs/JaypieNextJs.d.ts +1 -0
- package/dist/cjs/index.cjs +26 -6
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/JaypieEnvSecret.d.ts +1 -1
- package/dist/esm/JaypieNextJs.d.ts +1 -0
- package/dist/esm/index.js +26 -6
- package/dist/esm/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -17,7 +17,7 @@ export interface JaypieEnvSecretProps {
|
|
|
17
17
|
export declare class JaypieEnvSecret extends Construct implements ISecret {
|
|
18
18
|
private readonly _envKey?;
|
|
19
19
|
private readonly _secret;
|
|
20
|
-
constructor(scope: Construct,
|
|
20
|
+
constructor(scope: Construct, idOrEnvKey: string, props?: JaypieEnvSecretProps);
|
|
21
21
|
get stack(): Stack;
|
|
22
22
|
get env(): {
|
|
23
23
|
account: string;
|
package/dist/esm/index.js
CHANGED
|
@@ -21,7 +21,6 @@ import * as lambdaEventSources from 'aws-cdk-lib/aws-lambda-event-sources';
|
|
|
21
21
|
import { Rule, RuleTargetInput } from 'aws-cdk-lib/aws-events';
|
|
22
22
|
import { LambdaFunction } from 'aws-cdk-lib/aws-events-targets';
|
|
23
23
|
import { LogGroup, RetentionDays, FilterPattern } from 'aws-cdk-lib/aws-logs';
|
|
24
|
-
import { envHostname as envHostname$1, jaypieLambdaEnv as jaypieLambdaEnv$1, resolveHostedZone as resolveHostedZone$1 } from '@jaypie/constructs';
|
|
25
24
|
import { Nextjs } from 'cdk-nextjs-standalone';
|
|
26
25
|
import * as path from 'path';
|
|
27
26
|
import { Trail, ReadWriteType } from 'aws-cdk-lib/aws-cloudtrail';
|
|
@@ -1660,9 +1659,17 @@ function exportEnvName(name, env = process.env) {
|
|
|
1660
1659
|
return cleanName(rawName);
|
|
1661
1660
|
}
|
|
1662
1661
|
class JaypieEnvSecret extends Construct {
|
|
1663
|
-
constructor(scope,
|
|
1662
|
+
constructor(scope, idOrEnvKey, props) {
|
|
1663
|
+
// Check if idOrEnvKey should be treated as envKey:
|
|
1664
|
+
// - No props provided OR props.envKey is not set
|
|
1665
|
+
// - AND idOrEnvKey exists as a non-empty string in process.env
|
|
1666
|
+
const treatAsEnvKey = (!props || props.envKey === undefined) &&
|
|
1667
|
+
typeof process.env[idOrEnvKey] === "string" &&
|
|
1668
|
+
process.env[idOrEnvKey] !== "";
|
|
1669
|
+
const id = treatAsEnvKey ? `EnvSecret_${idOrEnvKey}` : idOrEnvKey;
|
|
1664
1670
|
super(scope, id);
|
|
1665
|
-
const { consumer = checkEnvIsConsumer(), envKey, export: exportParam, generateSecretString, provider = checkEnvIsProvider(), roleTag, vendorTag, value, } = props || {};
|
|
1671
|
+
const { consumer = checkEnvIsConsumer(), envKey: envKeyProp, export: exportParam, generateSecretString, provider = checkEnvIsProvider(), roleTag, vendorTag, value, } = props || {};
|
|
1672
|
+
const envKey = treatAsEnvKey ? idOrEnvKey : envKeyProp;
|
|
1666
1673
|
this._envKey = envKey;
|
|
1667
1674
|
let exportName;
|
|
1668
1675
|
if (!exportParam) {
|
|
@@ -2168,7 +2175,8 @@ class JaypieMongoDbSecret extends JaypieEnvSecret {
|
|
|
2168
2175
|
class JaypieNextJs extends Construct {
|
|
2169
2176
|
constructor(scope, id, props) {
|
|
2170
2177
|
super(scope, id);
|
|
2171
|
-
const domainName = props?.domainName || envHostname
|
|
2178
|
+
const domainName = props?.domainName || envHostname();
|
|
2179
|
+
this.domainName = domainName;
|
|
2172
2180
|
const domainNameSanitized = domainName
|
|
2173
2181
|
.replace(/\./g, "-")
|
|
2174
2182
|
.replace(/[^a-zA-Z0-9]/g, "_");
|
|
@@ -2193,18 +2201,30 @@ class JaypieNextJs extends Construct {
|
|
|
2193
2201
|
}
|
|
2194
2202
|
return acc;
|
|
2195
2203
|
}, {});
|
|
2204
|
+
// Process NEXT_PUBLIC_ environment variables
|
|
2205
|
+
const nextPublicEnv = Object.entries(process.env).reduce((acc, [key, value]) => {
|
|
2206
|
+
if (key.startsWith("NEXT_PUBLIC_") && value) {
|
|
2207
|
+
return {
|
|
2208
|
+
...acc,
|
|
2209
|
+
[key]: value,
|
|
2210
|
+
};
|
|
2211
|
+
}
|
|
2212
|
+
return acc;
|
|
2213
|
+
}, {});
|
|
2196
2214
|
const nextjs = new Nextjs(this, "NextJsApp", {
|
|
2197
2215
|
nextjsPath,
|
|
2198
2216
|
domainProps: {
|
|
2199
2217
|
domainName,
|
|
2200
|
-
hostedZone: resolveHostedZone
|
|
2218
|
+
hostedZone: resolveHostedZone(this, {
|
|
2201
2219
|
zone: props?.hostedZone,
|
|
2202
2220
|
}),
|
|
2203
2221
|
},
|
|
2204
2222
|
environment: {
|
|
2205
|
-
...jaypieLambdaEnv
|
|
2223
|
+
...jaypieLambdaEnv(),
|
|
2206
2224
|
...secretsEnvironment,
|
|
2207
2225
|
...jaypieSecretsEnvironment,
|
|
2226
|
+
...nextPublicEnv,
|
|
2227
|
+
NEXT_PUBLIC_SITE_URL: `https://${domainName}`,
|
|
2208
2228
|
},
|
|
2209
2229
|
overrides: {
|
|
2210
2230
|
nextjsDistribution: {
|