Skip to content

This project offers functionalities including user authentication and authorization, CRUD operations for posts, commenting, user profile management, and administrative control and fast access--> https://blogposts-faf8bd0bf0fd.herokuapp.com/

Notifications You must be signed in to change notification settings

vinaytheprogrammer/Blog_Post

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blog API Application Project

Tech Stack

Server: Node, Express, MongoDB, Mongoose, JWT

API FEATURES

  • Authentication & Authorization
  • Post CRUD operations
  • Comment functionality
  • Get posts created count
  • Get all users who views someone's profile
  • Admin can unblock a blocked user
  • Update password
  • Profile photo uploaded

Purposed Features

You are welcome to contribute in this project #openSource.

  • System blocking user if inactive for 30 days
  • Admin can block a user
  • A user can block different users
  • A user who block another user cannot see his/her posts
  • Last date a post was created
  • Check if a user is active or not
  • Check last date a user was active
  • Changing user award base on number of posts created by the user
  • A user can follow and unfollow another user
  • Get following and followers count
  • Get total profile viewers count
  • Get blocked counts
  • A user can close his/her account

ENDPOINTS

Run Locally

Clone the project

  git clone https://link-to-project

Go to the project directory

  cd my-project

Install dependencies

  npm install

Start the server

  node server.js

Environment Variables

To run this project, you will need to add the following environment variables to your .env file

MONGODB_URL

Example:

Not Exact Ones But in this format you have to fill these fields.

MONGO_URL = mongodb+srv://vinaytheprogrammer:[email protected]/?retryWrites=true&w=majority&appName=blogs
SESSION_KEY = asdfg
CLOUDINARY_NAME = dmm0cn
CLOUDINARY_KEY = 883144795556623
CLOUDINARY_SECRET_KEY = 3x-hS1D5OiEWDzQubWz6rw

API Authentication

Some endpoints may require authentication for example. To create a create/delete/update post, you need to register your API client and obtain an access token.

The endpoints that require authentication expect a bearer token sent in the Authorization header.

Register a new API client

POST /api/v1/users/register

The request body needs to be in JSON format.

API Reference

User Login

POST /api/v1/users/login
Parameter Type Description Required
authentication string Your token no
email string Your email yes
password string Your password yes

Example request body:

{
  "email":"your email"
  "password":"your password"
}

get my profile

GET /api/v1/users/profile
Parameter Type Description Required
authentication string Your token yes

Get all users

GET /api/v1/users/users
Parameter Type Description Required
authentication string Your token no

view a user profile

GET /api/v1/users/profile-viewers/:id
Parameter Type Description Required
authentication string Your token yes
id string ID of the user you want to view his profile yes

Following a user

GET /api/v1/users/following/:id
Parameter Type Description Required
authentication string Your token yes
id string ID of the user you want to follow yes

UnFollowing a user

GET /api/v1/users/unfollowing/:id
Parameter Type Description Required
authentication string Your token yes
id string ID of the user you want to follow yes

Update user password

PUT /api/v1/users/update-password
Parameter Type Description Required
authentication string Your token yes
password string Enter your password yes

Example request body:

{
  "password":"value"
}

Update your profile

PUT /api/v1/users
Parameter Type Description Required
authentication string Your token yes
email string Enter your email no
firstname string Enter your firstname no
lastname string Enter your lastname no

Example request body:

{
  "email":"value",
  "firstname":"value",
  "lastname":"value",
}

Block another user

PUT /api/v1/users/block/:id
Parameter Type Description Required
authentication string Your token yes
id string Id of the user you want to block yes

Unblock user

PUT /api/v1/users/unblock/:id
Parameter Type Description Required
authentication string Your token yes
id string Id of the user you want to unblock yes

Admin blocking a user

PUT /api/v1/users/admin-block/:id
Parameter Type Description Required
authentication string Your token yes
id string Id of the user you want to block yes

Admin unblocking a user

PUT /api/v1/users/admin-unblock/:id
Parameter Type Description Required
authentication string Your token yes
id string Id of the user you want to unblock yes

Delete your account

  DELETE /api/v1/users/delete-account
Parameter Type Description Required
authentication string Your token yes

Upload Profile Photo

  DELETE /api/v1/users/profile-photo-upload
Parameter Type Description Required
authentication string Your token yes
profilePhoto string Image to upload yes

Posts API Refeference

Create Post

  POST /api/v1/posts
Parameter Type Description Required
authentication string Your token yes
title string Post title yes
description string Post description yes
category string ID of the category yes
photo string Image of the post yes

Example request body:

{
  "title":"value",
  "description":"value",
  "category":"value",
  "photo":"photo",
}

Get All Posts

  GET /api/v1/posts
Parameter Type Description Required
authentication string Your token no

Get Single Post

  GET /api/v1/posts/:id
Parameter Type Description Required
authentication string Your token yes
id string ID of the post yes

Toggle Post like

  GET /api/v1/postslikes/:id
Parameter Type Description Required
authentication string Your token yes
id string ID of the post yes

Toggle Post dislike

  GET /api/v1/posts/dislikes/:id
Parameter Type Description Required
authentication string Your token yes
id string ID of the post yes

Update Post

  PUT /api/v1/posts/:id
Parameter Type Description Required
authentication string Your token yes
id string ID of the post yes
title string title of the post yes
description string description of the post yes
category string category of the post yes
photo string photo of the post yes

Example request body:

{
  "title":"value",
  "description":"value",
  "category":"value",
  "photo":"photo",
}

Delete Post

  GET /api/v1/posts/dislikes/:id
Parameter Type Description Required
authentication string Your token yes
id string ID of the post yes

Comment API Reference

Create Comment

  POST /api/v1/comments/:id
Parameter Type Description Required
authentication string Your token yes
id string ID of the post yes

Delete Comment

  DELETE /api/v1/comments/:id
Parameter Type Description Required
authentication string Your token yes
id string ID of the comment yes

Update Comment

  PUT /api/v1/comments/:id
Parameter Type Description Required
authentication string Your token yes
id string ID of the post yes

About

This project offers functionalities including user authentication and authorization, CRUD operations for posts, commenting, user profile management, and administrative control and fast access--> https://blogposts-faf8bd0bf0fd.herokuapp.com/

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published