Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sayanbanerjee-007/my_tube_backend
Working on building REST API for MyTube a clone of YouTube
https://github.com/sayanbanerjee-007/my_tube_backend
bcrypt cloudinary cookie-parser cors expresssjs jsonwebtoken mongoose multer pagination
Last synced: about 1 month ago
JSON representation
Working on building REST API for MyTube a clone of YouTube
- Host: GitHub
- URL: https://github.com/sayanbanerjee-007/my_tube_backend
- Owner: SayanBanerjee-007
- Created: 2024-04-08T09:24:46.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-07-27T11:03:50.000Z (5 months ago)
- Last Synced: 2024-07-27T12:23:26.860Z (5 months ago)
- Topics: bcrypt, cloudinary, cookie-parser, cors, expresssjs, jsonwebtoken, mongoose, multer, pagination
- Language: JavaScript
- Homepage:
- Size: 72.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# My Tube Backend
![License](https://img.shields.io/badge/license-MIT-blue.svg)
![Node.js](https://img.shields.io/badge/node-%3E%3D%2014.x-brightgreen.svg)
![Express.js](https://img.shields.io/badge/express-%5E4.18.1-orange.svg)
![MongoDB](https://img.shields.io/badge/mongoDB-%5E4.0.0-yellowgreen.svg)## Table of Contents
- [Project Overview](#project-overview)
- [Features](#features)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Running the Application](#running-the-application)
- [API Documentation](#api-documentation)## Project Overview
My Tube Backend is a RESTful API developed with Node.js and Express.js to support a video-sharing platform similar to YouTube. It manages videos, user accounts, and comments. The application connects to a MongoDB database for data persistence.
## Features
- User authentication and authorization
- CRUD operations for videos
- CRUD operations for comments
- User profile management
- Token-based authentication with JWT
- Middleware for request validation and error handling
- Structured logging for server activities
- Rate limiting to prevent abuse## Prerequisites
Before running this application, ensure you have the following installed on your machine:
- **Node.js** (version 14.x or higher)
- **npm** (Node Package Manager, which comes with Node.js)
- **MongoDB** (local instance or cloud service like MongoDB Atlas)## Installation
Follow these steps to set up and run the application locally:
1. **Clone the Repository**
```bash
git clone https://github.com/SayanBanerjee-007/My_Tube_Backend.git
cd My_Tube_Backend
```2. **Install Dependencies**
```bash
npm install
```3. **Set Environment Variables**
Create a `.env` file in the root directory of the project and copy the content of the `.env.sample` file into it. Update the environment variables with your values.:
## Running the Application
Once you have configured your environment, you can start the application using:
```bash
npm start
```The server will start on the specified port (default: 5000) and connect to the MongoDB database.
## Development Mode
For development mode with live-reloading, use:
```bash
npm run dev
```This command uses nodemon to automatically restart the server upon code changes.
## Accessing the Application
Once the server is running, you can access the API endpoints via:
```bash
http://localhost:5000/api
```## API Documentation
Authentication
Endpoint
Method
Description
Request Body
/api/auth/register
POST
Register User
{
"username": "user",
"email": "[email protected]",
"password": "password"
}
/api/auth/login
POST
Login User
{
"email": "[email protected]",
"password": "password"
}
Users
Endpoint
Method
Description
Request Body
/api/users
GET
Get All Users
/api/users/:id
GET
Get User by ID
/api/users/:id
PUT
Update User
{
"username": "newusername",
"email": "[email protected]"
}
/api/users/:id
DELETE
Delete User
Videos
Endpoint
Method
Description
Request Body
/api/videos
GET
Get All Videos
/api/videos/:id
GET
Get Video by ID
/api/videos
POST
Create Video
{
"title": "Video Title",
"description": "Video Description",
"url": "http://video-url.com"
}
/api/videos/:id
PUT
Update Video
{
"title": "Updated Title",
"description": "Updated Description"
}
/api/videos/:id
DELETE
Delete Video
Comments
Endpoint
Method
Description
Request Body
/api/videos/:videoId/comments
GET
Get All Comments for a Video
/api/videos/:videoId/comments
POST
Add Comment to a Video
{
"text": "Nice video!"
}
/api/comments/:commentId
PUT
Update Comment
{
"text": "Updated comment text"
}
/api/comments/:commentId
DELETE
Delete Comment
There are more routes available in the application. You can explore them by running the application and visiting the `/api` endpoint.