This project is a serverless application built using the Serverless Framework. It handles AWS API Gateway events and processes them through a Lambda function.
aws-lambda-serverless
├── src
│ ├── handler.js # Main entry point for the AWS Lambda function
│ └── utils
│ └── helper.js # Utility functions for the handler
├── serverless.yml # Serverless Framework configuration
├── package.json # npm configuration and dependencies
├── .gitignore # Git ignore file
└── README.md # Project documentation
-
Clone the repository:
git clone <repository-url> cd aws-lambda-serverless -
Install dependencies:
npm install -
Deploy the service:
serverless deploy -
Invoke the function:
serverless invoke -f <function-name> -
Remove the service:
serverless remove
This project is designed to handle API Gateway events. The main function is located in src/handler.js, and it processes incoming requests and returns appropriate responses.
Execute:
$ curl -v -X POST http://localhost:3000/api -d '{"msg":"abc"}' | /c/Users/eduardo.gouvea/.nvm/versions/node/v20.17.0/bin/node_modules/node-jq/bin/jq.exe
Response should be:
> POST /api HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/8.1.2
> Accept: */*
> Content-Length: 13
> Content-Type: application/x-www-form-urlencoded
>
} [13 bytes data]
< HTTP/1.1 200 OK
< content-type: application/json; charset=utf-8
< cache-control: no-cache
< content-length: 829
< Date: Mon, 31 Mar 2025 14:18:42 GMT
< Connection: keep-alive
< Keep-Alive: timeout=5
<
{ [829 bytes data]
100 842 100 829 100 13 3496 54 --:--:-- --:--:-- --:--:-- 3537
* Connection #0 to host localhost left intact
{
"message": "Hello from AWS Lambda!",
"input": {
"body": "{\"msg\":\"abc\"}",
"cookies": [],
"headers": {
"host": "localhost:3000",
"user-agent": "curl/8.1.2",
"accept": "*/*",
"content-length": "13",
"content-type": "application/x-www-form-urlencoded"
},
"isBase64Encoded": false,
"pathParameters": null,
"queryStringParameters": null,
"rawPath": "/api",
"rawQueryString": "",
"requestContext": {
"accountId": "offlineContext_accountId",
"apiId": "offlineContext_apiId",
"domainName": "offlineContext_domainName",
"domainPrefix": "offlineContext_domainPrefix",
"http": {
"method": "POST",
"path": "/api",
"protocol": "HTTP/1.1",
"sourceIp": "::1",
"userAgent": "curl/8.1.2"
},
"requestId": "offlineContext_resourceId",
"routeKey": "POST api",
"stage": "$default",
"time": "31/Mar/2025:11:18:42 -0300",
"timeEpoch": 1743430722590
},
"routeKey": "POST api",
"stageVariables": null,
"version": "2.0"
}
}
Feel free to submit issues or pull requests for improvements or bug fixes.
This project is licensed under the MIT License.