pvanhoven / recipes_old

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

recipes

Creating DynamoDb Tables

Assumes local dynamodb container

aws dynamodb create-table --cli-input-json file://db/create-recipes-table.json --endpoint-url http://localhost:8000
aws dynamodb create-table --cli-input-json file://db/create-users-table.json --endpoint-url http://localhost:8000

Updating an index, first had to delete index

aws dynamodb update-table --table-name Recipes --attribute-definitions AttributeName=userId,AttributeType=S AttributeName=name,AttributeType=S --global-secondary-index-updates file://api/db/update-recipes-table.json --endpoint-url http://localhost:8000

API Calls

GET: http://localhost:3000/recipes
POST: http://localhost:3000/users

Content-Type: application/json

{"userName": "phill", "email": "email@domain.com"}
POST: http://localhost:3000/recipes

Content-Type: application/json

{
  "name": "recipe name",
  "userId": "{from above POST to users}",
  "ingredients": [
    "item 1",
    "item 2"
  ],
  "instructions": [
    "do this",
    "do that"
  ]
}

About


Languages

Language:TypeScript 45.6%Language:JavaScript 38.6%Language:HCL 7.2%Language:HTML 4.1%Language:Shell 2.3%Language:CSS 1.2%Language:Pug 1.1%