Create fancy to do app, using express, jquery, ajax
- RESTful endpoint for toDo's CRUD operation
- JSON formatted response
To register
Request Header
not needed
Request Body
{
email : <posted-email>,
password : <posted-password>
}
Response (201)
[
{
"id": <Automatically generated by database>,
"email": <posted-email>,
"password": <hashed posted-password>,
"updatedAt": "2020-04-30T11:26:59.712Z",
"createdAt": "2020-04-30T11:26:59.712Z"
}
]
Response (400 - Bad Request)
{
"errorCode" = 'VALIDATION_ERROR'
"message": "<returned error message>"
}
Response (500 - Internal Server Error)
{
"message": "<returned error message>"
}
To Log-In
Request Header
not needed
Request Body
{
email : <posted-email>,
password : <posted-password>
}
Response (201)
[
{
"access_token": <This access token generated automatically when you Log-in>
}
]
Response (400 - Bad Request)
{
"errorCode" = 'INVALID_USERNAME_OR_PASSWORD'
"message": "<returned error message>"
}
Response (500 - Internal Server Error)
{
"message": "<returned error message>"
}
Get all toDo-List
Request Header
{
"access_token": <This access token generated automatically when you Log-in>
}
Request Body
not needed
Response (200)
[
{
"id": 1,
"title": "<todos title>",
"description": "<todos description>",
"status": "<todos status after create or update>",
"due_date": "<date when this data/object is updated/created>",
"createdAt": "2020-04-27T07:20:33.949Z",
"updatedAt": "2020-04-27T07:20:33.949Z"
},
{
"id": 3,
"title": "<todos title>",
"description": "<todos description>",
"status": "<todos status after create or update>",
"due_date": "<date when this data/object is updated/created>",
"createdAt": "2020-04-27T07:21:47.000Z",
"updatedAt": "2020-04-27T08:12:59.330Z"
},
{
"id": 8,
"title": "<todos title>",
"description": "<todos description>",
"status": "<todos status after create or update>",
"due_date": "<date when this data/object is updated/created>",
"createdAt": "2020-04-27T11:04:43.556Z",
"updatedAt": "2020-04-27T11:05:23.575Z"
}
]
Response (500 - Internal Server Error)
{
"message": "<returned error message>"
}
Find toDo-List based on Id
Request Header
{
"access_token": <This access token generated automatically when you Log-in>
}
Request Body
not needed
Request Params
{ id: ':id' }
Response (200 - Ok)
[
{
"id": 1 <if req.params.id is '1'>,
"title": "<todos title>",
"description": "<todos description>",
"status": "<todos status after create or update>",
"due_date": "2020-04-27T07:20:33.947Z",
"createdAt": "2020-04-27T07:20:33.949Z",
"updatedAt": "2020-04-27T07:20:33.949Z"
}
]
Response (404 - Not Found)
{
"message": "error, data not found"
}
Create new toDo-List
Request Header
{
"access_token": <This access token generated automatically when you Log-in>
}
Request Body
{
"title": "<posted title of toDo-list>",
"description": "<posted description of toDo-list>",
"status": "berhasil di-create" <default>,
"due_date": new Date(),
}
Response (201 - Created)
{
"id": <given id by system>,
"title": "<posted title>",
"description": "<posted description>",
"status": "berhasil di-create",
"due_date": "2020-04-27T11:19:26.264Z",
"updatedAt": "2020-04-27T11:19:26.267Z",
"createdAt": "2020-04-27T11:19:26.267Z"
}
Response (400 - Bad Request)
{
"message": [
"kolom title tidak boleh kosong" <if title column is empty>,
"kolom description tidak boleh kosong" <if description column is empty>
]
}
Response (500 - Internal Server Error)
{
"message": "<returned error message>"
}
Update toDo-List based in Id
Request Header
{
"access_token": <This access token generated automatically when you Log-in>
}
Request Body
{
"title": "<updated title of toDo-list>",
"description": "<updated description of toDo-list>",
"status": "berhasil di-update" <default>,
"due_date": new Date()
}
Request Params
{ id: ':id' }
Response (200 - Ok)
{
"id": <given id by system>,
"title": "<updated title>",
"description": "<updated description>",
"status": "berhasil di-update",
"due_date": "2020-04-27T11:19:26.264Z",
"updatedAt": "2020-04-27T11:19:26.267Z",
"createdAt": "2020-04-27T11:19:26.267Z"
}
Response (400 - Bad Request)
{
"message": [
"kolom title tidak boleh kosong" <if title column is empty>,
"kolom description tidak boleh kosong" <if description column is empty>
]
}
Response (404 - Not Found)
{
"message": "error, data not found"
}
Response (500 - Internal Server Error)
{
"message": "<returned error message>"
}
Delete toDo-List based on Id
Request Header
{
"access_token": <This access token generated automatically when you Log-in>
}
Request Body
not needed
Request Params
{ id: ':id' }
Response (200 - Ok)
{
"message": "data succesfully deleted"
}
Response (404 - Not Found)
{
"message": "error, data not found"
}
Response (500 - Internal Server Error)
{
"message": "<returned error message>"
}