MyTube - Backend
- [Models Link] (https://app.eraser.io/workspace/YtPqZ1VogxGy1jzIDkzj).
Here is the complete README.md
file for your project:
# MyTube_backend API
This project provides a set of APIs for managing videos, playlists, likes, subscriptions, and user-related actions in the MyTube_Backend application.
## Table of Contents
- [Installation](#installation)
- [Environment Variables](#environment-variables)
- [API Endpoints](#api-endpoints)
- [Auth](#auth)
- [Videos](#videos)
- [Playlists](#playlists)
- [Likes](#likes)
- [Subscriptions](#subscriptions)
- [Dashboard](#dashboard)
- [Usage](#usage)
- [Auth](#auth-usage)
- [Videos](#videos-usage)
- [Playlists](#playlists-usage)
- [Likes](#likes-usage)
- [Subscriptions](#subscriptions-usage)
- [Dashboard](#dashboard-usage)
## Installation
1. Clone the repository:
```bash
git clone https://github.com/hetpatel4381/mytube_backend
cd mytube_backend
```
-
Install dependencies:
npm install
-
Set up your environment variables. Create a
.env
file in the root directory and add the following variables:PORT=8000 MONGO_URI=`mongo_url` CORS_ORIGIN=* ACCESS_TOKEN_SECRET=`SECRET_KEY` ACCESS_TOKEN_EXPIRY=1d REFRESH_TOKEN_SECRET=`REFRESH_TOKEN` REFRESH_TOKEN_EXPIRY=10d CLOUDINARY_CLOUD_NAME=`CLOUD_NAME` CLOUDINARY_API_KEY=`API_KEY` CLOUDINARY_API_SECRET=`API_SECRET`
-
Start the server:
npm start npm run dev
Make sure to set up the following environment variables in your .env
file:
PORT
: Port on which the server will run (default: 8000)MONGODB_URI
: URI for connecting to MongoDBJWT_SECRET
: Secret key for JWT token generation and verification
POST /api/auth/register
: Register a new userPOST /api/auth/login
: Login a user
POST /api/videos
: Upload a new videoGET /api/videos/:videoId
: Get video details by IDPATCH /api/videos/:videoId
: Update video details by IDDELETE /api/videos/:videoId
: Delete video by ID
POST /api/playlists
: Create a new playlistGET /api/playlists/:playlistId
: Get playlist details by IDPATCH /api/playlists/:playlistId
: Update playlist details by IDDELETE /api/playlists/:playlistId
: Delete playlist by IDPATCH /api/playlists/add/:videoId/:playlistId
: Add a video to a playlistPATCH /api/playlists/remove/:videoId/:playlistId
: Remove a video from a playlist
POST /api/likes/toggle/v/:videoId
: Toggle like on a videoPOST /api/likes/toggle/c/:commentId
: Toggle like on a commentPOST /api/likes/toggle/t/:tweetId
: Toggle like on a tweetGET /api/likes/videos
: Get all liked videos by the user
POST /api/subscriptions/c/:channelId
: Toggle subscription to a channelGET /api/subscriptions/u/:subscriberId
: Get channels subscribed by the userGET /api/subscriptions/c/:channelId
: Get subscribers of a channel
GET /api/dashboard/stats
: Get channel statisticsGET /api/dashboard/videos
: Get all videos uploaded by the channel
POST /api/auth/register
{
"username": "exampleuser",
"email": "[email protected]",
"password": "password123"
}
POST /api/auth/login
{
"email": "[email protected]",
"password": "password123"
}
POST /api/videos
{
"title": "Video Title",
"description": "Video Description",
"url": "http://example.com/video.mp4"
}
GET /api/videos/:videoId
PATCH /api/videos/:videoId
{
"title": "Updated Title",
"description": "Updated Description"
}
DELETE /api/videos/:videoId
POST /api/playlists
{
"name": "Playlist Name",
"description": "Playlist Description"
}
GET /api/playlists/:playlistId
PATCH /api/playlists/:playlistId
{
"name": "Updated Playlist Name",
"description": "Updated Playlist Description"
}
DELETE /api/playlists/:playlistId
PATCH /api/playlists/add/:videoId/:playlistId
PATCH /api/playlists/remove/:videoId/:playlistId
POST /api/likes/toggle/v/:videoId
POST /api/likes/toggle/c/:commentId
POST /api/likes/toggle/t/:tweetId
GET /api/likes/videos
POST /api/subscriptions/c/:channelId
GET /api/subscriptions/u/:subscriberId
GET /api/subscriptions/c/:channelId
GET /api/dashboard/stats
GET /api/dashboard/videos