{
email: String,
password: String
}
status: 200,
result:
{
token: <access token>
}
status: 401,
result: "Invalid email or password"
-
{ email: String, password: String }
-
{ "_id": "5e1badb60312410893d356a9", "email": "<email>", "password":<hashed password>, "createdAt": "2020-01-12T17:00:00.000Z", }
-
status: 400 result: "email must be unique"
status : 400
result:
[
"User.email cannot be null",
"User.password cannot be null"
]
Seluruh akses di pada endpoint /todos menggunakan authorizasi
Authorization:
token: <login token>
Failed Authorization : "Invalid access token"
-
[ { "_id": "5e1bb3d399f1020f41dcbf74", "todoname": "example", "description": "example todo", "due_date": "2020-01-13T00:01:02.355Z", "userId": "5e1badb60312410893d356a9", "status": false, "created_at": "2020-01-13T00:03:31.504Z" }, ... or more ]
Seluruh akses create di todo memiliki hooks :
- Jika todoname kosong maka akan menjadi = '(No Title)'
- Default status ketika create adalah false
- Default createdAt atau timestamp nya adalah waktu todo itu dibuat
- Jika due_date tidak diisi maka default menjadi tanggal todo dibuat
-
due_date menggunakan format isoString
{ "todoname" : "example", "description" : "example todo", "due_date" : "2020-01-13T00:01:02.355Z" }
-
{ "msg": "Todo's Added", "result": { "_id": "5e1bb3d399f1020f41dcbf74", "todoname": "example", "description": "example todo", "due_date": "2020-01-13T00:01:02.355Z", "userId": "5e1badb60312410893d356a9", "status": false, "created_at": "2020-01-13T00:03:31.504Z", "__v": 0 } }
-
Jika description tidak di isi
{ "status": 400, "msg": { "description": { "message": "Description must not empty", "name": "ValidatorError", "properties": { "message": "Description must not empty", "type": "required", "path": "description" }, "kind": "required", "path": "description" } } }
-
params menggunakan id todo
-
{ "todoname" : "example update", "description" : "example todo update", "due_date" : "" }
-
{ "msg": "Todo has been updated" }
-
Jika todo id salah
{ "stringValue": "\"5e1bb76e974fa4151df0108\"", "kind": "ObjectId", "value": "5e1bb76e974fa4151df0108", "path": "_id", "reason": {}, "message": "Cast to ObjectId failed for value \"5e1bb76e974fa4151df0108\" at path \"_id\" for model \"Todo\"", "name": "CastError" }
-
params menggunakan id todo
-
{ "msg": "Todo has been deleted", "result": { "_id": "5e1bb3d399f1020f41dcbf74", "todoname": "example", "description": "example todo", "due_date": "2020-01-13T00:01:02.355Z", "userId": "5e1badb60312410893d356a9", "status": false, "created_at": "2020-01-13T00:03:31.504Z", "__v": 0 } }
-
Jika todo id salah :
{ "stringValue": "\"5e1bb76e974fa4151df0108\"", "kind": "ObjectId", "value": "5e1bb76e974fa4151df0108", "path": "_id", "reason": {}, "message": "Cast to ObjectId failed for value \"5e1bb76e974fa4151df0108\" at path \"_id\" for model \"Todo\"", "name": "CastError" }