Create kanban-app, using express
* RESTful endpoint for task List's CRUD operation
* JSON formatted response
* Web Server response
Make sure you have Node.js and npm in your computer and then run `npm install`.
In order to get access to all of the routes, you will need a `JWT(JSON Web Token) Token` which will be generated automatically after you sign in successfully.
Run `nodemon app.js to start the server.
Run `live-server --host=localhost` to start the client
##Restful endpoints
Client URL : http://localhost:8080
Server URL : http://localhost:3000
get all task list
Request Header
{
access_token: token
}
Request Body
not needed
Response (200)
[
{
"id": 4,
"title": "Mengerjakan Kanban App",
"createdAt": "2020-11-30T12:51:36.519Z",
"updatedAt": "2020-11-30T12:51:36.519Z",
"CategoryId": 1,
"OrganizationId": 1,
"UserId": 3
},
{
"id": 1,
"title": "Mengerjakan Server",
"createdAt": "2020-11-30T12:49:21.466Z",
"updatedAt": "2020-11-30T13:07:23.698Z",
"CategoryId": 2,
"OrganizationId": 1,
"UserId": 3
}
Response(401- Unauthorized)
{
"message": "You must login first"
}
Response (500 - Bad Request)
{
"message": "Internal Server Error"
}
Create new task
_Request Header
{
access_token: token
}
Request Body
{
"title": "<title to get insert into>",
"CategoryId": "<CategoryId to get insert into>",
"OrganizationId": "<Organization to get insert into>"
}
Response (201 - Created)
{
"id": 4,
"title": "Mengerjakan Kanban App",
"createdAt": "2020-11-30T12:51:36.519Z",
"updatedAt": "2020-11-30T12:51:36.519Z",
"CategoryId": 1,
"OrganizationId": 1,
"UserId": 3
}
Response(400- bad request)
{
"message": "Validation error: : Validation notEmpty on title failed"
}
Response(401- Unauthorized)
{
"message": "You must login first"
}
Response (500 - Bad Request)
{
"message": "Internal Server Error"
}
get task by id Request Header
{
access_token: token
}
Request Body
not needed
Response (200)
{
"id": 4,
"title": "Mengerjakan Kanban App",
"createdAt": "2020-11-30T12:51:36.519Z",
"updatedAt": "2020-11-30T12:51:36.519Z",
"CategoryId": 1,
"OrganizationId": 1,
"UserId": 3
}
Response(401- Unauthorized)
{
"message": "You must login first"
}
Response (500 - Bad Request)
{
"message": "Internal Server Error"
}
Response(404 - not found)
{
"message": "error not found"
}
### PUT/task/:id
>Update task by ID
_Request Header_
{ access_token: token }
_Request Body_
{ "title": "<title to get updated later on>", "CategoryId": "", "UserId": "" }
_Response(200)_
{
"id": 4,
"title": "Mengerjakan Kanban App",
"createdAt": "2020-11-30T12:51:36.519Z",
"updatedAt": "2020-11-30T12:51:36.519Z",
"CategoryId": 1,
"OrganizationId": 1,
"UserId": 3
}
_Response(401- Unauthorized)_
{ "message": "You must login first" }
_Response(403- Forbidden)_
{ "message": "you are not authorized" }
_Response(404 - not found)_
{ "message": "error not found" }
_Response(400- bad request)_
{ "message": "Validation error: Validation notEmpty on title failed" }
_Response (500)_
{ "message": "Internal Server Error" }
### PUT/task/:id
>Modify category task by ID
_Request Header_
{ access_token: token }
_Request Body_
{ "CategoryId": "" }
_Response(200)_
{ { "id": 4, "title": "Mengerjakan Kanban App", "createdAt": "2020-11-30T12:51:36.519Z", "updatedAt": "2020-11-30T12:51:36.519Z", "CategoryId": 2, "OrganizationId": 1, "UserId": 3 } }
_Response(401- Unauthorized)_
{ "message": "You must login first" }
_Response(403- Forbidden)_
{ "message": "you are not authorized" }
_Response(404 - not found)_
{ "message": "error not found" }
_Response (500)_
{ "message": "Internal Server Error" }
Delete task by ID
Request Header
{
access_token: token
}
Response(200)
{
"message": "delete success"
}
Response(401- Unauthorized)
{
"message": "You must login first"
}
Response(403- Forbidden)
{
"message": "you are not authorized"
}
Response(404 - not found)
{
"message": "error not found"
}
Response (500)
{
"message": "Internal Server Error"
}
Create User
Request Header
not needed
Request Body
{
"email": "<User's email>",
"password": "<User's password>"
}
Response(201)
{
"id": 2,
"email": "[email protected]",
"password": "$2a$08$h.kbgDtxJwE/koklvTOWNOZEU6/csi46/RbbIjwfQB6B3cyY/NS.W",
"updatedAt": "2020-11-27T18:53:16.688Z",
"createdAt": "2020-11-27T18:53:16.688Z"
}
Response(400- bad request)
{
"message": "Validation error: min password length is 4, email must be unique, Validation error: Validation isEmail on email failed,\nValidation error: Validation notEmpty on email failed, Validation error: min password length is 4,\nValidation error: Validation isEmail on email failed,\nValidation error: Validation notEmpty on password failed,email must be unique"
}
Response (500)
{
"message": "Internal Server Error"
}
Login User
Request Header
not needed
Request Body
{
"email": "<User's email>",
"password": "<User's password>"
}
Response(200)
{
"access_token": <token>
}
Response(400- bad request)
{
"message": "Invalid Account, invalid email or password"
}
Response (500)
{
"message": "Internal Server Error"
}
Google Sign IN User
Request Header
not needed
Request Body
{
"id_token": <id_token>;
}
Response(200)
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NiwiZW1haWwiOiJvZ3lyYWhtYXdhbkBnbWFpbC5jb20iLCJpYXQiOjE2MDY1MjM5ODJ9.67RLPaYnmqyfiEvEnITuq3QsLjX8AEBbpiHUJxaPkrQ"
}
Response (500)
{
"message": "Internal Server Error"
}
### POST/organization
>Create new organization
__Request Header_
_Request Body_
{ "name": "", }
_Response (201 - Created)_
{
"id": 1,
"name": "florence-fox",
"createdAt": "2020-11-30T12:36:57.885Z",
"updatedAt": "2020-11-30T12:36:57.885Z"
}
_Response(400- bad request)_
{ "message": "Validation error: : Validation notEmpty on title failed" }
_Response (500 - Bad Request)_
{ "message": "Internal Server Error" }
### GET/organization
>GET organization
__Request Header_
_Request Body_
Response (200)
[
{
"id": 1,
"name": "florence-fox",
"createdAt": "2020-11-30T12:36:57.885Z",
"updatedAt": "2020-11-30T12:36:57.885Z"
}
]
Response (500 - Bad Request)
{
"message": "Internal Server Error"
}
Create new category
_Request Header
{
access_token: token
}
Request Body
{
"title": "<title to get insert into>",
}
Response (201 - Created)
{
"id": 1,
"title": "backlog",
"createdAt": "2020-11-30T10:15:44.126Z",
"updatedAt": "2020-11-30T10:15:44.126Z"
}
Response(400- bad request)
{
"message": "Validation error: : Validation notEmpty on title failed"
}
Response (500 - Bad Request)
{
"message": "Internal Server Error"
}
GET category
_Request Header
{
access_token: token
}
Request Body
_Response (200)_
[ { "id": 1, "title": "backlog", "createdAt": "2020-11-30T10:15:44.126Z", "updatedAt": "2020-11-30T10:15:44.126Z", "Tasks": [ { "id": 5, "title": "pusing bikin tampilan", "createdAt": "2020-12-03T08:47:48.037Z", "updatedAt": "2020-12-04T07:06:39.889Z", "CategoryId": 1, "OrganizationId": 1, "UserId": 3, "User": { "id": 3, "email": "[email protected]", "password": "$2a$10$mf3PV1901mh4nJrCoqnPJOhMDdeL3j4lk24j5zCNAFrc6Y.8Cw9wq", "createdAt": "2020-11-30T12:40:40.432Z", "updatedAt": "2020-11-30T12:40:40.432Z", "OrganizationId": 1 }, "Organization": { "id": 1, "name": "florence-fox", "createdAt": "2020-11-30T12:36:57.885Z", "updatedAt": "2020-11-30T12:36:57.885Z" } }, { "id": 4, "title": "Mengerjakan Kanban App", "createdAt": "2020-11-30T12:51:36.519Z", "updatedAt": "2020-11-30T12:51:36.519Z", "CategoryId": 1, "OrganizationId": 1, "UserId": 3, "User": { "id": 3, "email": "[email protected]", "password": "$2a$10$mf3PV1901mh4nJrCoqnPJOhMDdeL3j4lk24j5zCNAFrc6Y.8Cw9wq", "createdAt": "2020-11-30T12:40:40.432Z", "updatedAt": "2020-11-30T12:40:40.432Z", "OrganizationId": 1 }, "Organization": { "id": 1, "name": "florence-fox", "createdAt": "2020-11-30T12:36:57.885Z", "updatedAt": "2020-11-30T12:36:57.885Z" } } ] }, ]
_Response (500 - Bad Request)_
{ "message": "Internal Server Error" }