Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mahmoud-elghonemy/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.
https://github.com/mahmoud-elghonemy/social-media-nodejs-iti
api backend backend-server cloudinary express js json middleware models mongodb mongoose multer nodejs routes
Last synced: about 1 month ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/mahmoud-elghonemy/social-media-nodejs-iti
- Owner: mahmoud-elghonemy
- License: mit
- Created: 2023-03-21T09:28:13.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-16T08:37:35.000Z (over 1 year ago)
- Last Synced: 2024-11-06T20:11:47.537Z (3 months ago)
- Topics: api, backend, backend-server, cloudinary, express, js, json, middleware, models, mongodb, mongoose, multer, nodejs, routes
- Language: JavaScript
- Homepage:
- Size: 176 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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.git2-Install dependencies:
```
npm install
```3-Create .env file and add required environment variables.
```
PORT=
DATABASE_URL=
SALT=
JWT_SECRET=
CLOUDINARY_CLOUD_NAME=
CLOUDINARY_API_KEY=
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
## ContributingContributions 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.