Skip to content

tmahmud7771/News-Analysis-Platform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Video Management System API Documentation

Table of Contents

Base URL

http://localhost:3000/api

Authentication

Register New User

POST /auth/register

Request 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"
    }
  }
}

Login

POST /auth/login

Request 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 Current User Profile

GET /auth/me

Headers:

Authorization: Bearer jwt_token_here

Response:

{
  "status": "success",
  "data": {
    "user": {
      "_id": "user_id",
      "username": "johndoe",
      "email": "john@example.com",
      "role": "user"
    }
  }
}

Person Management

Create Person Profile

POST /persons

Headers:

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 All Persons

GET /persons?page=1&limit=10&sort=name,-createdAt

Query 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..."
    }
  ]
}

Update Person Profile

PATCH /persons/:id

Headers:

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 Person Profile

DELETE /persons/:id

Headers:

Authorization: Bearer jwt_token_here
Role: admin

Response:

{
  "status": "success",
  "data": null
}

Video Management

Upload Video

POST /videos

Headers:

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 All Videos

GET /videos?page=1&limit=10&sort=datetime,-createdAt

Query 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..."
    }
  ]
}

Search Videos

GET /videos/search?query=keyword&startDate=2024-01-01&endDate=2024-12-31&people=person_id1,person_id2&keywords=keyword1,keyword2

Query Parameters:

  • query: Search text (searches in description, keywords, and people names)
  • startDate: Filter videos from this date
  • endDate: Filter videos until this date
  • people: Comma-separated list of person IDs
  • keywords: 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..."
    }
  ]
}

Update Video

PATCH /videos/:id

Headers:

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 Video

DELETE /videos/:id

Headers:

Authorization: Bearer jwt_token_here
Role: admin

Response:

{
  "status": "success",
  "data": null
}

Error Responses

All endpoints may return the following error responses:

400 Bad Request

{
  "status": "error",
  "message": "Error message describing the issue"
}

401 Unauthorized

{
  "status": "fail",
  "message": "You are not logged in"
}

403 Forbidden

{
  "status": "fail",
  "message": "You do not have permission to perform this action"
}

404 Not Found

{
  "status": "error",
  "message": "Resource not found"
}

500 Internal Server Error

{
  "status": "error",
  "message": "Internal server error"
}

Environment Variables

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

File Upload Limits

  • Video files: Maximum 100MB
  • Supported video formats: MP4, WebM, OGG

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published