Skip to content

Built user controller with the help of tutorials from Chai aur Code, rest all controllers were in assignment which are completed by me

Notifications You must be signed in to change notification settings

malhotraarshdeepsingh/DevTube_backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DevTube Backend

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...

đź›  Skills

Javascript, ExpressJS, NodeJS, MongoDb Aggregation Pipelines, Mongoose, Multer, Cloudinary...

Acknowledgements

Lessons Learned

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.

Run Locally

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

Environment Variables

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 =

API Reference

User Routes

Registration

  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

Login

  POST /users/login
Body Type Description
username or email string Required
password string Required

Logout

  POST /users/logout
Cookies Type Description
Jwt-Token string Required

Refresh Token

  POST /users/refresh-token
Cookies / Body Type Description
Jwt-Token string Required

Change Password

  POST /users/change-password
Cookies / Body Type Description
Jwt-Token string Required
Body Type Description
oldPassword string Required
newPassword string Required

Current User

  GET /users/current-user
Cookies / Body Type Description
Jwt-Token string Required

Update Profile

  PATCH /users/update-account
Cookies / Body Type Description
Jwt-Token string Required
Body Type Description
email string Required
fullName string Required

Update Cover Image

  PATCH /users/update-cover-image
Cookies / Body Type Description
Jwt-Token string Required
File Type Description
coverImage Image Required

Update Avatar

  PATCH /users/update-avatar
Cookies / Body Type Description
Jwt-Token string Required
File Type Description
avatar Image Required

Get Channel Profile

  GET /users/channels/${username}
Params Type Description
username Object Id Required

Video Routes

Get All Videos

  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})

Publish Video

  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 Video by ID

  GET /videos/:videoId
Params Type Description
VideoId Object Id Required

Update Video

  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 Video

  Delete /videos/:videoId
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

HealthCheck

  GET /healthcheck

Returns a 200 success message on call

Comment Routes

Get Video Comments

  GET /comments/:videoId
Params Type Description
VideoId Object Id Required

Add Comment

  POST /comments/:videoId
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

  POST /tweets
Body Type Description
content string Required
Cookies Type Description
Jwt-Token string Required

Get User Tweets

  GET /tweets/user/:userId
Params Type Description
userId Object Id Required

Update Tweet

  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

  DELETE /tweet/:tweetId
Params Type Description
tweetId Object Id Required
Cookies Type Description
Jwt-Token string Required

Like Routes

Toggle Video Like

  POST /likes/v/:videoId
Params Type Description
videoId Object Id Required
Cookies Type Description
Jwt-Token string Required

Toggle Comment Like

  POST /likes/c/:commentId
Params Type Description
commentId Object Id Required
Cookies Type Description
Jwt-Token string Required

Toggle Tweet Like

  POST /likes/t/:tweetId
Params Type Description
tweetId Object Id Required
Cookies Type Description
Jwt-Token string Required

Get Liked Videos

  POST /likes/videos
Cookies Type Description
Jwt-Token string Required

Dashboard Routes

Get Channel Stats

  GET /dashboard/stats/:channel
Params Type Description
channel Object Id Required

Get Channel Videos

  GET /dashboard/videos/:channel
Params Type Description
channel Object Id Required

Subscription Routes

Get Channel Subscribers

  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 Subscribed Channels

  GET /subscription/u/:subscriberId
Params Type Description
subscriberId Object Id Required

Playlist Routes

Create A Playlist

  POST /playlist/
Body Type Description
name string Required
description string Required
Cookies Type Description
Jwt-Token string Required

Get A Playlist

  GET /playlist/:playlistId
Params Type Description
playlistId Object Id Required
Cookies Type Description
Jwt-Token string Required

Update A Playlist

  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 A Playlist

  Delete /playlist/:playlistId
Params Type Description
playlistId Object Id Required
Cookies Type Description
Jwt-Token string Required

Add Video To Playlist

  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 User Playlists

  GET /playlist/user/:userId
Params Type Description
userId Object Id Required
Cookies Type Description
Jwt-Token string Required

Contributing

Contributions are always welcome!

About

Built user controller with the help of tutorials from Chai aur Code, rest all controllers were in assignment which are completed by me

Topics

Resources

Stars

Watchers

Forks