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.
- Node.js
- Express.js
- TypeScript
- MongoDB + Mongoose
- JWT + Cookie Authentication
- bcryptjs for password hashing
- express-validator for input validation
- cookie-parser
POST /api/userRegistration– Register as a new userPOST /api/adminRegistration– Register as an adminPOST /api/login– Login user and set HTTP-only JWT cookieGET /api/getInformation– Get information about current logged-in user
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 queryPATCH /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 postsPATCH /api/changePublishStatus- Change publish status of a blog post (owner & admin only)GET /api/publishedPosts- Get published postsPATCH /api/like-unlikeBlogPost- Like or unlike blog post
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 postPATCH /api/likeOrUnlikeComment– Like or unlike a commentPATCH /api/editCommentContent– Edit a comments content (sender & admin only)
- Clone this repo
git clone https://github.com/jamaldeen09/Blog-RESTFUL-API.git
cd Blog-RESTFUL-API