This API will function as a CRUD for a todo app. Funcionalities:
- Create a task
- List all tasks
- Update a task by id
- Remove a task by id
- Mark a task as completed
- Import massive tasks by a .csv
First Commit:
- Created server
- Setted server to listen on port 3333
- Created dev script with flag --watch
Structuring Routes - List/Create:
- Created file routes.js
- Created a list variable for storing the tasks
- Yet not decided about Stateless or Statefull application, but probably Statefull
Created a response if request on route GET/tasks:
- Destructuring the response object to get the method and url
- Define a response if the method is a GET and the url is /tasks
- Converted the response data (tasks) to a JSON string structure for the front-end
- Setted the reponse header of Content-type to be application/json
Created a response if request on route POST/tasks:
- Push the Array object of the request to the Array of tasks on the application memory
- Defined a 201 status code - "Created" - as a parameter to the method writeHead of the response
- Defined a 404 status code - "Not Found" - as a parameter to the method writeHead of the response