@fy-stack/app-construct 0.0.147-3-preview → 0.0.147-alpha.301
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/lib/lambda/apps/next-app-router-construct.d.ts +1 -1
- package/dist/lib/lambda/apps/next-app-router-construct.d.ts.map +1 -1
- package/dist/lib/lambda/apps/next-app-router-construct.js +38 -2
- package/dist/lib/lambda/types.d.ts +2 -2
- package/dist/lib/lambda/types.d.ts.map +1 -1
- package/dist/lib/lambda/utils/lambda-api.d.ts +1 -1
- package/dist/lib/lambda/utils/lambda-api.d.ts.map +1 -1
- package/dist/lib/lambda/utils/lambda-api.js +8 -5
- package/dist/lib/shared/next-app-router.d.ts.map +1 -1
- package/dist/lib/shared/next-app-router.js +3 -6
- package/package.json +4 -4
|
@@ -22,7 +22,7 @@ export declare class NextAppRouterConstruct extends Construct implements AppCons
|
|
|
22
22
|
constructor(scope: Construct, id: string, props: AppProperties<z.infer<typeof BuildParamsSchema>>);
|
|
23
23
|
cloudfront(path: string): Record<string, cloudfront.BehaviorOptions>;
|
|
24
24
|
cloudfrontPolicy(distributionId: string): void;
|
|
25
|
-
api(): Record<string, HttpRouteIntegration>;
|
|
25
|
+
api(basePath: string): Record<string, HttpRouteIntegration>;
|
|
26
26
|
attach(attachable: Record<string, Attachable>): void;
|
|
27
27
|
grant(...grants: Grantable[]): void;
|
|
28
28
|
subscription(): ITopicSubscription;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-app-router-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/lambda/apps/next-app-router-construct.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"next-app-router-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/lambda/apps/next-app-router-constru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,EAAE;IAI5B,YAAY,IAAI,kBAAkB;IAIlC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO;;;CAG7B"}
|
|
@@ -5,8 +5,11 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const fs = tslib_1.__importStar(require("node:fs"));
|
|
6
6
|
const path = tslib_1.__importStar(require("node:path"));
|
|
7
7
|
const cdk = tslib_1.__importStar(require("aws-cdk-lib"));
|
|
8
|
+
const aws_apigatewayv2_integrations_1 = require("aws-cdk-lib/aws-apigatewayv2-integrations");
|
|
8
9
|
const cloudfrontOrigin = tslib_1.__importStar(require("aws-cdk-lib/aws-cloudfront-origins"));
|
|
9
10
|
const lambda = tslib_1.__importStar(require("aws-cdk-lib/aws-lambda"));
|
|
11
|
+
const aws_lambda_1 = require("aws-cdk-lib/aws-lambda");
|
|
12
|
+
const s3Deploy = tslib_1.__importStar(require("aws-cdk-lib/aws-s3-deployment"));
|
|
10
13
|
const constructs_1 = require("constructs");
|
|
11
14
|
const zod_1 = require("zod");
|
|
12
15
|
const next_app_router_1 = require("../../shared/next-app-router");
|
|
@@ -57,8 +60,41 @@ class NextAppRouterConstruct extends constructs_1.Construct {
|
|
|
57
60
|
cloudfrontPolicy(distributionId) {
|
|
58
61
|
throw new Error(`cloudfrontPolicy not supported for ${this}`);
|
|
59
62
|
}
|
|
60
|
-
api() {
|
|
61
|
-
|
|
63
|
+
api(basePath) {
|
|
64
|
+
const strippedBasePath = basePath.replace(/^\/+|\/+$/g, '');
|
|
65
|
+
const apiUrl = this.function.addFunctionUrl({
|
|
66
|
+
authType: lambda.FunctionUrlAuthType.NONE,
|
|
67
|
+
invokeMode: aws_lambda_1.InvokeMode.RESPONSE_STREAM,
|
|
68
|
+
});
|
|
69
|
+
if (strippedBasePath) {
|
|
70
|
+
new s3Deploy.BucketDeployment(this, `${strippedBasePath}StaticDeployment`, {
|
|
71
|
+
destinationBucket: this.static,
|
|
72
|
+
sources: [this.files.staticFiles],
|
|
73
|
+
destinationKeyPrefix: `${strippedBasePath}/_next/static/`,
|
|
74
|
+
retainOnDelete: false,
|
|
75
|
+
});
|
|
76
|
+
new s3Deploy.BucketDeployment(this, `${strippedBasePath}PublicDeployment`, {
|
|
77
|
+
destinationBucket: this.static,
|
|
78
|
+
sources: [this.files.publicFiles],
|
|
79
|
+
destinationKeyPrefix: `${strippedBasePath}/`,
|
|
80
|
+
retainOnDelete: false,
|
|
81
|
+
});
|
|
82
|
+
this.function.addEnvironment('BASE_PATH', basePath);
|
|
83
|
+
}
|
|
84
|
+
const imageIntegration = new aws_apigatewayv2_integrations_1.HttpUrlIntegration('AppImageIntegration', apiUrl.url + path.join(strippedBasePath, '_next/image', '{proxy}'));
|
|
85
|
+
const staticIntegration = new aws_apigatewayv2_integrations_1.HttpUrlIntegration('AppStaticIntegration', this.static.bucketWebsiteUrl +
|
|
86
|
+
path.join(strippedBasePath, '/_next', '{proxy}'));
|
|
87
|
+
const publicIntegration = new aws_apigatewayv2_integrations_1.HttpUrlIntegration('AppPublicIntegration', this.static.bucketWebsiteUrl +
|
|
88
|
+
path.join(strippedBasePath, '/public', '{proxy}'));
|
|
89
|
+
const wildcardIntegration = new aws_apigatewayv2_integrations_1.HttpUrlIntegration('AppWildcardIntegration', apiUrl.url + path.join(strippedBasePath, '{proxy}'));
|
|
90
|
+
const defaultIntegration = new aws_apigatewayv2_integrations_1.HttpUrlIntegration('AppIntegration', apiUrl.url + strippedBasePath);
|
|
91
|
+
return {
|
|
92
|
+
[`${basePath}/_next/image/{proxy+}`]: imageIntegration,
|
|
93
|
+
[`${basePath}/_next/{proxy+}`]: staticIntegration,
|
|
94
|
+
[`${basePath}/public/{proxy+}`]: publicIntegration,
|
|
95
|
+
[`${basePath}/{proxy+}`]: wildcardIntegration,
|
|
96
|
+
[basePath]: defaultIntegration,
|
|
97
|
+
};
|
|
62
98
|
}
|
|
63
99
|
attach(attachable) {
|
|
64
100
|
return (0, lambda_attach_1.lambdaAttach)(this.function, attachable);
|
|
@@ -4,7 +4,7 @@ import type { Function, FunctionProps } from 'aws-cdk-lib/aws-lambda';
|
|
|
4
4
|
import type { ILogGroup } from 'aws-cdk-lib/aws-logs';
|
|
5
5
|
import type { Queue, QueueProps } from 'aws-cdk-lib/aws-sqs';
|
|
6
6
|
export type LambdaConstructProps = {
|
|
7
|
-
vpc?: IVpc;
|
|
7
|
+
vpc?: IVpc | (() => IVpc);
|
|
8
8
|
apps: Record<string, App>;
|
|
9
9
|
logGroup: ILogGroup;
|
|
10
10
|
};
|
|
@@ -24,6 +24,6 @@ export type AppProperties<BuildParams = Record<string, unknown>> = {
|
|
|
24
24
|
timeout?: number;
|
|
25
25
|
buildParams: BuildParams & Partial<FunctionProps>;
|
|
26
26
|
output: string;
|
|
27
|
-
vpc?: IVpc;
|
|
27
|
+
vpc?: IVpc | (() => IVpc);
|
|
28
28
|
};
|
|
29
29
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/lambda/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAChB,OAAO,EACP,KAAK,MAAM,EACX,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,KAAK,EACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAE7D,MAAM,MAAM,oBAAoB,GAAG;IACjC,GAAG,CAAC,EAAE,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/lambda/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAA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AM,CAAC,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;CAC3B,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HttpUrlIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';
|
|
2
2
|
import { Function } from 'aws-cdk-lib/aws-lambda';
|
|
3
|
-
export declare function lambdaApi(func: Function,
|
|
3
|
+
export declare function lambdaApi(func: Function, basePath: string): {
|
|
4
4
|
[x: string]: HttpUrlIntegration;
|
|
5
5
|
};
|
|
6
6
|
//# sourceMappingURL=lambda-api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lambda-api.d.ts","sourceRoot":"","sources":["../../../../src/lib/lambda/utils/lambda-api.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lambda-api.d.ts","sourceRoot":"","sources":["../../../../src/lib/lambda/utils/lambda-api.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGlD,wBAAgB,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM;;EAuBzD"}
|
|
@@ -2,16 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.lambdaApi = lambdaApi;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
5
6
|
const aws_apigatewayv2_integrations_1 = require("aws-cdk-lib/aws-apigatewayv2-integrations");
|
|
6
7
|
const lambda = tslib_1.__importStar(require("aws-cdk-lib/aws-lambda"));
|
|
7
|
-
function lambdaApi(func,
|
|
8
|
+
function lambdaApi(func, basePath) {
|
|
9
|
+
const strippedPath = basePath.replace(/^\/+|\/+$/g, '');
|
|
8
10
|
const apiUrl = func.addFunctionUrl({
|
|
9
11
|
authType: lambda.FunctionUrlAuthType.NONE,
|
|
10
12
|
});
|
|
11
|
-
func.addEnvironment('BASE_PATH',
|
|
12
|
-
const
|
|
13
|
+
func.addEnvironment('BASE_PATH', basePath);
|
|
14
|
+
const wildcardIntegration = new aws_apigatewayv2_integrations_1.HttpUrlIntegration('AppIntegration', apiUrl.url + node_path_1.default.join(strippedPath, '{proxy}'));
|
|
15
|
+
const integration = new aws_apigatewayv2_integrations_1.HttpUrlIntegration('AppWildcardIntegration', apiUrl.url + strippedPath);
|
|
13
16
|
return {
|
|
14
|
-
[
|
|
15
|
-
[`${
|
|
17
|
+
[basePath]: integration,
|
|
18
|
+
[`${basePath}/{proxy+}`]: wildcardIntegration,
|
|
16
19
|
};
|
|
17
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-app-router.d.ts","sourceRoot":"","sources":["../../../src/lib/shared/next-app-router.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AACnC,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AAEzD,OAAO,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,KAAK,QAAQ,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"next-app-router.d.ts","sourceRoot":"","sources":["../../../src/lib/shared/next-app-router.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AACnC,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AAEzD,OAAO,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,KAAK,QAAQ,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,MAAM,OAAO,GAAG;IACpB,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC;IAC9B,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC;CAC/B,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM;;;;;;EAsC9D;AAED,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,SAAS,EACd,YAAY,EAAE,EAAE,CAAC,MAAM,EACvB,YAAY,EAAE,UAAU,CAAC,OAAO,EAChC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO;;EAgEf"}
|
|
@@ -9,6 +9,7 @@ const cloudfront = tslib_1.__importStar(require("aws-cdk-lib/aws-cloudfront"));
|
|
|
9
9
|
const cloudfrontOrigin = tslib_1.__importStar(require("aws-cdk-lib/aws-cloudfront-origins"));
|
|
10
10
|
const s3 = tslib_1.__importStar(require("aws-cdk-lib/aws-s3"));
|
|
11
11
|
const s3Deploy = tslib_1.__importStar(require("aws-cdk-lib/aws-s3-deployment"));
|
|
12
|
+
const ssm = tslib_1.__importStar(require("aws-cdk-lib/aws-ssm"));
|
|
12
13
|
function staticDeployment(app, output) {
|
|
13
14
|
const staticBucket = new s3.Bucket(app, `StaticBucket`, {
|
|
14
15
|
removalPolicy: cdk.RemovalPolicy.DESTROY,
|
|
@@ -69,12 +70,8 @@ function cloudfrontBehaviours(app, staticBucket, serverOrigin, basePath, files)
|
|
|
69
70
|
compress: true,
|
|
70
71
|
viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
71
72
|
};
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
maxTtl: cdk.Duration.days(365),
|
|
75
|
-
enableAcceptEncodingGzip: true,
|
|
76
|
-
enableAcceptEncodingBrotli: true,
|
|
77
|
-
});
|
|
73
|
+
const imageCachePolicyID = ssm.StringParameter.fromStringParameterName(app, 'NextAppRouterImagePolicyArn', '/fy-stack/ImagePolicyID');
|
|
74
|
+
const imageCachePolicy = cloudfront.CachePolicy.fromCachePolicyId(app, 'ImagePolicy', imageCachePolicyID.stringValue);
|
|
78
75
|
const appBehaviour = {
|
|
79
76
|
origin: serverOrigin,
|
|
80
77
|
cachePolicy: cloudfront.CachePolicy.CACHING_DISABLED,
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fy-stack/app-construct",
|
|
3
|
-
"version": "0.0.147-
|
|
3
|
+
"version": "0.0.147-alpha.301",
|
|
4
4
|
"repository": "https://github.com/festusyuma/fy-stack",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@fy-stack/types": "0.0.147-
|
|
6
|
+
"@fy-stack/types": "0.0.147-alpha.301",
|
|
7
7
|
"tslib": "^2.3.0",
|
|
8
8
|
"zod": "^3.24.1"
|
|
9
9
|
},
|
|
10
10
|
"peerDependencies": {
|
|
11
|
-
"aws-cdk-lib": "^2.
|
|
12
|
-
"constructs": "^10.4.
|
|
11
|
+
"aws-cdk-lib": "^2.229.1",
|
|
12
|
+
"constructs": "^10.4.3"
|
|
13
13
|
},
|
|
14
14
|
"main": "./dist/index.js",
|
|
15
15
|
"module": "./dist/index.mjs",
|