Deployed backend for a Social Media application built with Node.js, Express, and MongoDB (Mongoose). It includes authentication (JWT), users/channels, videos, tweets, comments, likes, subscriptions, playlists, watch history, and a simple dashboard API.
- Backend URL: https://socialmediaapp-backend-1.onrender.com
Note: This URL is intended only for connecting the backend with the frontend. It is used exclusively for API calls and does not serve any standalone purpose.
- Runtime: Node.js
- Framework: Express
- Database: MongoDB + Mongoose
- Auth: JWT (supports cookie
accessTokenorAuthorization: Bearer <token>) - Uploads: Multer (memory storage) — used for avatar/cover image and video/thumbnail uploads
- Other: CORS, Cookie Parser, Dotenv
- Register user (supports avatar and cover image upload)
- Login / Logout
- Refresh access token
- Change password
- Get current logged-in user
- Update account details
- Update avatar / cover image
- Get user channel profile
- Watch history management:
- Get watch history
- Add video to watch history
- Remove video from watch history
- Clear watch history
- Publish video (upload videoFile + thumbnail)
- Get all videos (with optional filters handled by controller)
- Get video by ID
- Update view count
- Update video details / thumbnail
- Delete video
- Toggle publish/unpublish status
- Create tweet
- Get tweets by user
- Update tweet
- Delete tweet
- Get comments for a video
- Add comment to a video
- Update comment
- Delete comment
- Like/unlike a video
- Like/unlike a tweet
- Like/unlike a comment
- Fetch liked videos
- Check if current user liked a specific video/tweet/comment
- Get likes count for a video/tweet/comment
- Subscribe/unsubscribe to a channel
- Get subscribed channels
- Get channel subscribers
- Check if subscribed to a channel
- Create playlist
- Get playlist by ID
- Update playlist
- Delete playlist
- Add video to playlist
- Remove video from playlist
- Get playlists for a user
- Channel stats
- Channel videos listing (for dashboard)
- Healthcheck endpoint to verify API is running
All routes are mounted under:
/api/v1/*
GET /api/v1/healthcheck
POST /register(multipart:avatar,coverimage)POST /loginPOST /logout(auth)POST /refresh-tokenPOST /change-password(auth)GET /current-user(auth)PATCH /update-account(auth)PATCH /avatar(auth, multipart:avatar)PATCH /coverimage(auth, multipart:coverimage)GET /c/:username(auth)GET /history(auth)POST /addVideoToWatchHistory(auth)DELETE /clear-history(auth)DELETE /remove-from-history(auth)
POST /(multipart:videoFile,thumbnail)GET /GET /v/:videoIdPATCH /v/:videoId(update views)PATCH /uv/:videoId(optional multipart:thumbnail)DELETE /uv/:videoIdPATCH /uv/:videoId/toggle-publish
POST /GET /user/:userIdPATCH /:tweetIdDELETE /:tweetId
GET /:videoIdPOST /:videoIdPATCH /c/:commentIdDELETE /c/:commentId
POST /toggle/v/:videoIdPOST /toggle/c/:commentIdPOST /toggle/t/:tweetIdGET /videosGET /check/v/:videoIdGET /check/c/:commentIdGET /check/t/:tweetIdGET /count/v/:videoIdGET /count/c/:commentIdGET /count/t/:tweetId
GET /c/:channelIdPOST /c/:channelId(toggle subscribe)GET /u/:subscriptionIdGET /check/:channelId
POST /GET /:playlistIdPATCH /:playlistIdDELETE /:playlistIdPATCH /add/:videoId/:playlistIdPATCH /remove/:videoId/:playlistIdGET /user/:userId
GET /statsGET /videos
git clone https://github.com/AnasMultani17/Social-Media-App-Backend-Deployment.git
cd Social-Media-App-Backend-Deployment
npm installCreate an environment file (commonly .env). This backend expects at least:
PORT=7000
MONGO_URI=
CORS_ORIGIN=http://localhost:3000
ACCESS_TOKEN_SECRET=
ACCESS_TOKEN_EXPIRY=
REFRESH_TOKEN_SECRET=
REFRESH_TOKEN_EXPIRY=
CLOUDINARY_CLOUD_NAME=
CLOUDINARY_API_KEY=
CLOUDINARY_API_SECRET=
# development
npm run dev
# production
npm startServer starts on:
http://localhost:7000(by default)
Protected routes use verifyJWT middleware and accept tokens from:
- Cookie:
accessToken - Header:
Authorization: Bearer <token>
This backend uses multer memory storage, meaning files are kept in RAM during the request. Common multipart fields:
- User registration:
avatar,coverimage - Video publish:
videoFile,thumbnail - Update avatar:
avatar - Update cover image:
coverimage
CORS is enabled with credentials support and a configurable origin via:
CORS_ORIGIN(defaults tohttp://localhost:3000)
The app also explicitly sets Access-Control-Allow-Origin to:
https://new-social-media-app-frontned.vercel.app
- This repo contains deployment configuration (e.g.
vercel.json) and is deployed at:
- Fork the repo
- Create your feature branch:
git checkout -b feature/my-feature - Commit changes:
git commit -m "Add my feature" - Push to branch:
git push origin feature/my-feature - Open a Pull Request