Deadly Simple Video API

DEPREACETD
<style> h1 { font-size: 34px; } .heading { display: flex; align-items: center; justify-content: center; } label { margin-top: 35px; background:#de2f2f; padding: 2px 5px; font-size: 12px; text-transform:uppercase; border-radius: 5px; margin-left: 10px; } .dep { margin-bottom: 60px; } </style>

The Smallest and powerful API for new generation video service for creators.

Attempt This repository is dockerized

docker run -e SECRET_KEY=your_secret_key \
           -e EXPIRES_IN=your_expires_in \
           -e DB_HOST=your_db_host \
           -e DB_NAME=your_db_name \
           -e DB_PORT=your_db_port \
           -e DB_PASSWORD=your_db_password \
           -e DB_USERNAME=your_db_username \
           -e DROPSCHEMA=your_dropschema \
           -e SYNCHRONIZE=your_synchronize \
           -e MIGRATIONS_RUN=your_migrations_run \
           0xc000007bl/sbertube-backend:latest

Methods

  1. Auth - Authorization
    1. Register
    2. Login
  2. User - User manipulation methods
    1. Get current user (Authentication needed)
    2. Get user by username
    3. Edit User (Authentication needed)
    4. Delete User (Authentication needed)
  3. Video - Video files manipulation methods
    1. Upload Video (Authentication needed)
    2. Get Video By Title
    3. Get Videos
    4. Edit Video (Authentication needed)
    5. Delete Video (Authentication needed)
  4. Comments - Comments Manipulation methods
    1. Create Comment (Authentication needed)
    2. Get Video By Title
    3. Edit Comment (Authentication needed)
    4. Delete Comment (Authentication needed)
  5. Likes / Dislikes - Like/Dislike manipulation methods [Queried]
    1. Create Like (Authentication needed)
    2. Remove Like [Queried] (Authentication needed)
    3. Create Dislike (Authentication needed)

Auth

Note This section dedicated to creating and authorizing users

Register

Type: POST

This method accept user to register

   POST api/auth/login

Incoming parameters:

# naming type specs
1 email string your email
2 username string your username
3 password string your password
4 checkPassword string repeat of your password

Example

const req = await fetch('api/auth/login', {
	body: {
		email: '123@mail.ru',
		username: 'test',
		password: '123',
		checkPassword: '123',
	},
	method: 'POST',
	headers: {
		'Content-Type': 'application/json',
	},
});
const resp = req.json();

Returned object

{
    "user": {
        "email": "1234@mail.ru",
        "username": "test",
        "password": "$2b$10$5/DK9tMXP3OTGhMT3Sdw4e1OXa0OzhYH3A7o5jtAiHF5hEY0X.mFS",
        "token": "...",
        "videos": []
    }
}

Login

Type: POST

This method accept user to login

    api/auth/login

Incoming parameters:

# naming type specs
1 username string your username
2 password string your password

Returned object

Example

const req = await fetch('api/auth/login', {
	body: {
		username: 'test',
		password: '123',
	},
	method: 'POST',
	headers: {
		'Content-Type': 'application/json',
	},
});
const resp = req.json();
 {
    "user": {
        "email": "1234@mail.ru",
        "username": "test",
        "password": "$2b$10$5/DK9tMXP3OTGhMT3Sdw4e1OXa0OzhYH3A7o5jtAiHF5hEY0X.mFS",
       "token": "...",
        "videos": []
    }
}

User

Note This section dedicated to work with users

Edit User

Required Needs Authorization

Type: Put

 PUT api/auth/login
# naming type specs
1 email string your email
1 username string your username
2 password string your password

Note Email not editable field These method will edit your data on datatbase

Returned object

Example

const req = await fetch('api/user', {
	body: {
		email: '123@mail.ru',
		username: 'test123',
		password: '123',
	},
	method: 'PUT',
	headers: {
		'Content-Type': 'application/json',
	},
});
const resp = req.json();
 {
    "user": {
        "email": "1234@mail.ru",
        "username": "test",
        "password": "$2b$10$5/DK9tMXP3OTGhMT3Sdw4e1OXa0OzhYH3A7o5jtAiHF5hEY0X.mFS",
        "token": "...",
        "videos": []
    }
}

Get Current User

Required Needs Authorization

Type: Get

 GET api/user/account

Required Authentication Needed

Note This method return all your data from database

Not Return Value

Example

const req = await fetch('api/user/account', {
	method: 'GET',
	headers: {
		'Content-Type': 'application/json',
		Authentcation: 'Bearer 123',
	},
});

Returns object

{
    "user": {
        "email": "1234@mail.ru",
        "username": "test",
        "password": "$2b$10$5/DK9tMXP3OTGhMT3Sdw4e1OXa0OzhYH3A7o5jtAiHF5hEY0X.mFS",
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6IjEyMzRAbWFpbC5ydSIsInVzZXJuYW1lIjoidGVzdCIsInBhc3N3b3JkIjoiMTIzIiwiY2hlY2tQYXNzd29yZCI6IjEyMyIsImlhdCI6MTY5NDI2NzE3MH0.MSBM-okUu8irbWDoze0yQI_BdheXghyI9cpctpIFDIg",
        "videos": []
    }
}

Get User By Username

Type: Get

 GET api/user/:username

Note This method return all requested user data

Not Return Value

Example

const req = await fetch('api/user/test', {
	method: 'GET',
	headers: {
		'Content-Type': 'application/json',
	},
});

Returns object

{
    "user": {
        "email": "1234@mail.ru",
        "username": "test",
        "password": "$2b$10$5/DK9tMXP3OTGhMT3Sdw4e1OXa0OzhYH3A7o5jtAiHF5hEY0X.mFS",
       "token": "...",
       "videos": []
    }
}

Delete User

Required Needs Authorization

Type: Delete

 DELETE api/user

Required Authentication Needed

Note This method will delete your user from database

Example

const req = await fetch('api/user', {
	method: 'DELETE',
	headers: {
		'Content-Type': 'application/json',
		Authentication: 'Bearer 123',
	},
});

Not Return Value

Video

Note This section dedicated to work with videos

Upload Video

Required Authentication required

Type: POST

   POST api/video

Expected values

# naming type specs
1 file file file which you want to upload
2 title string your uploaded video title
3 body string your video description
4 shortBody string your video short description

Note These method use form-data for file upload

const params = new FormData(form);

fetch('api/video', {
	method: 'POST',
	body: params,
});

Returned Object

   {
   "video": {
      "id": 1,
      "title": "test",
      "body": "test",
      "shortBody": "test3",
      "path": "static/video/Screencast 2023-09-05 22:13:25.avi",
      "author": {
         "id": 2,
         "email": "1234@mail.ru",
         "username": "test",
         "password": "$2b$10$5/DK9tMXP3OTGhMT3Sdw4e1OXa0OzhYH3A7o5jtAiHF5hEY0X.mFS",
         "checkPassword": "$2b$10$I2X7aWAgpeU.MOY3hMpRNu9MYaJ0FbitzUVny1qxzpBsx.F7EPvfe",
         "token": "...",
         "videos": [
            {
               "id": 1,
               "title": "test",
               "body": "test",
               "shortBody": "test",
               "path": "static/video/Screencast 2023-09-05 22:13:25.avi"

            }
         ]
      }
   }
}

Get All Videos

Returns all videos

Type: GET

   GET api/video

Expected values

# naming type specs
1 title string video title
fetch('api/video/test', {
	method: 'GET',
});

Returned Object

   {
   "video": {
      "id": 1,
      "title": "test",
      "body": "test",
      "shortBody": "test3",
      "path": "static/video/Screencast 2023-09-05 22:13:25.avi",
      "author": {
         "id": 2,
         "email": "1234@mail.ru",
         "username": "test",
         "password": "$2b$10$5/DK9tMXP3OTGhMT3Sdw4e1OXa0OzhYH3A7o5jtAiHF5hEY0X.mFS",
         "checkPassword": "$2b$10$I2X7aWAgpeU.MOY3hMpRNu9MYaJ0FbitzUVny1qxzpBsx.F7EPvfe",
         "token": "..."
      }
   }
}

Get Video By Title

Return your all information about requested video

Type: GET

   GET api/video/:title
fetch('api/video/test', {
	method: 'GET',
});

Returned Object

   {
   "video": {
      "id": 1,
      "title": "test",
      "body": "test",
      "shortBody": "test3",
      "path": "static/video/Screencast 2023-09-05 22:13:25.avi",
      "author": {
         "id": 2,
         "email": "1234@mail.ru",
         "username": "test",
         "password": "$2b$10$5/DK9tMXP3OTGhMT3Sdw4e1OXa0OzhYH3A7o5jtAiHF5hEY0X.mFS",
         "checkPassword": "$2b$10$I2X7aWAgpeU.MOY3hMpRNu9MYaJ0FbitzUVny1qxzpBsx.F7EPvfe",
         "token": "..."
      }
   }
}

Edt Video

Required Authentication required

Type: PUT

   PUT api/video

Expected Values

# naming type specs
1 title string video title
1 body string new video description
1 shortBody string new short description
fetch('api/video', {
	body: {
		video: {
			title: '123',
			body: '123',
			shortBody: '123',
		},
	},
	method: 'PUT',
	headers: {
		Authentication: 'Beqrer 123',
	},
});

Returned Object

   {
   "video": {
      "id": 1,
      "title": "123",
      "body": "123",
      "shortBody": "123",
      "path": "static/video/Screencast 2023-09-05 22:13:25.avi",
      "author": {
         "id": 2,
         "email": "1234@mail.ru",
         "username": "test",
         "password": "$2b$10$5/DK9tMXP3OTGhMT3Sdw4e1OXa0OzhYH3A7o5jtAiHF5hEY0X.mFS",
         "checkPassword": "$2b$10$I2X7aWAgpeU.MOY3hMpRNu9MYaJ0FbitzUVny1qxzpBsx.F7EPvfe",
         "token": "...",
         "videos": [
            {
               "id": 1,
               "title": "123",
               "body": "123",
               "shortBody": "123",
               "path": "static/video/Screencast 2023-09-05 22:13:25.avi"
            }
         ]
      }
   }
}

COMMENTS

Note This section dedicated to creating and authorizing users

Create Comment

Required Authentication required

Type: POST

   POST api/commants

Expected Values

# naming type specs
1 title string comment title
2 body string comment body
fetch('api/comments', {
	body: {
		video: {
			title: '123',
			body: '123',
		},
	},
	method: 'POST',
	headers: {
		Authentication: 'Beqrer 123',
	},
});

Returned Object

these method not returns any value

Get Comment By Id

Type: GET

   GET api/commants/:id
fetch('api/commants/1', {
	method: 'GET',
	headers: {
		Authentication: 'Beqrer 123',
	},
});

Returned Object

 {
   "comment": {
      "id": 1,
      "title": "123",
      "body": "123",
      "author": {

      },
         "commentedVideo": {
            "id": 1,
            "title": "test",
            "body": "test"

         }
      }
   }

Expected Values

No needed fields

Delete Comment

Required Authentication Required

Type: GET

fetch('api/commants/1', {
	method: 'DELETE',
	headers: {
		Authentication: 'Beqrer 123',
	},
});

Returned Object

Edit Comment

Required Authentication Required

Type: PUT

Expected values

# naming type specs
1 title string comment title
2 body string comment body
fetch('api/commants/1', {
	body: {
		title: 'test',
		body: 'test',
	},
	method: 'PUT',
	headers: {
		Authentication: 'Beqrer 123',
	},
});

Returned Object

 {
   "comment": {
      "id": 1,
              "title": "test",
              "body": "test",
              "author": {
         "id": 2,
                 "email": "1234@mail.ru",
                 "username": "test",
                 "password": "$2b$10$5/DK9tMXP3OTGhMT3Sdw4e1OXa0OzhYH3A7o5jtAiHF5hEY0X.mFS",
                 "checkPassword": "$2b$10$I2X7aWAgpeU.MOY3hMpRNu9MYaJ0FbitzUVny1qxzpBsx.F7EPvfe",
                 "token": "...",
                 "videos": [
            {
               "id": 1,
               "title": "123",
               "body": "123",
               "shortBody": "123",
               "path": "static/video/Screencast 2023-09-05 22:13:25.avi"

            }
         ],
                 "commentedVideo": {
            "id": 1,
                    "title": "test",
                    "body": "test"
         }
      }
   }
}

Note These methods uses query params

Likes / Dislikes

Likes

Base route api/like/

Create Like

Required Authentication needed

Type: Post

Expected values

# naming type specs
1 videoId number liked video id
2 commentId number liked comment id

Example

fetch('api/like/', {
	body: {
		commentId: 1,
	},
	method: 'POST',
	headers: {
		Authentication: 'Beqrer 123',
	},
});

Returned Object

{
	"like": {
		"id": 1,
		"author": {},
		"likedVideo": {},
		"likedComment": {
			"id": 1,
			"isLiked": true,
			"likesCount": 1
		}
	}
}

Remove Like

Required Authentication needed

Type: DELETE

Expected values

Note Expecting query

/api/like/../..?dislikeId=

Example

fetch('api/like/vieo/1?likeId=1', {
	method: 'DELETE',
	headers: {
		Authentication: 'Beqrer 123',
	},
});

Returned Object

// nothing

Dislikes

Base route api/dislike/

Create Dislike

Required Authentication needed

Type: Post

Expected values

# naming type specs
1 videoId number liked video id
2 commentId number liked comment id

Example

fetch('api/dislike/', {
	body: {
		commentId: 1,
	},
	method: 'POST',
	headers: {
		Authentication: 'Beqrer 123',
	},
});

Returned Object

{
	"dislike": {
		"id": 1,
		"author": {},
		"dislikedVideo": {},
		"dislikedComment": {
			"id": 1,
			"isDisliked": true,
			"dislikesCount": 1
		}
	}
}

Remove Like

Required Authentication needed

Type: DELETE

Expected values

Note Expecting query

/api/dislike/../..?dislikeId=

Example

fetch('api/dislike/vieo/1?likeId=1', {
	method: 'DELETE',
	headers: {
		Authentication: 'Beqrer 123',
	},
});

Returned Object

// nothing