This repository contains the backend code for a social media platform built with Express.js. The backend provides APIs for user management, posts, friendships, comments, infinite comment replies with media, logical reactions (like, love, care, etc.), notifications, and more
POST /users/register
- Register a new userPOST /users/verify-otp
- Verify OTP for registrationPOST /users/login
- User loginPATCH /users/update-profile
- Update user profile (requires authentication)POST /users/verify-password
- Verify user password (requires authentication)POST /users/request-email-update-otp
- Request OTP for email update (requires authentication)PATCH /users/confirm-email-update
- Confirm email update (requires authentication)POST /users/request-forgot-password-otp
- Request OTP for forgot password (requires authentication)POST /users/match-password-otp
- Match OTP for password reset (requires authentication)PATCH /users/reset-forgot-password
- Reset password using OTP (requires authentication)
POST /friends/send-request
- Send friend request (requires authentication)POST /friends/reject-request
- Reject friend request (requires authentication)POST /friends/accept-request
- Accept friend request (requires authentication)POST /friends/un-friend
- Unfriend a user (requires authentication)GET /friends/friends-list
- Get friends list (requires authentication)GET /friends/sent-requests
- Get sent friend requests (requires authentication)GET /friends/friend-request
- Get friend requests (requires authentication)GET /friends/friend
- Get a specific friend's details (requires authentication)
GET /post
- Get all postsGET /post/:postId
- Get a single post by IDPOST /post
- Create a new post (requires authentication)PATCH /post/:postId
- Update a post by ID (requires authentication)DELETE /post/:postId
- Delete a post by ID (requires authentication)PATCH /post/reactions/:postId
- React to a post (requires authentication)
POST /comment/:postId
- Create a new comment on a post (requires authentication)PATCH /comment/:commentId
- Update a comment by ID (requires authentication)DELETE /comment/:commentId
- Delete a comment by ID (requires authentication)PATCH /comment/reactions/:commentId
- React to a comment (requires authentication)
GET /notification
- Get all notifications (requires authentication)DELETE /notification/delete/:id
- Delete a notification by ID (requires authentication)
- Clone the repository:
git clo git clone https://github.com/Tariq-Monowar/social-media-typescript-with-express.js-api.git
- Install dependencies:
cd social-media-backend npm install
- Set up environment variables:
PORT=1010 DBURL= Mongodb url WEBTOKEN_SECRET_KEY=**************** NODE_MAILER_USER=*********************** NODE_MAILER_PASSWORD=********************* SESSION_SECRET=**************** CLOUD_NAME=*************** CLOUD_API_KEY=******************* CLOUD_API_SECRET=*************************
├── config/
│ ├── cloudinary.config.ts
│ ├── db.ts
│ └── config.ts
├── constants/
│ ├── email_message.ts
│ └── interface.ts
├── controllers/
│ ├── comment.controllers.ts
│ ├── friends.controllers.ts
│ ├── notification.controllers.ts
│ ├── posts.controllers.ts
│ └── users.controllers.ts
├── middleware/
│ └── verifyUser.ts
├── models/
│ ├── comment.models.ts
│ ├── friend.models.ts
│ ├── notification.models.ts
│ ├── post.models.ts
│ └── user.models.ts
├── routes/
│ ├── comment.routes.ts
│ ├── friend.routes.ts
│ ├── notification.routes.ts
│ ├── post.routes.ts
│ └── user.routes.ts
├── util/
│ ├── baseUrl.ts
│ └── fireUploade.ts
├── .env
├── .gitignore
├── README.md
├── app.ts
├── index.ts
├── package-lock.json
├── package.json
├── tsconfig.json