1
1
import { aws_apigateway } from "aws-cdk-lib" ;
2
+ import { APIGatewayProxyEvent , APIGatewayProxyResult } from "aws-lambda" ;
2
3
import { Construct } from "constructs" ;
3
- import { isParameterDecl } from "." ;
4
- import { FunctionDecl , isFunctionDecl } from "./declaration" ;
4
+ import { FunctionDecl , isFunctionDecl , isParameterDecl } from "./declaration" ;
5
5
import { isErr } from "./error" ;
6
6
import {
7
7
Identifier ,
@@ -20,6 +20,7 @@ import {
20
20
ObjectLiteralExpr ,
21
21
PropAccessExpr ,
22
22
} from "./expression" ;
23
+ import { Function } from "./function" ;
23
24
import { findIntegration , IntegrationImpl } from "./integration" ;
24
25
import { FunctionlessNode } from "./node" ;
25
26
import { isReturnStmt , isVariableStmt , ReturnStmt } from "./statement" ;
@@ -83,7 +84,7 @@ export abstract class BaseApiIntegration {
83
84
*/
84
85
public abstract addMethod (
85
86
httpMethod : HttpMethod ,
86
- resource : aws_apigateway . Resource
87
+ resource : aws_apigateway . IResource
87
88
) : aws_apigateway . Method ;
88
89
}
89
90
@@ -225,7 +226,7 @@ export interface AwsApiIntegrationProps<
225
226
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-api-integration-types.html
226
227
*/
227
228
export class AwsApiIntegration <
228
- Request ,
229
+ Request extends ApiRequest < any , any , any , any > ,
229
230
IntegrationResponse ,
230
231
MethodResponse
231
232
> extends BaseApiIntegration {
@@ -553,3 +554,36 @@ export interface ApiGatewayVtlIntegration {
553
554
responses : aws_apigateway . IntegrationResponse [ ]
554
555
) => aws_apigateway . Integration ;
555
556
}
557
+
558
+ export interface LambdaProxyApiIntegrationProps
559
+ extends Omit <
560
+ aws_apigateway . LambdaIntegrationOptions ,
561
+ | "requestParameters"
562
+ | "requestTemplates"
563
+ | "integrationResponses"
564
+ | "passthroughBehavior"
565
+ | "proxy"
566
+ > {
567
+ function : Function < APIGatewayProxyEvent , APIGatewayProxyResult > ;
568
+ }
569
+
570
+ export class LambdaProxyApiIntegration extends BaseApiIntegration {
571
+ readonly function ;
572
+ constructor ( private readonly props : LambdaProxyApiIntegrationProps ) {
573
+ super ( ) ;
574
+ this . function = props . function ;
575
+ }
576
+
577
+ public addMethod (
578
+ httpMethod : HttpMethod ,
579
+ resource : aws_apigateway . IResource
580
+ ) : aws_apigateway . Method {
581
+ return resource . addMethod (
582
+ httpMethod ,
583
+ new aws_apigateway . LambdaIntegration ( this . function . resource , {
584
+ ...this . props ,
585
+ proxy : true ,
586
+ } )
587
+ ) ;
588
+ }
589
+ }
0 commit comments