A Node.js REST API for create, uodate and delete posts with JWT user authentication
This API Service can be deployed and run on Docker. For instructions for installing Docker please visit https://docs.docker.com/get-docker/
Use either following command to clone the repository
git clone git@github.com:lakeedrock/cloubi_blog_server.git
or
git clone https://github.com/lakeedrock/cloubi_blog_server.git
Go to config folder and make a copy of example.config.env and rename it to config.env
cd config
cp example.config.env config.env
useing your favoirite text editer update following fonfig values
DB_URL= Mongodb server url
For Docker : use mongodb://mongo:27017/cloubi_blog
If you wish to run the project locally : use mongodb://localhost:{local mongodb port | default: 27017}/cloubi_blog
PORT= Api service port which you wish to run the API service
SECRET= Secret for JWT token
Go to the project root directory and run following command to run the project
docker-compose up
Use Postman
application to test the API service. Download Postman
application from https://www.postman.com/downloads/
Import API collection json file from cloubi_blog_server/postman/Cloubi.postman_collection.json
to Postman. For more instruction please visit https://learning.postman.com/docs/getting-started/importing-and-exporting-data/
API Call : http://api_service_url/api/checkhealth
Method : GET
Body Parms : none
Response Object:
{
"message": "ok"
}
API Call : http://api_service_url/api/register
Method : POST
Body Parms Object:
{
"name": String,
"email": String,
"password": String
}
Response Object:
{
"name": String,
"email": String,
"_id": String,
"__v": 0
}
API Call : http://api_service_url/api/login
Method : POST
Body Parms Object:
{
"email": String,
"password": String
}
Response Object:
{
"message": "success"
}
API Call : http://api_service_url/api/login
Method : GET
Body Parms Object: N/A
Response Object:
{
"_id": String,
"name": String,
"email": String,
"__v": 0
}
API Call : http://api_service_url/api/logout
Method : POST
Body Parms Object: N/A
Response Object:
{
"message": "success"
}
API Call : http://api_service_url/api/post
Method : POST
Body Parms Object:
{
"title": String,
"text": String
}
Response Object:
{
"message": "success",
"post_id": String
}
API Call : http://api_service_url/api/post
Method : GET
Body Parms Object:
{
"postId": String
}
Response Object:
{
"_id": String,
"title": String,
"text": String
"userId": String,
"createdAt": Date,
"updatedAt": Date,
"__v": 0
}
API Call : http://api_service_url/api/post
Method : PUT
Body Parms Object:
{
"postId": String,
"title": String,
"text": String
}
Response Object:
{
"message": "success"
}
API Call : http://api_service_url/api/post
Method : DELETE
Body Parms Object:
{
"postId": String
}
Response Object:
{
"message": "success"
}
#happycoding