$ npm install
# Starts the Live Lambda Development environment.
$ npm run dev
$ npm run deploy
API-First Approach
-
Update swagger.yaml under /packages/core with your new endpoint defination
follow the Guide here https://swagger.io/docs/specification/basic-structure/
-
Generate types from swagger file and load to project
$ npm run openapi
-
Create enpoint lambda handler file. The file name need to match the swagger operationId
handler template
export class TestHandler extends BaseAPIGatewayHandler {
constructor(){
// load services
// add your service at lambdas/src/providers.ts
super(providers);
}
// business logic
async handleRequest(event: APIGatewayEvent, context: Context)
: Promise<Clients> // replace the return type with corresponding Swagger response type
{
var service = this.app?.get(TestService);
var client: Client = {
id: 1,
name: service.getHello()
};
return [client];
};
}
// lambda entry point
export const handler = async (event: any, context: Context) =>
await new TestHandler().lambdaHandler(event, context);
-
Add your new handler to stacks/LambdaStack.ts
const testHandler: FunctionProps = { handler: "packages/lambdas/src/handlers/testHandler.handler", environment: { // add handler level environment here LOG_LEVEL: "debug", } };
Remember to add your handler to return
return { testHandler, ... }
# Starts the Live Lambda Development environment.
$ npm run dev
-
grab SiteUrl link from your console and open /api from browser
{SiteUrl}/api
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov