Place orders and accept/reject them done with Serverless Framework using AWS Lambda, API Gateway, DynamoDB, EventBridge, SNS, Cognito, SSM & SQS
-
Register
-
Place orders clicking in restaurants
-
Simulate restaurant response accepting or rejecting them curling like this:
API=https://lrmnkd5aj8.execute-api.us-east-1.amazonaws.com/prod/order ACCEPTANCE_URL=${API}/acceptance ORDER=<your order> ACCEPTANCE=order_accepted # or ACCEPTANCE=order_rejected curl -d '{"orderId":"'"${ORDER}"'", "acceptance":"'"${ACCEPTANCE}"'"}' -H "Content-Type: application/json" -X POST $ACCEPTANCE_URL
-
In the case you accepted the order you can complete it
-
Once you complete or reject the order you can delete it curling like this:
DELETE_URL=${API}/delete ORDER=<your order> curl --request GET \ --url $DELETE_URL/$ORDER
-
Use Node 20 version, using nvm you can:
# set Node 20 in current terminal nvm use 20 # set Node 20 as default (new terminals will use 20) nvm alias default 20
-
Install dependencies and deploy on your stage (provided you configured your AWS credentials)
npm i # deploy on dev stage npm run sls -- deploy # ...to deploy on prod stage npm run sls -- deploy -s prod
-
Configure these parameters in
AWS Systems Manager > Parameter Store
:/prsls/${stage}/get-restaurants/config
:{ "defaultResults": 8 }
/prsls/${stage}/search-restaurants/config
:{ "defaultResults": 8 }
-
Populate the database with restaurants:
export restaurants_table=<DynamoDB table for the stage> node -e 'require("./tests/steps/given.js").eight_initial_restaurants()'