This is a sample for todo api CRUD. Generated by phoenix framework.
To start Phoenix app:
- Install dependencies with
mix deps.get
- Create and migrate your database with
mix ecto.create && mix ecto.migrate
- Start Phoenix endpoint with
mix phoenix.server
Now you can go to localhost:4000/api/todos
from browser.
docker-compose
should be installed
Run todo_api and postgres db in detached mode
docker-compose up -d
after create and migrate db
docker-compose run web mix do ecto.create, ecto.migrate
Now you can create new items. Example with curl
:
create new item:
curl -XPOST http:https://localhost:4000/api/todos \
-H 'Content-type: application/json' \
--data '{"todo": {"description":"create todo", "complete":true}}'
get all items:
curl http:https://localhost:4000/api/todos
update item:
curl -XPUT http:https://localhost:4000/api/todos/1 \
-H 'Content-type: application/json' \
--data '{"todo", {"description":"update todo", "complete":false}}'
delete item:
curl -XDELETE http:https://localhost:4000/api/todos/1 \
turn off:
docker-compose down
ecs-cli should be installed.
- Configure ecs. docs
ecs-cli configure --region us-west-2 --access-key $AWS_ACCESS_KEY_ID --secret-key $AWS_SECRET_ACCESS_KEY --cluster ecs-cli-demo
- Run with command:
ecs-cli compose --file docker-compose.yml up
More commands can be found in official documentation