Skip to content

Nipan83/blog-API

Repository files navigation

Node BLOG REST API

This is a simple REST API server implementation built on top of Node.js and Express.js with Mongoose.js for MongoDB integration. Authentication is handled using JWT integration. Testing is handled using mocha and chai

Build Status

Get Started:

git clone https://github.com/Nipan83/blog-API.git

cd blog-API

Running project

Manual

You need to have Node.js and npm installed.

Run server

	# Install all dependencies
	npm install

	# Start the server
	npm start

Base URI for making requests

Running locally

http://localhost:3000/

Heroku

https://nipan-blogapi.herokuapp.com/

RUN THE APIs

Check the APIs using Postman

Routes

POST Register

http://localhost:3000/register

or

https://nipan-blogapi.herokuapp.com/register

This route allows a user to register herself on the platform with basic information

username, email, password, firstname, lastname, blogURL

Email must be unique for new registration.

All you need to do is pass the information in the request body in key-value pair

alt text

POST Login

http://localhost:3000/login

or

https://nipan-blogapi.herokuapp.com/login

This route allows a user to log in herself on the platform with basic information

email and password

All you need to do is pass the information in the request body in key-value pair

A JWT TOKEN will be returned which will be used for further using the API.

The token should be placed in header key as x-access-token and value will be the token.

alt text

POST Blogpost

http://localhost:3000/blogpost
or
https://nipan-blogapi.herokuapp.com/blogpost

This route allows a user to create a blog post with following parameters

▪ Title, content

Authentication is handled here using JWT

alt text

alt text

PUT follow/{username}

http://localhost:3000/follow/{username}
or
https://nipan-blogapi.herokuapp.com/follow/{username}

This route allows you to follow new users

alt text

GET feed

http://localhost:3000/feed
or
https://nipan-blogapi.herokuapp.com/feed

This route returns all blog posts of users you follow

alt text

NOTE: For viewing own blog post user have to follow himself.

GET users

http://localhost:3000/getuser
or
https://nipan-blogapi.herokuapp.com/getuser

This route returns all the users registered.

This route is for monitoring purpose.

Token will also be needed here.

TESTING

	# TESTING of APIs
	npm test

	# NOTE: Since email field is unique for registering a user. So register test case may fail after running npm test two times.

	# To prevent the error, open test/test.js and change the email value to a new emailId.

AUTHOR

Created and Maintained by @Nipan83 - nipandas83@gmail.com

About

This is a simple REST API server implementation built on top of Node.js and Express.js with Mongoose.js for MongoDB integration.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors