http://localhost:3000/api
POST /auth/registerRequest Body:
{
"username": "johndoe",
"email": "john@example.com",
"password": "securepassword123",
"role": "user" // "user" or "admin"
}Response:
{
"status": "success",
"token": "jwt_token_here",
"data": {
"user": {
"_id": "user_id",
"username": "johndoe",
"email": "john@example.com",
"role": "user"
}
}
}POST /auth/loginRequest Body:
{
"email": "john@example.com",
"password": "securepassword123"
}Response:
{
"status": "success",
"token": "jwt_token_here",
"data": {
"user": {
"_id": "user_id",
"username": "johndoe",
"email": "john@example.com",
"role": "user"
}
}
}GET /auth/meHeaders:
Authorization: Bearer jwt_token_here
Response:
{
"status": "success",
"data": {
"user": {
"_id": "user_id",
"username": "johndoe",
"email": "john@example.com",
"role": "user"
}
}
}POST /personsHeaders:
Authorization: Bearer jwt_token_here
Request Body:
{
"name": "John Doe",
"occupation": ["Software Developer", "Technical Writer"],
"description": "Full stack developer with 5 years of experience",
"aliases": ["JD", "Johnny"],
"img": "profile-image-url"
}Response:
{
"status": "success",
"data": {
"_id": "person_id",
"name": "John Doe",
"occupation": ["Software Developer", "Technical Writer"],
"description": "Full stack developer with 5 years of experience",
"aliases": ["JD", "Johnny"],
"img": "profile-image-url",
"createdAt": "2024-12-31T...",
"updatedAt": "2024-12-31T..."
}
}GET /persons?page=1&limit=10&sort=name,-createdAtQuery Parameters:
page(optional): Page number (default: 1)limit(optional): Items per page (default: 10)sort(optional): Sorting criteria (prefix with - for descending)
Response:
{
"status": "success",
"results": 10,
"total": 45,
"totalPages": 5,
"currentPage": 1,
"data": [
{
"_id": "person_id",
"name": "John Doe",
"occupation": ["Software Developer"],
"description": "...",
"aliases": ["JD"],
"img": "profile-image-url",
"createdAt": "2024-12-31T...",
"updatedAt": "2024-12-31T..."
}
]
}PATCH /persons/:idHeaders:
Authorization: Bearer jwt_token_here
Request Body:
{
"name": "John Doe Updated",
"occupation": ["Senior Developer"],
"description": "Updated description"
}Response:
{
"status": "success",
"data": {
"_id": "person_id",
"name": "John Doe Updated",
"occupation": ["Senior Developer"],
"description": "Updated description",
"aliases": ["JD"],
"img": "profile-image-url",
"updatedAt": "2024-12-31T..."
}
}DELETE /persons/:idHeaders:
Authorization: Bearer jwt_token_here
Role: admin
Response:
{
"status": "success",
"data": null
}POST /videosHeaders:
Authorization: Bearer jwt_token_here
Content-Type: multipart/form-data
Form Data:
video: [video file]
description: "Video description"
keywords: ["keyword1", "keyword2"]
relatedPeople: [
{
"person": "person_id",
"name": "John Doe"
}
]
datetime: "2024-12-31T12:00:00Z"
Response:
{
"status": "success",
"data": {
"_id": "video_id",
"videoLink": "/uploads/unique-video-filename",
"description": "Video description",
"keywords": ["keyword1", "keyword2"],
"relatedPeople": [
{
"person": "person_id",
"name": "John Doe"
}
],
"datetime": "2024-12-31T12:00:00Z",
"createdAt": "2024-12-31T...",
"updatedAt": "2024-12-31T..."
}
}GET /videos?page=1&limit=10&sort=datetime,-createdAtQuery Parameters:
page(optional): Page number (default: 1)limit(optional): Items per page (default: 10)sort(optional): Sorting criteria (prefix with - for descending)
Response:
{
"status": "success",
"results": 10,
"total": 100,
"totalPages": 10,
"currentPage": 1,
"data": [
{
"_id": "video_id",
"videoLink": "/uploads/filename",
"description": "...",
"keywords": ["keyword1", "keyword2"],
"relatedPeople": [
{
"person": {
"_id": "person_id",
"name": "John Doe",
"occupation": ["Developer"],
"img": "..."
},
"name": "John Doe"
}
],
"datetime": "2024-12-31T...",
"createdAt": "2024-12-31T...",
"updatedAt": "2024-12-31T..."
}
]
}GET /videos/search?query=keyword&startDate=2024-01-01&endDate=2024-12-31&people=person_id1,person_id2&keywords=keyword1,keyword2Query Parameters:
query: Search text (searches in description, keywords, and people names)startDate: Filter videos from this dateendDate: Filter videos until this datepeople: Comma-separated list of person IDskeywords: Comma-separated list of keywords
Response:
{
"status": "success",
"results": 5,
"data": [
{
"_id": "video_id",
"videoLink": "/uploads/filename",
"description": "...",
"keywords": ["keyword1"],
"relatedPeople": [
{
"person": {
"_id": "person_id1",
"name": "John Doe",
"occupation": ["Developer"],
"img": "..."
},
"name": "John Doe"
}
],
"datetime": "2024-12-31T..."
}
]
}PATCH /videos/:idHeaders:
Authorization: Bearer jwt_token_here
Request Body:
{
"description": "Updated description",
"keywords": ["updated", "keywords"],
"relatedPeople": [
{
"person": "person_id",
"name": "John Doe"
}
],
"datetime": "2024-12-31T12:00:00Z"
}Response:
{
"status": "success",
"data": {
"_id": "video_id",
"videoLink": "/uploads/filename",
"description": "Updated description",
"keywords": ["updated", "keywords"],
"relatedPeople": [
{
"person": "person_id",
"name": "John Doe"
}
],
"datetime": "2024-12-31T12:00:00Z",
"updatedAt": "2024-12-31T..."
}
}DELETE /videos/:idHeaders:
Authorization: Bearer jwt_token_here
Role: admin
Response:
{
"status": "success",
"data": null
}All endpoints may return the following error responses:
{
"status": "error",
"message": "Error message describing the issue"
}{
"status": "fail",
"message": "You are not logged in"
}{
"status": "fail",
"message": "You do not have permission to perform this action"
}{
"status": "error",
"message": "Resource not found"
}{
"status": "error",
"message": "Internal server error"
}Create a .env file in the root directory with the following variables:
MONGODB_URI=mongodb://localhost:27017/video-management
JWT_SECRET=your_jwt_secret_key
JWT_EXPIRES_IN=90d
PORT=3000- Video files: Maximum 100MB
- Supported video formats: MP4, WebM, OGG