-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fc0a67c
commit c590988
Showing
3 changed files
with
13 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,11 @@ | ||
import { Context, APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda'; | ||
import { createServer, proxy } from 'aws-serverless-express'; | ||
|
||
import serverless from 'serverless-http'; // Converte o app Express para Lambda handler | ||
import { APIGatewayProxyEvent, Context, APIGatewayProxyResult } from 'aws-lambda'; | ||
import {app} from "./src/api/api" | ||
|
||
const server = createServer(app); | ||
// Converte a aplicação Express para funcionar no ambiente Lambda | ||
const handler = serverless(app); | ||
|
||
export const handler = (event: APIGatewayProxyEvent, context: Context): Promise<APIGatewayProxyResult> => { | ||
return new Promise((resolve, reject) => { | ||
try { | ||
proxy(server, event, context); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
// Função exportada para a Lambda | ||
export const lambdaHandler = async (event: APIGatewayProxyEvent, context: Context) => { | ||
return handler(event, context); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters