Todo List web app REST API
API built for the data manegement of the web app Todo List, and to study the basicconcepts of REST and CORS
- NodeJs
- ExpressJs
- MongoDB
Returns a list of json about the tasks.
-
URL
/tasks
-
Method:
GET
-
URL Params
Required:
None
-
Data Params
None
-
Success Response:
- Code: 200
Content:[ { "_id": "5ef0bf8c76edf12768eb0fa9", "title": "Titulo", "description": "descrição", "createdAt": "2020-06-22T14:26:20.839Z", "updatedAt": "2020-06-22T14:26:20.839Z", "__v": 0 }, { "_id": "5ef0bf8d76edf12768eb0faa", "title": "Titulo", "description": "descrição", "createdAt": "2020-06-22T14:26:21.563Z", "updatedAt": "2020-06-22T14:26:21.563Z", "__v": 0 } ]
- Code: 200
-
Error Response:
- Code: 500 INTERNAL ERROR
Content:{ message: 'api internal error could not get', error }
- Code: 500 INTERNAL ERROR
Returns a single json about a task.
-
URL
/tasks/:id
-
Method:
GET
-
URL Params
Required:
/:id ex:. /5ef0bf6976edf12768eb0fa7
-
Data Params
None
-
Success Response:
- Code: 200
Content:{ "_id": "5ef0bf8c76edf12768eb0fa9", "title": "Titulo", "description": "descrição", "createdAt": "2020-06-22T14:26:20.839Z", "updatedAt": "2020-06-22T14:26:20.839Z", "__v": 0 },
- Code: 200
-
Error Response:
- Code: 500 INTERNAL ERROR
Content:{ message: 'api internal error could not get', error }
OR
- Code: 404 NOT FOUND
Content:{ message: 'could not find' }
- Code: 500 INTERNAL ERROR
Stores the json send in the request body in the database.
-
URL
/tasks
-
Method:
POST
-
URL Params
Required:
None
-
Data Params
{ "title": "Titulo", "description": "descrição", }
-
Success Response:
- Code: 200
Content:{ "_id": "5ef0bf8c76edf12768eb0fa9", "title": "Titulo", "description": "descrição", "createdAt": "2020-06-22T14:26:20.839Z", "updatedAt": "2020-06-22T14:26:20.839Z", "__v": 0 },
- Code: 200
-
Error Response:
- Code: 500 INTERNAL ERROR
Content:{ message: 'could not store a task', error }
- Code: 500 INTERNAL ERROR
Updates the given camp passed in json on the id passed in params.
-
URL
/tasks/:id
-
Method:
PUT
-
URL Params
Required:
/:id ex:. /5ef0bf6976edf12768eb0fa7
-
Data Params
{ "title": "titulo" }
OR
{ "description": "description" }
OR
{ "title": "titulo", "description": "description" }
-
Success Response:
- Code: 200
Content:{ "_id": "5ef0bf8c76edf12768eb0fa9", "title": "Titulo Atualizado", "description": "descrição Atualizada", "createdAt": "2020-06-22T14:26:20.839Z", "updatedAt": "2020-06-22T14:26:20.839Z", "__v": 0 },
- Code: 200
-
Error Response:
- Code: 500 INTERNAL ERROR
Content:{ message: 'could not update', error }
OR
- Code: 404 NOT FOUND
Content:{ message: 'could not find' }
- Code: 500 INTERNAL ERROR
Deletes a task.
-
URL
/tasks/:id
-
Method:
DELETE
-
URL Params
Required:
/:id ex:. /5ef0bf6976edf12768eb0fa7
-
Data Params
None
-
Success Response:
- Code: 200
Content:{ "message": "task is gone" }
- Code: 200
-
Error Response:
- Code: 500 INTERNAL ERROR
Content:{ message: 'could not delete a task', error }
- Code: 500 INTERNAL ERROR
Project under 📕 MIT license Built by Felipe Fideles in 2020