Register User
-
Method:
POST
-
URL </register>
-
Data Params
Required:name=[string]
email=[string]
password=[string]
-
Success Response:
- Code: 201
Content:{ "_id": "5dbf463e66d4901e33fe6b81", "email": "[email protected]", "password": "$2a$10$8cEP6gHdxjU7aZimMA8xouv3Xq40htC6ikfpUHOdPsPWVg8IFHpzG", "name": "foo", "createdAt": "2019-11-03T21:27:26.087Z", "updatedAt": "2019-11-03T21:27:26.087Z", "__v": 0 }
- Code: 201
-
Error Response:
-
Code: 422 Unprocessable Entity
Content:
{ "message": [ "Email can not be empty" ] }
{ "message": [ "Name can not be empty" ] }
{ "message": [ "Please fill a valid email address" ] }
-
Code: 409 Conflict
Content:
{ "message": "User already exist." }
-
Code: 500 Internal Server Error
Content:
{ "message": "Internal Server Error" }
-
Login User
-
URL </login>
-
Method:
POST
-
Data Params
Required:email=[string]
password=[string]
-
Success Response:
- Code: 201
Content:{ "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVkYmY0NjNlNjZkNDkwMWUzM2ZlNmI4MSIsImVtYWlsIjoiYXNkYXNkYXNkQGFzZC5jb20iLCJpYXQiOjE1NzI4MTY1Mjl9.QPqj-wyuPI-pErO-PxDuJqe8a7gHysxRgQ8_yufcwH0" }
- Code: 201
-
Error Response:
- Code: 401 Unauthorized
Content:
{ "message": "User not found. Please register." }
- Code: 401 Unauthorized
Get All Articles
-
URL <_/articles>
-
Method:
GET
-
Headers
Authorization=[string]
-
Data Params
none -
Success Response:
- Code: 201
Content:[ { "_id": "5dc849754a895a81da0b6ae6", "title": "Aricle 1", "content": "<p>This is the content of article 1/p>", "UserId": "5dc848cd3fca71811dfc4087", "createdAt": "2019-11-10T17:31:33.252Z", "updatedAt": "2019-11-10T17:31:33.252Z", "__v": 0 }, { "_id": "5dc849754a895a81da0b6ae6", "title": "Aricle 2", "content": "<p>This is the content of article 2/p>", "UserId": "5dc848cd3fca71811dfc4087", "createdAt": "2019-11-10T17:31:33.252Z", "updatedAt": "2019-11-10T17:31:33.252Z", "__v": 0 } ]
- Code: 201
-
Error Response:
- Code: 401 Unauthorized
Content:
{ "name": "JsonWebTokenError", "message": "jwt must be provided" }
{ "name": "JsonWebTokenError", "message": "invalid token" }
- Code: 401 Unauthorized
Delete an article
-
URL </api/articles/{id}>
-
Method:
DELETE
-
Headers
Authorization=[string]
-
Data Params
None -
Success Response:
- Code: 201
Content:{ "_id": "5dc849754a895a81da0b6ae6", "title": "Aricle 1", "content": "<p>This is the content of article 1/p>", "UserId": "5dc848cd3fca71811dfc4087", "createdAt": "2019-11-10T17:31:33.252Z", "updatedAt": "2019-11-10T17:31:33.252Z", "__v": 0 }
- Code: 201
-
Error Response:
- Code: 401 UNAUTHORIZED
Content:{ "name": "JsonWebTokenError", "message": "invalid token" }
- Code: 401 UNAUTHORIZED