@fy-stack/apigateway-construct 0.0.122
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/README.md +7 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/lib/apigateway-construct.d.ts +8 -0
- package/dist/lib/apigateway-construct.d.ts.map +1 -0
- package/dist/lib/apigateway-construct.js +37 -0
- package/dist/lib/types.d.ts +6 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +2 -0
- package/package.json +22 -0
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,YAAY,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiGatewayConstruct = void 0;
|
|
4
|
+
var apigateway_construct_1 = require("./lib/apigateway-construct");
|
|
5
|
+
Object.defineProperty(exports, "ApiGatewayConstruct", { enumerable: true, get: function () { return apigateway_construct_1.ApiGatewayConstruct; } });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { HttpApi } from "aws-cdk-lib/aws-apigatewayv2";
|
|
2
|
+
import { Construct } from "constructs";
|
|
3
|
+
import { ApiGatewayConstructProps } from "./types";
|
|
4
|
+
export declare class ApiGatewayConstruct extends Construct {
|
|
5
|
+
readonly api: HttpApi;
|
|
6
|
+
constructor(scope: Construct, id: string, props: ApiGatewayConstructProps);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=apigateway-construct.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apigateway-construct.d.ts","sourceRoot":"","sources":["../../src/lib/apigateway-construct.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAc,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAEnD,qBAAa,mBAAoB,SAAQ,SAAS;IAChD,SAAgB,GAAG,EAAE,OAAO,CAAC;gBAEjB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,wBAAwB;CAuC1E"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiGatewayConstruct = void 0;
|
|
4
|
+
const aws_apigatewayv2_1 = require("aws-cdk-lib/aws-apigatewayv2");
|
|
5
|
+
const constructs_1 = require("constructs");
|
|
6
|
+
class ApiGatewayConstruct extends constructs_1.Construct {
|
|
7
|
+
api;
|
|
8
|
+
constructor(scope, id, props) {
|
|
9
|
+
super(scope, id);
|
|
10
|
+
const routes = {};
|
|
11
|
+
Object.assign(routes, Object.fromEntries(Object.entries(props.routes).map(([key, val]) => {
|
|
12
|
+
const app = props.resources?.[val.$resource];
|
|
13
|
+
if (!app)
|
|
14
|
+
throw new Error(`"${val.$resource}" resource not found`);
|
|
15
|
+
return [key, app];
|
|
16
|
+
})));
|
|
17
|
+
const { "/*": base, ...otherRoutes } = routes;
|
|
18
|
+
if (!base)
|
|
19
|
+
throw new Error("no base route");
|
|
20
|
+
const { "/*": defaultIntegration, ...additionalIntegrations } = base
|
|
21
|
+
.api("");
|
|
22
|
+
if (!defaultIntegration)
|
|
23
|
+
throw new Error("no default integration");
|
|
24
|
+
for (const i in otherRoutes) {
|
|
25
|
+
Object.assign(additionalIntegrations, otherRoutes[i]?.api(i));
|
|
26
|
+
}
|
|
27
|
+
this.api = new aws_apigatewayv2_1.HttpApi(this, "Api", { defaultIntegration });
|
|
28
|
+
for (const i in additionalIntegrations) {
|
|
29
|
+
this.api.addRoutes({
|
|
30
|
+
integration: additionalIntegrations[i],
|
|
31
|
+
methods: [aws_apigatewayv2_1.HttpMethod.ANY],
|
|
32
|
+
path: `${i}/{proxy+}`,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.ApiGatewayConstruct = ApiGatewayConstruct;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAC,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE/D,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAAC,CAAC;CACrD,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fy-stack/apigateway-construct",
|
|
3
|
+
"version": "0.0.122",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"tslib": "^2.3.0",
|
|
6
|
+
"@fy-stack/types": "0.0.122"
|
|
7
|
+
},
|
|
8
|
+
"peerDependencies": {
|
|
9
|
+
"aws-cdk-lib": "2.164.1",
|
|
10
|
+
"constructs": "10.4.2"
|
|
11
|
+
},
|
|
12
|
+
"type": "commonjs",
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"typings": "./dist/index.d.ts",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"!**/*.tsbuildinfo"
|
|
18
|
+
],
|
|
19
|
+
"nx": {
|
|
20
|
+
"name": "apigateway-construct"
|
|
21
|
+
}
|
|
22
|
+
}
|