ToDo App
After you have every of the above requirements:
- Download the project:
go get -u github.com/avalchev94/to-do-api
- Update ./config/setup_env.sh enviroment variables.
- Open .bashrc*(on ubuntu ~/.bashrc)* and add the following code(replace GOPATH):
if [ -f ~/GOPATH/src/github.com/avalchev94/to-do-app/config/setup_env.sh ];
then
. ~/GOPATH/src/github.com/avalchev94/to-do-app/config/setup_env.sh
fi
- Create the database and import the schema:
dbcreate -U $PG_USER todo_app
#go to to-do-app main directory
psql -U $PG_USER todo_app < config/todoapp.sql
- Go to ./cmd/todo_app folder:
go build
./todo_app api
- GET /login Returns the currently logged user:
{"id": 1, "name":"avalchev", "email":"avl@bg.bg", "avatar":...}
- POST /login Start new login session:
{"name":"some_name", "password":"the_password"}
- POST /user Register new user:
{"name":"some_name", "password":"...", "email":"...", "avatar":"..."}
- GET /user/:id Returns the specified user:
{"id": 1, "name":"avalchev", "email":"avl@bg.bg", "avatar":...}
- GET /user/:id/labels Returns the labels that the user created:
[ {"id":1,"user_id":1,"name":"Work","color":"123456"}, {"id":2,"user_id":1,"name":"School","color":"ABCDEF"} ]
- GET /user/:id/tasks Returns the tasks that the user created:
[{"id":2,"user_id":1,"title":"sth","data":"I should..","labels":[{"id":1,"name":"Work","color":"123456"}],"labels_id":[1],"created":"2018-09..."}]
- POST /label Create new label:
{"name":"Work", "color":"000fff"}
- GET /label/:id Get label with id:
{"id":1,"user_id":1,"name":"Work","color":"123456"}
- POST /task Create new task:
{"title":"..", "data":"what u should do", "labels":[1, 5, 10]}
- GET /task/:id Get task with id:
{"id":2,"user_id":1,"title":"Finish..","data":"I should finish..","labels":[{"id":1,"name":"Work","color":"123456"}],"labels_id":[1],"created":"2018-09..."}