Coder Social home page Coder Social logo

mahmoudmohamed22 / social-media-nodejs-iti Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 180 KB

Social Media NodeJS ITI, This project is a Social Media Backend Server built using Node.js. It implements CRUD operations for User, Post, Comments and Review models. Additionally, it also includes features such as Role based authentication, request validation, error handling and data aggregation using MongoDB Aggregation Pipelines.

License: MIT License

JavaScript 100.00%
api backend backend-server cloudinary middleware models mongodb mongoose multer nodejs

social-media-nodejs-iti's Introduction

Social-Media-NodeJS-ITI

Social Media NodeJS ITI, This project is a Social Media Backend Server built using Node.js. It implements CRUD operations for User, Post, Comments and Review models. Additionally, it also includes features such as Role based authentication, request validation, error handling and data aggregation using MongoDB Aggregation Pipelines.

Technologies Used

  • Node.js
  • Express.js
  • MongoDB
  • Mongoose
  • Joi
  • Cloudinary
  • Multer

Features

  • User model and CRUD operations with role-based authentication (admin, creator, user)
  • Post model and CRUD operations
  • Comments model and CRUD operations
  • Review system where users can create reviews for posts created by creators
  • Profile pictures for users with image uploading through Multer and Cloudinary
  • API protection for allowed roles
  • Retrieval of comments and reviews with each post
  • Retrieval of posts with each user
  • Protection of sensitive information such as passwords
  • Request validation using Joi
  • Error handling strategy
  • Bonus feature: top 5 rated posts based on highest average reviews using MongoDB aggregation pipelines

Getting Started

To get started with the project, follow these steps:

Prerequisites

Make sure you have the following installed on your system:

  • Node.js (v14 or later)
  • MongoDB
  • NPM

Installing

1-Clone the repository: git clone https://github.com/mahmoudmohamed22/Social-Media-NodeJS-ITI.git

2-Install dependencies:

npm install

3-Create .env file and add required environment variables.

PORT=<your port to listen server>
DATABASE_URL=<your MongoDB URI>
SALT=<your round salt>
JWT_SECRET=<your JWT secret>
CLOUDINARY_CLOUD_NAME=<your Cloudinary cloud name>
CLOUDINARY_API_KEY=<your Cloudinary API key>
CLOUDINARY_API_SECRET=<your Cloudinary API secret>

4-Start the server:

npm start

Usage

Once the server is running, you can use the following endpoints:

  • /api/user/signup - POST request to register a new user
  • /api/user/login- POST request to log in an existing user
  • /api/user - GET request to retrieve all users (admin role only)
  • /api/user/:id - GET request to retrieve a single user (admin role only)
  • /api/user/:id - PUT request to update a user's information (user can update their own information, admin role can update any user)
  • /api/user/:id - DELETE request to delete a user (admin role only)
  • /api/posts - GET request to retrieve all posts
  • /api/posts/:id - GET request to retrieve a single post
  • /api/posts - POST request to create a new post (creator role only)
  • /api/posts/:id - PUT request to update a post (creator role only)
  • /api/posts/:id - DELETE request to delete a post (creator role only)
  • /api/posts/:post_id/comments - GET request to retrieve all comments
  • /api/posts/:post_id/comments/:comment_id - GET request to retrieve a single comment
  • /api/posts/:post_id/comments - POST request to create a new comment
  • /api/posts/:post_id/comments/:comment_id - PUT request to update a comment (user can update their own comments, admin role can update any comment)
  • /api/posts/:post_id/comments/:comment_id - DELETE request to delete a comment (user can delete their own comments, admin role can delete any comment)
  • /api/posts/:post_id/review - GET request to retrieve all reviews
  • /api/posts/:post_id/review/:review_id - GET request to retrieve a single review
  • /api/posts/:post_id/review - POST request to create a new review
  • /api/posts/:post_id/review/:review_id - PUT request to update a review (user can update their own reviews, admin role can update any review)

Authors

- Mahmoud M.Abdelwahab         - Mahmoud M.Mansour

Contributing

Contributions to this project are welcome. If you would like to contribute, please submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

social-media-nodejs-iti's People

Contributors

dependabot[bot] avatar mahmoudmansourr avatar mahmoudmohamed22 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.