@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/cjs/index.cjs
CHANGED
|
@@ -19,7 +19,6 @@ var lambdaEventSources = require('aws-cdk-lib/aws-lambda-event-sources');
|
|
|
19
19
|
var awsEvents = require('aws-cdk-lib/aws-events');
|
|
20
20
|
var awsEventsTargets = require('aws-cdk-lib/aws-events-targets');
|
|
21
21
|
var awsLogs = require('aws-cdk-lib/aws-logs');
|
|
22
|
-
var constructs$1 = require('@jaypie/constructs');
|
|
23
22
|
var cdkNextjsStandalone = require('cdk-nextjs-standalone');
|
|
24
23
|
var path = require('path');
|
|
25
24
|
var awsCloudtrail = require('aws-cdk-lib/aws-cloudtrail');
|
|
@@ -1691,9 +1690,17 @@ function exportEnvName(name, env = process.env) {
|
|
|
1691
1690
|
return cleanName(rawName);
|
|
1692
1691
|
}
|
|
1693
1692
|
class JaypieEnvSecret extends constructs.Construct {
|
|
1694
|
-
constructor(scope,
|
|
1693
|
+
constructor(scope, idOrEnvKey, props) {
|
|
1694
|
+
// Check if idOrEnvKey should be treated as envKey:
|
|
1695
|
+
// - No props provided OR props.envKey is not set
|
|
1696
|
+
// - AND idOrEnvKey exists as a non-empty string in process.env
|
|
1697
|
+
const treatAsEnvKey = (!props || props.envKey === undefined) &&
|
|
1698
|
+
typeof process.env[idOrEnvKey] === "string" &&
|
|
1699
|
+
process.env[idOrEnvKey] !== "";
|
|
1700
|
+
const id = treatAsEnvKey ? `EnvSecret_${idOrEnvKey}` : idOrEnvKey;
|
|
1695
1701
|
super(scope, id);
|
|
1696
|
-
const { consumer = checkEnvIsConsumer(), envKey, export: exportParam, generateSecretString, provider = checkEnvIsProvider(), roleTag, vendorTag, value, } = props || {};
|
|
1702
|
+
const { consumer = checkEnvIsConsumer(), envKey: envKeyProp, export: exportParam, generateSecretString, provider = checkEnvIsProvider(), roleTag, vendorTag, value, } = props || {};
|
|
1703
|
+
const envKey = treatAsEnvKey ? idOrEnvKey : envKeyProp;
|
|
1697
1704
|
this._envKey = envKey;
|
|
1698
1705
|
let exportName;
|
|
1699
1706
|
if (!exportParam) {
|
|
@@ -2199,7 +2206,8 @@ class JaypieMongoDbSecret extends JaypieEnvSecret {
|
|
|
2199
2206
|
class JaypieNextJs extends constructs.Construct {
|
|
2200
2207
|
constructor(scope, id, props) {
|
|
2201
2208
|
super(scope, id);
|
|
2202
|
-
const domainName = props?.domainName ||
|
|
2209
|
+
const domainName = props?.domainName || envHostname();
|
|
2210
|
+
this.domainName = domainName;
|
|
2203
2211
|
const domainNameSanitized = domainName
|
|
2204
2212
|
.replace(/\./g, "-")
|
|
2205
2213
|
.replace(/[^a-zA-Z0-9]/g, "_");
|
|
@@ -2224,18 +2232,30 @@ class JaypieNextJs extends constructs.Construct {
|
|
|
2224
2232
|
}
|
|
2225
2233
|
return acc;
|
|
2226
2234
|
}, {});
|
|
2235
|
+
// Process NEXT_PUBLIC_ environment variables
|
|
2236
|
+
const nextPublicEnv = Object.entries(process.env).reduce((acc, [key, value]) => {
|
|
2237
|
+
if (key.startsWith("NEXT_PUBLIC_") && value) {
|
|
2238
|
+
return {
|
|
2239
|
+
...acc,
|
|
2240
|
+
[key]: value,
|
|
2241
|
+
};
|
|
2242
|
+
}
|
|
2243
|
+
return acc;
|
|
2244
|
+
}, {});
|
|
2227
2245
|
const nextjs = new cdkNextjsStandalone.Nextjs(this, "NextJsApp", {
|
|
2228
2246
|
nextjsPath,
|
|
2229
2247
|
domainProps: {
|
|
2230
2248
|
domainName,
|
|
2231
|
-
hostedZone:
|
|
2249
|
+
hostedZone: resolveHostedZone(this, {
|
|
2232
2250
|
zone: props?.hostedZone,
|
|
2233
2251
|
}),
|
|
2234
2252
|
},
|
|
2235
2253
|
environment: {
|
|
2236
|
-
...
|
|
2254
|
+
...jaypieLambdaEnv(),
|
|
2237
2255
|
...secretsEnvironment,
|
|
2238
2256
|
...jaypieSecretsEnvironment,
|
|
2257
|
+
...nextPublicEnv,
|
|
2258
|
+
NEXT_PUBLIC_SITE_URL: `https://${domainName}`,
|
|
2239
2259
|
},
|
|
2240
2260
|
overrides: {
|
|
2241
2261
|
nextjsDistribution: {
|