To start API using command:
docker-compose up
Docker will build rest API application image then start api and db service.
Root URL is http://localhost:3000
At 26/01/2019 I'm using Docker version 18.09.0, build 4d60db4 and docker-compose version 1.21.2, build a133471
-
URL:
/api/v1/tasks
Method:GET
Content-type:application/json
Success response:Status code: 200 Response data: [ { "id": "5c4c45b2216949001e5014c4", "subject": "Example 1", "detail": "", "status": 0 }, { "id": "5c4c6501804649001eafc6f0", "subject": "Example 2", "detail": "This is descriptio", "status": 0 }, ] -
URL:
/api/v1/tasks/:taskId
Method:GET
Content-type:application/json
URL params:Required: taskId: hexadecimal string (objectId of mongodb) example: 5c4c6501804649001eafc6f0Success response:
Status code: 200 Response data: { "id": "5c4c6501804649001eafc6f0", "subject": "Example 1", "detail": "", "status": 0 }Errors response: If
taskIdis not valid.Status code: 400 Response data: { "message": "Invalid params", "errors": [ { "location": "params", "param": "taskId", "value": "1", "msg": "taskId is invalid" } ] }If a task not found.
Status code: 404 Response data: { "message": "Not found" } -
URL:
/api/v1/tasks
Method:POST
Content-type:application/json
Body params:Required: subject: string example: "example subject" Optional: detail: string example: "this is description"Success response:
Request body: { "subject": "example subject", "detail": "this is description" }Status code: 201 Response data: { "id": "5c4c6c68804649001eafc6f1", "subject": "example subject", "detail": "this is description", "status": 0 }Errors response: If
subjectis empty or not string.Request body: { }Status code: 400 Response data: { "message": "Invalid params", "errors": [ { "location": "body", "param": "subject", "msg": "subject is required" }, { "location": "body", "param": "subject", "msg": "subject must be string" } ] } -
URL:
/api/v1/tasks/:taskId
Method:PUT
Content-type:application/json
URL params:Required: taskId: hexadecimal string (objectId of mongodb) example: 5c4c6501804649001eafc6f0Body params:
Required: subject: string example: "example subject edit" Optional: detail: string example: "this is description edit"Success response:
Request body: { "subject": "example subject edit", "detail": "this is description edit", }Status code: 200 Response data: { "id": "5c4c6c68804649001eafc6f1", "subject": "example subject edit", "detail": "this is description edit", "status": 0 }Errors response: If a task not found.
Status code: 404 Response data: { "message": "Not found" }If
taskIdis not valid.Status code: 400 Response data: { "message": "Invalid params", "errors": [ { "location": "params", "param": "taskId", "value": "1", "msg": "taskId is invalid" } ] }If
subjectis empty or not string.Request body: { }Status code: 400 Response data: { "message": "Invalid params", "errors": [ { "location": "body", "param": "subject", "msg": "subject is required" }, { "location": "body", "param": "subject", "msg": "subject must be string" } ] } -
URL:
/api/v1/tasks/:taskId/status
Method:PUT
Content-type:application/json
URL params:Required: taskId: hexadecimal string (objectId of mongodb) example: 5c4c6501804649001eafc6f0Body params:
Required: status: Number (1 or 0 , 0 = pending, 1 = done) example: 1Success response:
Request body: { "status": 1 }Status code: 200 Response data: { "id": "5c4c6c68804649001eafc6f1", "subject": "example subject edit", "detail": "this is description edit", "status": 1 }Errors response: If a task not found.
Status code: 404 Response data: { "message": "Not found" }If
taskIdis not valid.Status code: 400 Response data: { "message": "Invalid params", "errors": [ { "location": "params", "param": "taskId", "value": "1", "msg": "taskId is invalid" } ] }If
statusis not be1or0.Status code: 400 Response data: { "message": "Invalid parameter or body", "errors": [ { "location": "body", "param": "status", "value": "Example String", "msg": "status is invalid" } ] } -
URL:
/api/v1/tasks/:taskId
Method:DELETE
Content-type:application/json
URL params:Required: taskId: hexadecimal string (objectId of mongodb) example: 5c4c6501804649001eafc6f0Success response:
Status code: 200 Response data: -Errors response: If a task not found.
Status code: 404 Response data: { "message": "Not found" }If
taskIdis not valid.Status code: 400 Response data: { "message": "Invalid params", "errors": [ { "location": "params", "param": "taskId", "value": "1", "msg": "taskId is invalid" } ] }