I have completed all assignments of chai aur code yt backend series. It is code for backend of youtube clone with all the basic features of user authentication, video handeling, like, comment, subcription, tweet etc...
Javascript, ExpressJS, NodeJS, MongoDb Aggregation Pipelines, Mongoose, Multer, Cloudinary...
As it was my first time to write the code of backend of any application, I learnt how the real world backend actually works. In this project, I created backend for youtube which has all functionalities of user authentications like refresh token, access token, password hashing. Created all user routes like change password, change avatar, change cover image, sign up, log in, etc.. I learnt Jwt token, sessions and multer middleware for file handling in nodeJS environment. I integerated mongodb and cloudinary databases to store data and files. I created video, comment, like, subscription, tweet, playlist, healthcheck and dashboard controller all by myself. It has all crud functions with user checking and updations through mongoDb aggregation pipelines. I have also created search feature for videos through mongoDb aggregation pipelines.
Clone the project
https://github.com/malhotraarshdeepsingh/DevTube_backend
Go to the project directory
cd DevTube_backend
Install dependencies
npm install
Start the server
npm run dev
To run this project, you will need to add the following environment variables to your .env file
PORT=8000
MONGODB_URL
CORS_ORIGIN = *
ACCESS_TOKEN_SECRET
ACCESS_TOKEN_EXPIRY = 1d
REFRESH_TOKEN_SECRET =
REFRESH_TOKEN_EXPIRY = 10d
CLOUDINARY_NAME =
CLOUDINARY_API_KEY =
CLOUDINARY_API_SECRET =
POST /users/register
Body | Type | Description |
---|---|---|
fullName |
string |
Required |
email |
string |
Required |
username |
string |
Required |
password |
string |
Required |
Files | Type | Description |
---|---|---|
coverImage |
Image |
Required |
avatar |
Image |
Required |
POST /users/login
Body | Type | Description |
---|---|---|
username or email |
string |
Required |
password |
string |
Required |
POST /users/logout
Cookies | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
POST /users/refresh-token
Cookies / Body | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
POST /users/change-password
Cookies / Body | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
Body | Type | Description |
---|---|---|
oldPassword |
string |
Required |
newPassword |
string |
Required |
GET /users/current-user
Cookies / Body | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
PATCH /users/update-account
Cookies / Body | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
Body | Type | Description |
---|---|---|
email |
string |
Required |
fullName |
string |
Required |
PATCH /users/update-cover-image
Cookies / Body | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
File | Type | Description |
---|---|---|
coverImage |
Image |
Required |
PATCH /users/update-avatar
Cookies / Body | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
File | Type | Description |
---|---|---|
avatar |
Image |
Required |
GET /users/channels/${username}
Params | Type | Description |
---|---|---|
username |
Object Id |
Required |
GET /videos
Body | Type | Description |
---|---|---|
query |
string |
Optional |
userId |
string |
Optional |
Returns with all the videos which matches the query and userId if provided else will return all the videos stored in the db ({with isPublised:true})
POST /videos
Body | Type | Description |
---|---|---|
title |
string |
Required |
description |
string |
Required |
isPublished |
boolean |
Required |
Files | Type | Description |
---|---|---|
thumbnail |
Image |
Required |
coverImage |
Image |
Required |
Cookies | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
GET /videos/:videoId
Params | Type | Description |
---|---|---|
VideoId |
Object Id |
Required |
PATCH /videos/:videoId
Body | Type | Description |
---|---|---|
title |
string |
Required |
description |
string |
Required |
isPublished |
boolean |
Required |
Files | Type | Description |
---|---|---|
thumbnail |
Image |
Required |
coverImage |
Image |
Required |
Cookies | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
Params | Type | Description |
---|---|---|
VideoId |
Object Id |
Required |
Delete /videos/:videoId
Cookies | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
Params | Type | Description |
---|---|---|
VideoId |
Object Id |
Required |
PATCH /videos/toggle/publish/:VideoId
Cookies | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
Params | Type | Description |
---|---|---|
VideoId |
Object Id |
Required |
GET /healthcheck
Returns a 200 success message on call
GET /comments/:videoId
Params | Type | Description |
---|---|---|
VideoId |
Object Id |
Required |
POST /comments/:videoId
Params | Type | Description |
---|---|---|
VideoId |
Object Id |
Required |
Body | Type | Description |
---|---|---|
content |
string |
Required |
Cookies | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
PATCH /comments/c/:commentId
Params | Type | Description |
---|---|---|
commentId |
Object Id |
Required |
Body | Type | Description |
---|---|---|
content |
string |
Required |
Cookies | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
DELETE /comments/c/:commentId
Params | Type | Description |
---|---|---|
commentId |
Object Id |
Required |
Cookies | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
POST /tweets
Body | Type | Description |
---|---|---|
content |
string |
Required |
Cookies | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
GET /tweets/user/:userId
Params | Type | Description |
---|---|---|
userId |
Object Id |
Required |
PATCH /tweets/tweetId
Params | Type | Description |
---|---|---|
TweetId |
Object Id |
Required |
Body | Type | Description |
---|---|---|
content |
string |
Required |
Cookies | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
DELETE /tweet/:tweetId
Params | Type | Description |
---|---|---|
tweetId |
Object Id |
Required |
Cookies | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
POST /likes/v/:videoId
Params | Type | Description |
---|---|---|
videoId |
Object Id |
Required |
Cookies | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
POST /likes/c/:commentId
Params | Type | Description |
---|---|---|
commentId |
Object Id |
Required |
Cookies | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
POST /likes/t/:tweetId
Params | Type | Description |
---|---|---|
tweetId |
Object Id |
Required |
Cookies | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
POST /likes/videos
Cookies | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
GET /dashboard/stats/:channel
Params | Type | Description |
---|---|---|
channel |
Object Id |
Required |
GET /dashboard/videos/:channel
Params | Type | Description |
---|---|---|
channel |
Object Id |
Required |
GET /subscription/c/:channelId
Params | Type | Description |
---|---|---|
channelId |
Object Id |
Required |
POST /subscription/c/:channelId
Params | Type | Description |
---|---|---|
channelId |
Object Id |
Required |
Cookies | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
GET /subscription/u/:subscriberId
Params | Type | Description |
---|---|---|
subscriberId |
Object Id |
Required |
POST /playlist/
Body | Type | Description |
---|---|---|
name |
string |
Required |
description |
string |
Required |
Cookies | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
GET /playlist/:playlistId
Params | Type | Description |
---|---|---|
playlistId |
Object Id |
Required |
Cookies | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
PATCH /playlist/:playlistId
Params | Type | Description |
---|---|---|
playlistId |
Object Id |
Required |
Body | Type | Description |
---|---|---|
name |
string |
Required |
description |
string |
Required |
Cookies | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
Delete /playlist/:playlistId
Params | Type | Description |
---|---|---|
playlistId |
Object Id |
Required |
Cookies | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
PATCH /playlist/add/:videoId/:playlistId
Params | Type | Description |
---|---|---|
playlistId |
Object Id |
Required |
videoId |
Object Id |
Required |
Cookies | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
PATCH /playlist/remove/:videoId/:playlistId
Params | Type | Description |
---|---|---|
playlistId |
Object Id |
Required |
videoId |
Object Id |
Required |
Cookies | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
GET /playlist/user/:userId
Params | Type | Description |
---|---|---|
userId |
Object Id |
Required |
Cookies | Type | Description |
---|---|---|
Jwt-Token |
string |
Required |
Contributions are always welcome!