geekmidas
07/16/2021, 11:01 AMimport { App, Stack } from '@serverless-stack/resources';
import {
HttpApi,
} from '@aws-cdk/aws-apigatewayv2';
import { HttpAlbIntegration } from '@aws-cdk/aws-apigatewayv2-integrations';
import { Server } from './Server';
export class Api extends Stack {
constructor(app: App, props: Props) {
super(app, 'api');
const { server } = props;
const { fargate } = server;
const integration = new HttpAlbIntegration({
listener: fargate.listener,
});
new HttpApi(this, 'http-api', {
defaultIntegration: integration,
});
}
}
interface Props {
server: Server;
}
Frank
new sst.Api(this, 'http-api', {
customDomain: "<http://api.domain.com|api.domain.com>",
defaultRoute: {
albProps: {
listener: fargate.listener,
}
},
});
Would that work for you?geekmidas
07/16/2021, 7:09 PMFrank
new sst.Api(this, 'MyApi', {
routes: {
"GET /": "src/lambda.main",
"GET /2nd": {
albProps: { ... },
},
"GET /3rd": {
sqsProps: { ... },
},
},
});
Frank
import { HttpAlbIntegration } from '@aws-cdk/aws-apigatewayv2-integrations';
geekmidas
07/16/2021, 7:20 PM"GET /2nd": {
integrationType: SOME_ENUM
integration: albProps | sqsProps |...
},
would work better, what do you think?Frank
albProps
or sqsProps
, etc. But you are right, we should throw an error if ppl are trying to set more than 1 integration.Frank
Frank
geekmidas
07/21/2021, 9:36 AM