Skip to content

s4nt14go/prsls

Repository files navigation

Production-Ready Serverless

Place orders and accept/reject them done with Serverless Framework using AWS Lambda, API Gateway, DynamoDB, EventBridge, SNS, Cognito, SSM & SQS

▶️ Demo site

  1. Register

  2. Place orders clicking in restaurants

  3. 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
  4. In the case you accepted the order you can complete it

  5. 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

Deployment instructions

  1. 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
    
  2. 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
  3. Configure these parameters in AWS Systems Manager > Parameter Store:

    /prsls/${stage}/get-restaurants/config:

    {
       "defaultResults": 8
    }

    /prsls/${stage}/search-restaurants/config:

    {
       "defaultResults": 8
    }
  4. Populate the database with restaurants:

    export restaurants_table=<DynamoDB table for the stage>
    node -e 'require("./tests/steps/given.js").eight_initial_restaurants()'