Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

hcoa/todo-api-phoenix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

TodoApi

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.

Run in docker with compose

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

Deploying to AWS ECS

ecs-cli should be installed.

  1. 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
  1. Run with command:
ecs-cli compose --file docker-compose.yml up

More commands can be found in official documentation

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages