Feat: Todo List `REST API`
nelsonic opened this issue ยท 2 comments
Once deployed to Fly.io with CI/CD #52 and auth
is added #37
we should add a basic REST API
endpoint to CRUD
Todo List items.
Why?
As part of building a full-stack App using our chosen Tech Stack https://github.com/dwyl/technology-stack#the-petal-stack
We want to build the backend API in Phoenix
.
This mini tutorial is the perfect place to showcase building such an API because all the ground-work is already done for Todo list items
.
Todo
- in the same Phoenix App, create a new
api_controller.ex
forCRUD
-ing theTodo
listitems
(you can use:pipe_through :json
).Remember our objective is to leverage as much of the existing work in this repo as possible. ๐
- Create an API Endpoint for
Creating
anew
todo listitem
and test it viacURL
(orPostman
)- Should accept a
JSON
payload with the necessary data, e.g:
person_id
(Int
)status
(Int
)text
(String
)
- Should accept a
phoenix-todo-list-tutorial/lib/app/todo/item.ex
Lines 5 to 8 in e945ed2
-
Should create a new Todo
item
if the data is valid -
Create a
REST API
Endpoint forediting
theTodo
listitem.text
:- Signature:
POST /items/:id/
- Should accept the
item.id
(Int
) anditem.text
(String
) and return200
if successful. ๐
- Signature:
-
Create
REST API
Endpoint for Updating thestatus
of theitem
i.e. setting it to "done" โ
Relevant Learning
Please read: https://github.com/dwyl/phoenix-content-negotiation-tutorial ๐
And if you have any questions regarding content negotiation please open an issue. ๐
For this
project we don't need to have all the same routes we just need:
- Create ๐
- Edit ๐
- Update status โ
@LuchoTurtle assigning this to you. But if anything is unclear please comment. ๐ฌ ๐
@LuchoTurtle please see: dwyl/hits#168 ๐