A Node.js backend project featuring user authentication, video uploads, playlists, comments, likes, subscriptions, and more. Built with Express, MongoDB, and Cloudinary.
- User registration and login (JWT authentication)
- Password hashing and secure token storage
- Video upload and management (Cloudinary integration)
- User profile with avatar and cover image uploads
- Playlists, comments, likes, and subscriptions
- Watch history tracking
- RESTful API structure
- Environment variable support via
.env - Modular codebase with MVC structure
- Node.js
- Express.js
- MongoDB & Mongoose
- Cloudinary (media storage)
- Multer (file uploads)
- JWT (authentication)
- bcrypt (password hashing)
- dotenv (environment variables)
- Prettier (code formatting)
.env
.env.sample
.gitignore
.prettierignore
.prettierrc
package.json
Readme.md
public/
temp/
.gitkeep
src/
app.js
constants.js
index.js
controllers/
user.controller.js
db/
index.js
middlewares/
auth.middleware.js
multer.middleware.js
models/
comment.model.js
like.model.js
playlist.model.js
subscription.model.js
tweet.model.js
user.model.js
video.model.js
routes/
user.routes.js
utils/
ApiError.js
ApiResponse.js
asyncHandler.js
cloudinary.js
- Node.js (v16+ recommended)
- MongoDB database
- Cloudinary account
-
Clone the repository:
git clone https://github.com/Abdus-Samee-007/Backend-Project
-
Install dependencies:
npm install
-
Copy
.env.sampleto.envand fill in your credentials:cp .env.sample .env
-
Start the development server:
npm run dev
All endpoints are prefixed with /api/v1/users. Example endpoints:
POST /register— Register a new userPOST /login— Login userPOST /logout— Logout userPOST /refresh-token— Refresh JWT tokensPOST /change-password— Change user passwordGET /current-user— Get current user profilePATCH /update-account— Update user detailsPATCH /avatar— Update user avatarPATCH /cover-image— Update user cover imageGET /c/:username— Get user channel profileGET /history— Get watch history
See .env.sample for all required environment variables.
Example:
PORT=8000
MONGODB_URI= <insert your MONGODB_URI here>
CORS_ORIGIN=*
ACCESS_TOKEN_SECRET= <insert your ACCESS_TOKEN_SECRET here>
ACCESS_TOKEN_EXPIRY= <insert your ACCESS_TOKEN_EXPIRY duration here>
REFRESH_TOKEN_SECRET= <insert your REFRESH_TOKEN_SECRET here>
REFRESH_TOKEN_EXPIRY= <insert your REFRESH_TOKEN_EXPIRY duration here>
CLOUDINARY_CLOUD_NAME= <insert your CLOUDINARY_CLOUD_NAME here>
CLOUDINARY_API_KEY= <insert your CLOUDINARY_API_KEY here>
CLOUDINARY_API_SECRET= <insert your CLOUDINARY_API_SECRET here>
npm run dev— Start the development server with nodemon
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.