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:
- GET - https://b9rsz7l5g9.execute-api.eu-central-1.amazonaws.com/dev/feed
- GET - https://b9rsz7l5g9.execute-api.eu-central-1.amazonaws.com/dev/useritems
- POST - https://b9rsz7l5g9.execute-api.eu-central-1.amazonaws.com/dev/feed
- PATCH - https://b9rsz7l5g9.execute-api.eu-central-1.amazonaws.com/dev/feed/{itemId}
- DELETE - https://b9rsz7l5g9.execute-api.eu-central-1.amazonaws.com/dev/feed/{itemId}
- POST - https://b9rsz7l5g9.execute-api.eu-central-1.amazonaws.com/dev/feed/{itemId}/attachment
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)
- Authenticate postman
- Use Postman requests
- Go to the
Authorization
tab in the Postman collection. All requests will inherit this authorization method - Select Type
OAuth2.0
andRequest Headers
- Select
Get New Access Token
- Enter the following information and click
Get New Access Token
Grant Type
:Authorization Code
Callback Url
: http://localhost:3000/callback- Uncheck
Authorize using browser
Auth URL
: https://dev-kmdcgf-x.eu.auth0.com/authorize/Access Token Url
: https://dev-kmdcgf-x.eu.auth0.com/oauth/tokenClient ID
: aCwMOQJKS9BPJWDkyOe3Alc2KE6E9Qty- Leave
Client Secret
empty Scope
: openid- Leave
State
empty - For
Client Authentication
selectSend as Basic Auth header
- 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)
- DO NOT CLICK
Use Token
, it does not work. Instead, copy theid_token
into the Access Token field. - Now you should be able to do all requests.
Example workflow: 0. Get feed (No auth needed)
- Create two items
- Get user items
- Update one item by giving a itemId (get this from previous request 2.)
- Get user items
- Delete one item by giving a itemId
- Get user items
- Get upload url by giving a itemId
- Upload image, by copying returned Url into the
Upload file
PUT request with a binary body, where you select a local file to upload
To deploy an application run the following commands:
cd backend
npm install
sls deploy -v
cd backend
npm install
sls dynamodb install
sls offline start