This project was built using the Serverless framework, Node.js & TypeScript.
Depending on your preferred package manager, follow the instructions below to deploy your project.
- Run
npm i
to install the project dependencies - Run
npx sls deploy
to deploy this stack to AWS
- Run
yarn
to install the project dependencies - Run
yarn sls deploy
to deploy this stack to AWS
This project contains a single lambda function triggered by an HTTP request made on the provisioned API Gateway REST API /hello
route with POST
method. The request body must be provided as application/json
. The body structure is tested by API Gateway against src/functions/hello/schema.ts
.
- requesting any other path than
/hello
with any other method thanPOST
will result in API Gateway returning a403
HTTP error code - sending a
POST
request to/hello
with a payload not containing a string property namedname
will result in API Gateway returning a400
HTTP error code - sending a
POST
request to/hello
with a payload containing a string property namedname
will result in API Gateway returning a200
HTTP status code with a message saluting the provided name and the detailed event processed by the lambda
⚠️ As is, this project, once deployed, opens a public endpoint within your AWS account resources. Anybody with the URL can actively execute the API Gateway endpoint and the corresponding lambda. You should protect this endpoint with the authentication method of your choice.
In order to test the hello function locally, run the following command:
npx sls invoke local -f hello --path src/functions/hello/mock.json
if you're using NPMyarn sls invoke local -f hello --path src/functions/hello/mock.json
if you're using Yarn
Check the sls invoke local
command documentation for more information.
Copy and replace your url
- found in Serverless deploy
command output - and name
parameter in the following curl
command in your terminal or in Postman to test your newly deployed application.
curl --location --request POST 'https://<my-api-endpoint>/dev/hello' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "OSlash"
}'