Register new user
Parameter | Type | Description |
---|---|---|
name |
string |
Required User name |
email |
string |
Required User Email |
password |
string |
Required User password |
age |
string |
User age |
POST /users
- Response
{
"code": 201,
"user": [
{
"id": 1,
"name": "Suhaib",
"email": "[email protected]",
"age": 22,
"createdAt": "2022-06-11T17:43:05.503Z",
"updatedAt": "2022-06-11T17:43:05.503Z"
},
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"
}
]
}
Login registered user
Parameter | Type | Description |
---|---|---|
email |
string |
Required User Email |
password |
string |
Required User password |
POST /users/login
- Response
{
"code": 200,
"user": [
{
"id": 1,
"name": "Suhaib",
"email": "[email protected]",
"age": 22,
"createdAt": "2022-06-11T17:43:05.503Z",
"updatedAt": "2022-06-11T17:43:05.503Z"
},
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"
}
]
}
Logout user from the current device
Parameter | Type | Description |
---|---|---|
email |
string |
Required User Email |
password |
string |
Required User password |
POST /users/logout
!Authenticated!
- Response
{
"code": 200,
"msg": "Logged out"
}
Logout user from all the device
Parameter | Type | Description |
---|---|---|
email |
string |
Required User Email |
password |
string |
Required User password |
POST /users/logoutAll
!Authenticated!
- Response
{
"code": 200,
"msg": "Logged out from all the device"
}
Get profile of the current user
GET /users/me
!Authenticated!
- Response
{
"code": 200,
"user": {
"id": 1,
"name": "Suhaib",
"email": "[email protected]",
"age": 22,
"createdAt": "2022-06-11T17:43:03.023Z",
"updatedAt": "2022-06-11T17:43:03.023Z"
}
}
Edit current user profile
Parameter | Type | Description |
---|---|---|
name |
string |
User name |
password |
string |
User password |
email |
string |
User email |
age |
string |
User age |
PATCH /users/me
!Authenticated!
- Response
{
"code": 200,
"user": {
"id": 1,
"name": "Rafi",
"email": "[email protected]",
"age": 21,
"createdAt": "2022-06-11T17:43:03.023Z",
"updatedAt": "2022-06-11T17:43:03.023Z"
}
}
Create new blog for login user
Parameter | Type | Description |
---|---|---|
title |
string |
Required Blog title |
description |
string |
Required Blog description |
POST /blogs/create
!Authenticated!
- Response
{
"code": 201,
"blog": {
"id": 5,
"ownerId": 3,
"title": "My first blog",
"description": "description of my first blog",
"createdAt": "2022-06-11T17:46:41.866Z",
"updatedAt": "2022-06-11T17:46:41.866Z"
}
}
Get most recent blogs (10 by default)
Parameter | Type | Description |
---|---|---|
?limit |
string |
Limit the number of blogs fetched from database.(10 default) |
?skip |
string |
Skip the number of blogs fetched from the database. |
GET /blogs
- Request
"localhost/blogs?limit=2&skip=2"
- Response
{
"code": 200,
"blogs": [
{
"id": 2,
"title": "My second blog",
"description": "description of my second blog",
"createdAt": "2022-06-11T17:45:23.882Z",
"updatedAt": "2022-06-11T17:45:23.882Z",
"ownerId": 4
},
{
"id": 1,
"title": "My first blog",
"description": "description of my first blog",
"createdAt": "2022-06-11T17:45:12.916Z",
"updatedAt": "2022-06-11T17:45:12.916Z",
"ownerId": 4
}
]
}
Get a specific blog by id
GET /blogs/:id
- Request
"localhost/blogs/2"
- Response
{
"code": 200,
"blog": [
{
"id": 2,
"title": "My second blog",
"description": "description of my second blog",
"createdAt": "2022-06-11T17:45:23.882Z",
"updatedAt": "2022-06-11T17:45:23.882Z",
"ownerId": 4
}
]
}
Delete a blog by id
DELETE /blogs/:id
!Authenticated!
- Request
"localhost/blogs/2"
- Response
{
"code": 200
}