NodePost is a light backend-end logic for a blogpost website made with Node.js and Typescript. The application provides registeration and login routes where users are added to the MongoDB database and given an authentication token. The authorized user can then make a blogpost by providing a title and content. Other authorized users have the ability to comment on a given blogpost and search for users or blogposts. The user can also add blogposts to their favourite blogposts.
npm install
npm run devStart
Post http://localhost:8080/api/regis
A POST
Requist with payload the following format will add a user to the database if successfully verified.
{ "email": "name@email.com", "password" : "password", "userName" :"userOne" }
Post http://localhost:8080/api/auth
The same object must be provided in order to receive an auhtentication token.
{ "email": "name@email.com", "password" : "password", "userName" :"userOne" }
The authenticated user will receive a response with following object
{ "data": "SECRET_TOKEN", "message": "logged in successfully" }
Post http://localhost:8080/api/blogpost
The authenticated user must provide a the authentication token in the x-access-header
before making a post request with with following payload:
x-access-header : "SECRET_TOKEN"
{ "title": "blogpost title", "content" : "blogpost content" }
Post http://localhost:8080/api/blogpost/:blogpostId/comment
The authenticated user can post comments on a given blogpost with the following format:
{ "content" : "dummy comment content" }
Post http://localhost:8080/api/blogpost/:blogpostId/comment
The authenticated user can add a blogpost to favourites by making POST
request to this endpoint.
{"content" : "blogpost content" }
Search for an user witrh user ID
GET http://localhost:8080/api/search/:userId
retrieve the comments made by the user
GET http://localhost:8080/api/search/:userId/commentsByUser
retrieve the bogposts made by the user
GET http://localhost:8080/api/search/:userId/postsByUser
NodePost uses a number of open source projects to work properly:
- markdown-it - Markdown parser done right. Fast and easy to extend.
- node.js - evented I/O for the backend
- Express - fast node.js network app framework [@tjholowaychuk]
Made by Jaggar Yussef