Welcome to the VideoMe API - your go-to platform for managing multimedia content. This API is built with Node.js and Express.js, using TypeScript. MongoDB serves as the primary database, and Mongoose, along with mongoose-aggregate-paginate-v2
, is utilized for powerful MongoDB query capabilities. Passwords are securely encrypted using bcrypt, and file uploading is handled with Multer. Cloudinary is integrated for cloud storage, offering a scalable solution for media assets. JSON Web Tokens (JWT) are employed for authorization and authentication, while Joi is used for input validation.
Modal Link | Postman Link |
---|---|
Schema Design | Postman Collection |
- Node.js: Server-side JavaScript runtime.
- Express.js: Web application framework for Node.js.
- TypeScript: Superset of JavaScript with static typing.
- MongoDB: Primary NoSQL database for data storage.
- Mongoose: MongoDB ODM for simplified data manipulation.
- mongoose-aggregate-paginate-v2: Enhances Mongoose with advanced aggregation and pagination support.
- bcrypt: Library for securely hashing and encrypting passwords.
- Multer: Middleware for handling file uploads.
- Cloudinary: Cloud-based storage for media assets.
- JSON Web Tokens (JWT): Token-based authentication and authorization.
- Joi: Library for input validation.
- Clone the Repository:
git clone https://github.com/Sujeet76/youtube-ts.git cd videoMe_Api
- Install Dependencies
npm i
- Build the TypeScript Files
npm run build
- Run the Project
npm run dev
PORT =8080
BD_URL =
CORS_ORIGIN =
ACCESS_TOKEN_SECRET =
ACCESS_TOKEN_EXPIRATION_TIME = 1d
REFRESH_TOKEN_SECRET =
REFRESH_TOKEN_EXPIRATION_TIME =10d
CLOUDINARY_CLOUD_NAME=
CLOUDINARY_API_KEY=
CLOUDINARY_API_SECRET=
- Base URL:
http://localhost:3000/api/v1
- Authentication Middleware: The
isAuthorized
middleware is applied across various routes to verify JWT for secure authentication.
- Base URL:
/users
-
Register
- Path:
/register
- HTTP Method: POST
- Description: Create a new user account with username, full name, email, password, and optional avatar and cover image.
- Required Parameter
- username
- fullName
- password
- avatar(file)
- coverImage(file,optional)
- Path:
-
Login
- Path:
/login
- HTTP Method: POST
- Description: Log in with valid credentials to obtain an access token.
- Required Parameter
- username(optional,any one)
- email(optional,any one)
- password
- Path:
-
Get Access Token
- Path:
/get-token
- HTTP Method: GET
- Description: Obtain a new access token using the refresh token.
- Path:
-
Logout
- Path:
/logout
- HTTP Method: POST
- Description: Log out the user by invalidating the access token.
- Path:
-
Update Password
- Path:
/update-password
- HTTP Method: PATCH
- Description: Update the user's password.
- Required Parameter
- currentPassword
- newPassword
- Path:
-
Update Avatar
- Path:
/update-avatar
- HTTP Method: PATCH
- Description: Update the user's avatar.
- Required Parameter
- avatar(file)
- Path:
-
Update Cover Image
- Path:
/update-cover-img
- HTTP Method: PATCH
- Description: Update the user's cover image.
- Required Parameter
- coverImage
- Path:
-
Update User Details
- Path:
/update-user
- HTTP Method: PATCH
- Description: Update the user's profile details.
- Required Parameter
- fullName (optional)
- email (optional)
- Path:
-
Get User Channel Profile
- Path:
/c/:username
- HTTP Method: GET
- Description: Retrieve the profile information for a user's channel.
- Path:
-
Get Watch History
- Path:
/history
- HTTP Method: GET
- Description: Retrieve the watch history for the authenticated user.
- Path:
- Base URL:
/subscriptions
- Middleware:
isAuthorized
-
Toggle Subscription
- Path:
/c/:channelId
- HTTP Methods: POST
- Description: Toggle subscription status for a specific channel.
- Path:
-
Get User Channel Subscribers
- Path:
/c/:channelId
- HTTP Methods: GET
- Description: Retrieve subscriber lists
- Path:
-
Get Subscribed Channels for a User
- Path:
/u/:subscriberId
- HTTP Method: GET
- Description: Retrieve the list of channels to which a user has subscribed.
- Path:
- Base URL:
/videos
- Middleware:
isAuthorized
-
Publish a Video
- Path:
/
- HTTP Methods: POST
- Description: Publish a new video.
- Required Parameter
- title
- description
- videoFile (file)
- thumbnail (file)
- Path:
-
Get All Videos
- Path:
/
- HTTP Methods: GET
- Description: Retrieve a list of all videos
- Query Parameter
- userId
- query (optional)
- page (optional, default 1)
- limit (optional, default 10)
- sortType (optional, default asc)
- sortBy (optional, default createdAt)
- Path:
-
Get, Delete a Video by ID
- Path:
/videos/:videoId
- HTTP Methods: GET, DELETE
- Description: Retrieve and delete video details by ID.
- Path:
-
Update a Video by ID
- Path:
/videos/:videoId
- HTTP Methods: PATCH
- Description: Update video details by ID.
- Required Parameter
- title (optional)
- description (optional)
- thumbnail (optional,file)
- Path:
-
Toggle Publish Status of a Video
- Path:
/toggle/publish/:videoId
- HTTP Method: PATCH
- Description: Toggle the publish status of a video.
- Path:
- Base URL:
/playlists
- Middleware:
isAuthorized
-
Create a Playlist
- Path:
/
- HTTP Method: POST
- Description: Create a new playlist.
- Required Parameter
- name
- description
- Path:
-
Get, Delete a Playlist by ID
- Path:
/:playlistId
- HTTP Methods: GET, DELETE
- Description: Retrieve and delete playlist details by ID.
- Path:
-
Update a Playlist by ID
- Path:
/:playlistId
- HTTP Methods: PATCH
- Description: Update playlist details by ID.
- Required Parameter
- name
- description
- Path:
-
Add and Remove Videos to/from a Playlist
- Path:
/add/:playlistId
and/remove/:playlistId
- HTTP Method: PATCH
- Description: Add and remove videos to/from a playlist.
- Required Parameter
- videoIds (array of video ids)
- Path:
-
Get User's Playlists
- Path:
/user/playlist
- HTTP Method: GET
- Description: Retrieve playlists associated with the authenticated user.
- Path:
- Base URL:
/tweets
- Middleware:
isAuthorized
-
Create a Tweet
- Path:
/
- HTTP Method: POST
- Description: Create a new tweet.
- Required Parameter
- content
- Path:
-
Get User's Tweets
- Path:
/user/:userId
- HTTP Method: GET
- Description: Retrieve tweets associated with a specific user.
- Path:
-
Delete a Tweet by ID
- Path:
/:tweetId
- HTTP Methods: DELETE
- Description: Delete a tweet by its ID.
- Path:
-
Update a Tweet by ID
- Path:
/:tweetId
- HTTP Methods: PATCH
- Description: Update a tweet by its ID.
- Required Parameter
- content
- Path:
- Base URL:
/likes
- Middleware:
isAuthorized
-
Toggle Like on a Video
- Path:
/toggle/v/:videoId
- HTTP Method: POST
- Description: Toggle the like status on a video.
- Path:
-
Toggle Like on a Comment
- Path:
/toggle/c/:commentId
- HTTP Method: POST
- Description: Toggle the like status on a comment.
- Path:
-
Toggle Like on a Tweet
- Path:
/toggle/t/:tweetId
- HTTP Method: POST
- Description: Toggle the like status on a tweet.
- Path:
-
Get Liked Videos
- Path:
/videos
- HTTP Method: GET
- Description: Retrieve a list of videos liked by the authenticated user.
- Path:
- Base URL:
/dashboard
- Middleware:
isAuthorized
-
Get Channel Statistics
- Path:
/stats
- HTTP Method: GET
- Description: Retrieve statistics for the authenticated user's channel.
- Path:
-
Get Channel Videos
- Path:
/videos
- HTTP Method: GET
- Description: Retrieve a list of videos associated with the authenticated user's channel.
- Path:
- Base URL:
/comments
-
Get Video Comments
- Path:
/:videoId
- HTTP Method: GET
- Description: Retrieve comments associated with a specific video.
- Query Parameter
- page (optional, default 1)
- limit (optional, default 10)
- Path:
-
Delete Comment
- Path:
/c/:commentId
- HTTP Methods: DELETE
- Description: Delete comment by their ID.
- Path:
-
Update Comment
- Path:
/c/:commentId
- HTTP Methods: PATCH
- Description: Update comment by their ID.
- Path:
- Base URL:
/healthcheck
- Health Check
- Path:
/
- HTTP Method: GET
- Description: Perform a health check on the server.
- Path: