@fy-stack/apigateway-construct 0.0.143 → 0.0.144
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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Attachable } from '@fy-stack/types';
|
|
1
2
|
import { HttpApi } from 'aws-cdk-lib/aws-apigatewayv2';
|
|
2
3
|
import { Construct } from "constructs";
|
|
3
4
|
import { ApiGatewayConstructProps } from "./types";
|
|
@@ -9,8 +10,9 @@ import { ApiGatewayConstructProps } from "./types";
|
|
|
9
10
|
*
|
|
10
11
|
* @throws {Error} Throws an error if the base route is not found.
|
|
11
12
|
*/
|
|
12
|
-
export declare class ApiGatewayConstruct extends Construct {
|
|
13
|
+
export declare class ApiGatewayConstruct extends Construct implements Attachable {
|
|
13
14
|
readonly api: HttpApi;
|
|
14
15
|
constructor(scope: Construct, id: string, props: ApiGatewayConstructProps);
|
|
16
|
+
attachable(): Record<string, string>;
|
|
15
17
|
}
|
|
16
18
|
//# sourceMappingURL=apigateway-construct.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apigateway-construct.d.ts","sourceRoot":"","sources":["../../src/lib/apigateway-construct.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"apigateway-construct.d.ts","sourceRoot":"","sources":["../../src/lib/apigateway-construct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAkB,OAAO,EAAc,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAEnD;;;;;;;GAOG;AACH,qBAAa,mBAAoB,SAAQ,SAAU,YAAW,UAAU;IACtE,SAAgB,GAAG,EAAE,OAAO,CAAC;gBAEjB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,wBAAwB;IA6CzE,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAKrC"}
|
|
@@ -22,22 +22,21 @@ class ApiGatewayConstruct extends constructs_1.Construct {
|
|
|
22
22
|
throw new Error(`"${val.$resource}" resource not found`);
|
|
23
23
|
return [key, app];
|
|
24
24
|
})));
|
|
25
|
-
const {
|
|
25
|
+
const { '/*': base, ...otherRoutes } = routes;
|
|
26
26
|
if (!base)
|
|
27
|
-
throw new Error(
|
|
28
|
-
const {
|
|
29
|
-
.api("");
|
|
27
|
+
throw new Error('no base route');
|
|
28
|
+
const { '': defaultIntegration, ...additionalIntegrations } = base.api('');
|
|
30
29
|
if (!defaultIntegration)
|
|
31
|
-
throw new Error(
|
|
30
|
+
throw new Error('no default integration');
|
|
32
31
|
for (const i in otherRoutes) {
|
|
33
32
|
Object.assign(additionalIntegrations, otherRoutes[i]?.api(i));
|
|
34
33
|
}
|
|
35
|
-
this.api = new aws_apigatewayv2_1.HttpApi(this,
|
|
34
|
+
this.api = new aws_apigatewayv2_1.HttpApi(this, 'Api', {
|
|
36
35
|
corsPreflight: {
|
|
37
|
-
allowHeaders: [
|
|
38
|
-
allowOrigins: [
|
|
36
|
+
allowHeaders: ['*'],
|
|
37
|
+
allowOrigins: ['*'],
|
|
39
38
|
allowMethods: [aws_apigatewayv2_1.CorsHttpMethod.ANY],
|
|
40
|
-
}
|
|
39
|
+
},
|
|
41
40
|
});
|
|
42
41
|
for (const i in additionalIntegrations) {
|
|
43
42
|
this.api.addRoutes({
|
|
@@ -47,5 +46,10 @@ class ApiGatewayConstruct extends constructs_1.Construct {
|
|
|
47
46
|
});
|
|
48
47
|
}
|
|
49
48
|
}
|
|
49
|
+
attachable() {
|
|
50
|
+
return {
|
|
51
|
+
domain: this.api.apiEndpoint
|
|
52
|
+
};
|
|
53
|
+
}
|
|
50
54
|
}
|
|
51
55
|
exports.ApiGatewayConstruct = ApiGatewayConstruct;
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fy-stack/apigateway-construct",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.144",
|
|
4
4
|
"repository": "https://github.com/festusyuma/fy-stack",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"tslib": "^2.3.0"
|
|
6
|
+
"tslib": "^2.3.0",
|
|
7
|
+
"@fy-stack/types": "0.0.144"
|
|
7
8
|
},
|
|
8
9
|
"peerDependencies": {
|
|
9
10
|
"aws-cdk-lib": "^2.198.0",
|