https://github.com/bharatlal124/postaway-ii-api-project
This is a project to create a backend REST-API for a social media platform using Node.js, Express.Js, and MongoDB. It enables users to post, comment, like, manage friends, and reset passwords securely with OTP
https://github.com/bharatlal124/postaway-ii-api-project
database expressjs javascript mongodb mvc-architecture nodejs
Last synced: 3 months ago
JSON representation
This is a project to create a backend REST-API for a social media platform using Node.js, Express.Js, and MongoDB. It enables users to post, comment, like, manage friends, and reset passwords securely with OTP
- Host: GitHub
- URL: https://github.com/bharatlal124/postaway-ii-api-project
- Owner: bharatlal124
- Created: 2024-02-20T06:59:18.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-22T06:21:48.000Z (over 2 years ago)
- Last Synced: 2025-03-30T23:27:59.450Z (over 1 year ago)
- Topics: database, expressjs, javascript, mongodb, mvc-architecture, nodejs
- Language: JavaScript
- Homepage:
- Size: 198 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Postaway-II Social Media API : Project
Postaway is a social media platform API built using Express.js, Node.js, MongoDB, designed to enable users to perform various social media activities such as user management, posts creation, commenting, liking, friend requests, and enhanced security features, OTP based password reset and more.
## Features
- **User Management**: Register and authenticate users.
- **Post Creation**: Users can create posts with text and media.
- **Commenting**: Users can comment on posts.
- **Liking**: Users can like posts.
- **File Upload**: Supports file upload for user avatars and post images.
- **Error Handling**: Graceful handling of errors with appropriate HTTP status codes and error messages.
- **Authentication**: Implements JSON Web Tokens (JWT) for user authentication.
- **Security**: Ensures security measures like data validation and input sanitization.
- **Scalable Architecture**: Uses Express.js for a scalable and modular architecture.
## Installation
1. Clone the repository:
```bash
git clone https://github.com/bharatlal124/Postaway-II-API-project.git
cd postaway-api
```
2. Install dependencies:
**npm install**
3. Set up environment variables:
- Create a `.env` file in the root directory with the following variables:
- **DB_URL**=Add database link here
- **JWT_SECRET_KEY**=your = _jwt_secret_key_here
4. Start the server:
**node index.js**
## API Endpoints
### User Routes
- **POST /api/user/register**: Register a new user account.
- **POST /api/user/login**: Log in as a user.
- **POST /api/user/upload-avatar**: Upload user avatar.
### Post Routes
- **POST /api/posts**: Create a new post.
- **POST /api/posts/upload-image**: Upload post image.
- **GET /api/posts**: Retrieve all posts.
- **GET /api/posts/:id**: Retrieve a specific post by ID.
- **PUT /api/posts/:id**: Update a specific post by ID.
- **DELETE /api/posts/:id**: Delete a specific post by ID.
### Comment Routes
- **POST /api/comments**: Create a new comment.
- **GET /api/comments**: Retrieve all comments for a specific post.
- **PUT /api/comments/:id**: Update a specific comment by ID.
- **DELETE /api/comments/:id**: Delete a specific comment by ID.
### Like Routes
- **POST /api/likes**: Add a like to a post.
- **DELETE /api/likes/:id**: Remove a like from a post.
- **GET /api/likes/:postId**: Retrieve all likes for a specific post.
## Technologies Used
- Express.js
- Mongoose (for MongoDB object modeling)
- JWT (JSON Web Tokens) for authentication
- Multer (for handling file uploads)
- Bcrypt (for password hashing)
- Body-parser (for parsing request bodies)
- Axios (for HTTP requests)
- ESLint (for code linting)
- Winston (for logging)
- Helmet (for securing HTTP headers)
- Dotenv (for environment variables)
- Nodemailer (For sending emails)
- Node.js Crypto Module (For generating and verifying OTPs securely)