Share Leftovers App

Overview

This app lets users share images of their leftover food. Other people can contact them and fetch the leftovers. Users are able to login, get, update and delete their items. And can also upload images.

Endpoints:

This project demonstrates the usage of:

  • serverless framework
  • serverless offline
  • AWS lambda architecture
  • API Gateway REST-API and validations
  • Authentication and authorization with Auth0
  • DynamoDB integration
  • S3 signedUrl Upload
  • AWS X-Ray
  • Ports and Adapter Architecture (separation of business and data layer)

Instructions with Postman

  1. Authenticate postman
  2. Use Postman requests

How to authenticate in Postman

  1. Go to the Authorization tab in the Postman collection. All requests will inherit this authorization method alt text
  2. Select Type OAuth2.0 and Request Headers alt text
  3. Select Get New Access Token
  4. Enter the following information and click Get New Access Token
  5. You should be greeted with a login/registration page. Please register and login. Note: Clear cookies in Postman if there are cookies from previous sessions (https://stackoverflow.com/questions/28305273/how-to-delete-session-cookie-in-postman) alt text
  6. DO NOT CLICK Use Token, it does not work. Instead, copy the id_token into the Access Token field. alt text alt text
  7. Now you should be able to do all requests.

How to use Postman collection

Example workflow: 0. Get feed (No auth needed)

  1. Create two items
  2. Get user items
  3. Update one item by giving a itemId (get this from previous request 2.)
  4. Get user items
  5. Delete one item by giving a itemId
  6. Get user items
  7. Get upload url by giving a itemId
  8. Upload image, by copying returned Url into the Upload file PUT request with a binary body, where you select a local file to upload

Deployment

To deploy an application run the following commands:

cd backend
npm install
sls deploy -v

Run local version

cd backend
npm install
sls dynamodb install
sls offline start