Welcome to the uViewTube Backend repository! This project serves as the backend for the uViewTube application, providing APIs for user management, video handling, comments, likes, playlists, and more.
- uViewTube Backend
- User authentication and authorization
- Video upload, update, and deletion
- Commenting on videos
- Liking videos and comments
- Creating and managing playlists
- Subscriptions to user channels
- Fetching user watch history
- Node.js
- Express.js
- MongoDB with Mongoose
- JWT for authentication
- Cloudinary for media storage
- Winston for logging
- Prettier for code formatting
- Node.js installed
- MongoDB instance running
- Cloudinary account
-
Fork the repository. If you are not familiar with how to do this, follow the instructions here.
-
Clone the repository:
git clone https://github.com/<username>/uViewTube-Backend.git cd uViewTube-Backend
-
Install dependencies:
npm install
-
Create a
.env
file based on the.env.example
provided and fill in the necessary environment variables. -
Start the server:
npm run dev
The following environment variables need to be set in your .env
file:
# Server Configuration
PORT= # Port number on which the server will run
CORS_ORIGIN= # Allowed origins for CORS
# Database Configuration
MONGODB_URI= # MongoDB connection string
# JWT Configuration
ACCESS_TOKEN_SECRET= # Secret key for access token
ACCESS_TOKEN_EXPIRY= # Expiry time for access token
REFRESH_TOKEN_SECRET= # Secret key for refresh token
REFRESH_TOKEN_EXPIRY= # Expiry time for refresh token
# Cloudinary Configuration
CLOUDINARY_CLOUD_NAME= # Cloudinary cloud name
CLOUDINARY_API_KEY= # Cloudinary API key
CLOUDINARY_API_SECRET= # Cloudinary API secret
# Environment
NODE_ENV= # Environment (development, production, etc.)
POST /api/v1/users/register
- Register a new userPOST /api/v1/users/#
- Login a userPOST /api/v1/users/refresh-token
- Refresh access tokenGET /api/v1/users/logout
- Logout a userPATCH /api/v1/users/update-details
- Update user detailsPATCH /api/v1/users/update-avatar
- Update user avatarPATCH /api/v1/users/update-coverimage
- Update user cover imageGET /api/v1/users/watch-history
- Get user watch history
POST /api/v1/videos/upload
- Upload a new videoPATCH /api/v1/videos/update/:videoId
- Update video detailsDELETE /api/v1/videos/delete/:videoId
- Delete a video
POST /api/v1/comments/add/:videoId
- Add a comment to a videoGET /api/v1/comments/:videoId
- Get comments for a videoPATCH /api/v1/comments/update/:commentId
- Update a commentDELETE /api/v1/comments/delete/:commentId
- Delete a comment
PATCH /api/v1/likes/toggle/video/:videoId
- Like or unlike a videoPATCH /api/v1/likes/toggle/comment/:commentId
- Like or unlike a comment
POST /api/v1/playlists/create
- Create a new playlistGET /api/v1/playlists/user/:userId
- Get playlists for a userGET /api/v1/playlists/id/:playlistId
- Get a playlist by IDPATCH /api/v1/playlists/update/:playlistId
- Update a playlistDELETE /api/v1/playlists/delete/:playlistId
- Delete a playlist
PATCH /api/v1/subscriptions/toggle/:userId
- Subscribe or unsubscribe to a user
POST /api/v1/tweets/create
- Create a new tweetGET /api/v1/tweets
- Get user tweetsPATCH /api/v1/tweets/update/:tweetId
- Update a tweetDELETE /api/v1/tweets/delete/:tweetId
- Delete a tweet
GET /api/v1/dashboard/videos
- Get channel videosGET /api/v1/dashboard/stats
- Get channel stats
GET /api/v1/healthcheck
- Health check
username
email
fullname
avatar
avatarPublicID
coverImage
coverImagePublicID
watchHistory
password
refreshToken
title
description
url
thumbnail
owner
views
likes
comments
video
content
owner
name
description
videos
owner
Errors are handled using custom APIError
and APIResponse
classes. These ensure consistent error responses across the API.
Logging is handled using Winston. Logs are output to the console and saved to app.log
.
Contributions are welcome! Please open an issue or submit a pull request.