@@ -44,8 +44,12 @@ Create a `app.ts` file
4444``` typescript
4545// Import API Gateway Event handler
4646import { APIGatewayProxyEvent , Context } from ' aws-lambda' ;
47- import { ApiGatewayResolver } from ' ./ApiGateway' ;
48- import { AsyncFunction , BaseProxyEvent , JSONData } from ' types' ;
47+ import {
48+ ApiGatewayResolver ,
49+ AsyncFunction ,
50+ BaseProxyEvent ,
51+ JSONData ,
52+ } from ' @evernorth/aws-lambda-ts-event-handler' ;
4953
5054// Initialize the event handler
5155const app = new ApiGatewayResolver ();
@@ -63,9 +67,17 @@ app.addRoute('GET', '/v1/hello', helloHandler as AsyncFunction);
6367exports .handler = (
6468 _event : APIGatewayProxyEvent ,
6569 _context : Context ,
66- ): Promise <JSONData > =>
70+ ): Promise <JSONData > => {
6771 // Resolve routes
68- app .resolve (_event , _context );
72+ return app .resolve (_event , _context );
73+ };
74+
75+ // Declare your Lambda handler
76+ if (require .main === module ) {
77+ LocalTestServer .getInstance (handler as Handler ).start ();
78+ } else {
79+ module .exports .handler = handler ;
80+ }
6981```
7082
7183Run the application
@@ -124,9 +136,10 @@ export class HelloController {
124136const handler = (
125137 _event : APIGatewayProxyEvent ,
126138 _context : Context ,
127- ): Promise <JSONData > =>
139+ ): Promise <JSONData > => {
128140 // Resolve routes
129- app .resolve (_event , _context );
141+ return app .resolve (_event , _context );
142+ };
130143
131144// Declare your Lambda handler
132145if (require .main === module ) {
0 commit comments