Skip to content

Latest commit

 

History

History
52 lines (40 loc) · 1.96 KB

README.md

File metadata and controls

52 lines (40 loc) · 1.96 KB

📝 Blog API

A full-featured RESTful Blog API built with Node.js, Express, TypeScript, and MongoDB using JWT-based cookie authentication. Authenticated users can create, update, delete blog posts, leave comments, and like posts.


🔧 Tech Stack

  • Node.js
  • Express.js
  • TypeScript
  • MongoDB + Mongoose
  • JWT + Cookie Authentication
  • bcryptjs for password hashing
  • express-validator for input validation
  • cookie-parser

🚀 Features

🟢 Authentication

  • POST /api/userRegistration – Register as a new user
  • POST /api/adminRegistration – Register as an admin
  • POST /api/login – Login user and set HTTP-only JWT cookie
  • GET /api/getInformation – Get information about current logged-in user

📝 Blogs

  • POST /api/createBlogPost – Create a new blog post (auth required)
  • GET /api//blogSearch?title=Something&tag=someThing&page=somePage&limit=SomeLimit(max 50) – Get all blog posts with pagination title search query and tags search query
  • PATCH /api/editBlogPost – Update a blog post (owner & admin only)
  • DELETE /api/deleteBlogPost – Delete a blog post (owner & admin only)
  • GET /api/createdBlogs - Get created blog posts
  • PATCH /api/changePublishStatus - Change publish status of a blog post (owner & admin only)
  • GET /api/publishedPosts - Get published posts
  • PATCH /api/like-unlikeBlogPost - Like or unlike blog post

💬 Comments

  • POST /api/blogs/newComment – Add a comment to a blog (auth required)
  • DELETE /api/deleteComment – Delete a comment (only the comment’s author)
  • GET /api/getPostsComments – Get all comments under a post
  • PATCH /api/likeOrUnlikeComment – Like or unlike a comment
  • PATCH /api/editCommentContent – Edit a comments content (sender & admin only)

🧪 Running Locally

  1. Clone this repo
git clone https://github.com/jamaldeen09/Blog-RESTFUL-API.git
cd Blog-RESTFUL-API