Backend service for a video streaming platform. Handles authentication, video uploads, asynchronous processing, and secure access to user-owned content.
This repository represents v1.0.0 — a stable backend ready for frontend integration.
- Node.js
- Express.js
- MongoDB + Mongoose
- Cloudinary (video storage, HLS streaming, thumbnails)
- JWT Authentication
- Multer (temporary file uploads)
- Winston (structured logging)
- Docker (deployment-ready)
- User registration & login (JWT-based)
- Secure video upload with async processing
- HLS (
.m3u8) streaming support - Automatic thumbnail generation
- Video status lifecycle (
PROCESSING → READY / FAILED) - Fetch videos for logged-in user with pagination
- Centralized error handling
- Safe temporary file cleanup
- Structured logging with timestamps
- Client uploads video
- File stored temporarily on disk via Multer
- Video record created immediately with status
PROCESSING - Async upload to Cloudinary (HLS + thumbnail)
- Video metadata updated (
READY/FAILED) - Temporary file deleted from server
This ensures:
- Non-blocking uploads
- Resilient failure handling
- Clean filesystem state
| Method | Route | Description |
|---|---|---|
| POST | /api/auth/register |
Register new user |
| POST | /api/auth/login |
Login user |
| Method | Route | Description |
|---|---|---|
| POST | /api/videos/upload |
Upload a new video |
| GET | /api/videos/my |
Get videos of logged-in user |
| GET | /api/videos/:id |
Get video by ID (owner-only for now) |
GET /api/videos/my?page=1&limit=10
Response includes metadata:
{
"meta": {
"page": 1,
"limit": 10,
"total": 6,
"totalPages": 1
}
}Create a .env file in root:
PORT=5000
NODE_ENV=development
MONGO_URI=your_mongodb_uri
REDIS_URL = your_redis_url (leave empty if you have redis installed and you are running it locally)
JWT_SECRET=your_jwt_secret
JWT_EXPIRES_IN=7d
CLOUDINARY_CLOUD_NAME=xxxx
CLOUDINARY_API_KEY=xxxx
CLOUDINARY_API_SECRET=xxxx# install dependencies
npm install
# start dev server
npm run dev- Uses Winston
- Console logs for development
- Structured JSON logs (file-ready)
- Error stack traces preserved
- Timezone-aware timestamps (IST)
- Centralized
AppErrorclass - Async error wrapper
- No unhandled promise rejections
- Consistent error response format
- JWT verified on every protected route
- Users can only access their own videos
- No direct file-system exposure
- Cloudinary URLs returned only when video is
READY
-
v1.0.0
- Backend feature-complete
- No video sharing
- No public access
- Focused on core upload & playback flow
Future versions will add:
- Video sharing
- Public/private controls
- Analytics
- Admin tools
- Caching layer (Redis)
MIT
Vishal Backend focused on correctness, scalability, and clean architecture.