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
Install dependencies
Start the server
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 =
Body
Type
Description
fullName
string
Required
email
string
Required
username
string
Required
password
string
Required
Files
Type
Description
coverImage
Image
Required
avatar
Image
Required
Body
Type
Description
username or email
string
Required
password
string
Required
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
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
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})
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
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
Cookies
Type
Description
Jwt-Token
string
Required
Params
Type
Description
VideoId
Object Id
Required
Toggle Publish Video-Status
PATCH /videos/toggle/publish/:VideoId
Cookies
Type
Description
Jwt-Token
string
Required
Params
Type
Description
VideoId
Object Id
Required
Returns a 200 success message on call
Comment Routes
Get Video Comments
Params
Type
Description
VideoId
Object Id
Required
Add Comment
Params
Type
Description
VideoId
Object Id
Required
Body
Type
Description
content
string
Required
Cookies
Type
Description
Jwt-Token
string
Required
Update Comment
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 Comment
DELETE /comments/c/:commentId
Params
Type
Description
commentId
Object Id
Required
Cookies
Type
Description
Jwt-Token
string
Required
Tweet Routes
Create Tweet
Body
Type
Description
content
string
Required
Cookies
Type
Description
Jwt-Token
string
Required
Get User Tweets
Params
Type
Description
userId
Object Id
Required
Update Tweet
Params
Type
Description
TweetId
Object Id
Required
Body
Type
Description
content
string
Required
Cookies
Type
Description
Jwt-Token
string
Required
Delete Tweet
Params
Type
Description
tweetId
Object Id
Required
Cookies
Type
Description
Jwt-Token
string
Required
Params
Type
Description
videoId
Object Id
Required
Cookies
Type
Description
Jwt-Token
string
Required
Toggle Comment Like
Params
Type
Description
commentId
Object Id
Required
Cookies
Type
Description
Jwt-Token
string
Required
Toggle Tweet Like
Params
Type
Description
tweetId
Object Id
Required
Cookies
Type
Description
Jwt-Token
string
Required
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
Toggle Subscription Status
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
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
Remove Video From Playlist
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!