Skip to content

Czar-16/Clixx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Clixx Backend

A Node.js (Express) backend for the Clixx platform. It provides RESTful APIs for user management, authentication, and media handling.


Table of Contents


Features

  • User registration, login, logout, and JWT‑based authentication
  • Password change & user profile updates (avatar, cover image)
  • Media upload via Multer and Cloudinary integration
  • Secure routes protected by JWT middleware
  • Pagination for watch‑history and channel profiles

Prerequisites

  • Node.js >= 20 (the project uses ES modules)
  • npm (or yarn)
  • A MongoDB instance (local or remote)
  • A Cloudinary account (for image uploads)

Installation

# Clone the repository (if you haven't already)
git clone <repo‑url>
cd Clixx

# Install dependencies
npm install

Configuration

Create a .env file in the project root (./.env). Below is a minimal example – adjust values to match your environment:

# Server
PORT=8080
CORS_ORIGIN=http://localhost:3000

# MongoDB
MONGODB_URI=mongodb://localhost:27017/clixx
DB_NAME=clixx

# JWT
JWT_SECRET=your‑strong‑secret
JWT_EXPIRES_IN=7d

# Cloudinary (optional – required for avatar & cover uploads)
CLOUDINARY_CLOUD_NAME=your‑cloud‑name
CLOUDINARY_API_KEY=your‑api‑key
CLOUDINARY_API_SECRET=your‑api‑secret

Note: The server reads the .env file via dotenv. Ensure the file is added to .gitignore.


Running the Application

Development

npm run dev

The server will automatically restart on file changes (via nodemon) and listen on http://localhost:${PORT}.

Production

node src/index.js

API Reference

All routes are prefixed with /api/v1/users.

Method Path Description Auth
POST /register Register a new user (multipart – avatar & coverImage optional)
POST /login Login and receive a JWT token
POST /logout Invalidate the current token (client‑side)
POST /refresh-token Refresh an expired access token
POST /change-password Change the authenticated user's password
GET /current-user Retrieve the profile of the logged‑in user
PATCH /update-account Update user details (e.g., username, email)
PATCH /avatar Upload a new avatar image
PATCH /cover-image Upload a new cover image
GET /c/:username Get public channel profile for a user
GET /history Get the authenticated user's watch history

Auth: = requires the Authorization: Bearer <jwt> header; = public.


Testing

No test suite is currently included. Add your own tests (e.g., with Jest or Mocha) and place them under a tests/ directory.


Contributing

  1. Fork the repository.
  2. Create a feature branch (git checkout -b feature/awesome-feature).
  3. Make your changes and ensure the code follows the existing style (run npm run prettier).
  4. Submit a pull request describing the changes.

License

This project is licensed under the ISC license.

About

Clixx is a YouTube‑like application that currently implements only the backend services. It provides a Node.js/Express API with MongoDB

Resources

Stars

Watchers

Forks

Contributors