A Node.js (Express) backend for the Clixx platform. It provides RESTful APIs for user management, authentication, and media handling.
- Features
- Prerequisites
- Installation
- Configuration
- Running the Application
- API Reference
- Testing
- Contributing
- License
- 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
- Node.js >= 20 (the project uses ES modules)
- npm (or yarn)
- A MongoDB instance (local or remote)
- A Cloudinary account (for image uploads)
# Clone the repository (if you haven't already)
git clone <repo‑url>
cd Clixx
# Install dependencies
npm installCreate 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‑secretNote: The server reads the
.envfile viadotenv. Ensure the file is added to.gitignore.
npm run devThe server will automatically restart on file changes (via nodemon) and listen on http://localhost:${PORT}.
node src/index.jsAll 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.
No test suite is currently included. Add your own tests (e.g., with Jest or Mocha) and place them under a
tests/directory.
- Fork the repository.
- Create a feature branch (
git checkout -b feature/awesome-feature). - Make your changes and ensure the code follows the existing style (run
npm run prettier). - Submit a pull request describing the changes.
This project is licensed under the ISC license.