in infra/stack/serverless-stack.ts [113:133]
private createApiRest(apiFunction: lambda.Function) {
const rest = new api.LambdaRestApi(this, 'rest-api', {
restApiName: `${this.stackName}-APIs`,
handler: apiFunction,
proxy: false,
deployOptions: {
loggingLevel: api.MethodLoggingLevel.INFO
}
});
const resourceName = 'books';
const books = rest.root.addResource(resourceName);
books.addMethod('GET');
new cdk.CfnOutput(this, 'api-endpoint', {
value: `https://${rest.restApiId}.execute-api.${this.region}.amazonaws.com/prod/${resourceName}`,
exportName: 'APIGatewayEndpoint'
})
return rest;
}