kierans777
10/09/2021, 11:57 AMApiGatewayV1ApiRouteProps
instance without a Function, but just an API Gateway Mock Integration? Or will I get errors from SST?kierans777
10/09/2021, 12:57 PMFrank
ApiGatewayV1Api
, but you can do it in CDK with something like this:
const api = new sst.ApiGatewayV1Api(...);
api.restApi.root.addResource('pets').addMethod('GET', new MockIntegration({
integrationResponses: [{
statusCode: '200',
}],
passthroughBehavior: PassthroughBehavior.NEVER,
requestTemplates: {
'application/json': '{ "statusCode": 200 }',
},
}), {
methodResponses: [{ statusCode: '200' }],
});
Frank
api.restApi
gives you the CDK RestApi construct, and you can use integrations that are not yet supported by SST.Frank
kierans777
10/10/2021, 6:30 AMApi
constructs more rich? For example
1. IMO if you don't have a verb for a route the API should return an HTTP 405 "Method Not Allowed" which can be achieved with a Mock Integration
2. If I want my endpoint to use a Custom Authoriser and then put the request payload onto a SQS queue, then I have to use the integration approach above where it would be great to make use of the routing DSL SST has ie:
new ApiGatewayV1Api(this, "Api", {
routes: {
"GET /notes": "src/list.main",
"POST /notes": new AwsIntegration(...),
},
});
I'm happy to open GitHub issues if there's a place for such ideas.
(One thing that annoyed me about the Serverless platform is it's focus on Lambda's to the detriment of everything else, and good API design)Frank
Api
construct (ie. Api
support ALB and HTTP proxy integrations). And we more open issues for adding SQS and StepFunctions integrations.Frank
ApiGatewayV1Api
construct, and hence it’s a bit thin on features.Frank
kierans777
10/11/2021, 5:45 AMFrank