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
- Auth - Authorization
- User - User manipulation methods
- Get current user (Authentication needed)
- Get user by username
- Edit User (Authentication needed)
- Delete User (Authentication needed)
- Video - Video files manipulation methods
- Upload Video (Authentication needed)
- Get Video By Title
- Get Videos
- Edit Video (Authentication needed)
- Delete Video (Authentication needed)
- Comments - Comments Manipulation methods
- Create Comment (Authentication needed)
- Get Video By Title
- Edit Comment (Authentication needed)
- Delete Comment (Authentication needed)
- Likes / Dislikes - Like/Dislike manipulation methods [Queried]
- Create Like (Authentication needed)
- Remove Like [Queried] (Authentication needed)
- Create Dislike (Authentication needed)
Note This section dedicated to creating and authorizing users
Type: POST
POST api/auth/login
Incoming parameters:
# | naming | type | specs |
---|---|---|---|
1 | string | your email | |
2 | username | string | your username |
3 | password | string | your password |
4 | checkPassword | string | repeat of your password |
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": []
}
}
Type: POST
api/auth/login
Incoming parameters:
# | naming | type | specs |
---|---|---|---|
1 | username | string | your username |
2 | password | string | your password |
Returned object
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": []
}
}
Note This section dedicated to work with users
Required Needs Authorization
Type: Put
PUT api/auth/login
# | naming | type | specs |
---|---|---|---|
1 | 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
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": []
}
}
Required Needs Authorization
Type: Get
GET api/user/account
Required Authentication Needed
Note This method return all your data from database
Not Return Value
const req = await fetch('api/user/account', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authentcation: 'Bearer 123',
},
});
{
"user": {
"email": "1234@mail.ru",
"username": "test",
"password": "$2b$10$5/DK9tMXP3OTGhMT3Sdw4e1OXa0OzhYH3A7o5jtAiHF5hEY0X.mFS",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6IjEyMzRAbWFpbC5ydSIsInVzZXJuYW1lIjoidGVzdCIsInBhc3N3b3JkIjoiMTIzIiwiY2hlY2tQYXNzd29yZCI6IjEyMyIsImlhdCI6MTY5NDI2NzE3MH0.MSBM-okUu8irbWDoze0yQI_BdheXghyI9cpctpIFDIg",
"videos": []
}
}
Type: Get
GET api/user/:username
Note This method return all requested user data
Not Return Value
const req = await fetch('api/user/test', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
});
{
"user": {
"email": "1234@mail.ru",
"username": "test",
"password": "$2b$10$5/DK9tMXP3OTGhMT3Sdw4e1OXa0OzhYH3A7o5jtAiHF5hEY0X.mFS",
"token": "...",
"videos": []
}
}
Required Needs Authorization
Type: Delete
DELETE api/user
Required Authentication Needed
Note This method will delete your user from database
const req = await fetch('api/user', {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
Authentication: 'Bearer 123',
},
});
Not Return Value
Note This section dedicated to work with videos
Required Authentication required
Type: POST
POST api/video
# | 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,
});
{
"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"
}
]
}
}
}
Returns all videos
Type: GET
GET api/video
# | naming | type | specs |
---|---|---|---|
1 | title | string | video title |
fetch('api/video/test', {
method: 'GET',
});
{
"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": "..."
}
}
}
Return your all information about requested video
Type: GET
GET api/video/:title
fetch('api/video/test', {
method: 'GET',
});
{
"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": "..."
}
}
}
Required Authentication required
Type: PUT
PUT api/video
# | 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',
},
});
{
"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"
}
]
}
}
}
Note This section dedicated to creating and authorizing users
Required Authentication required
Type: POST
POST api/commants
# | 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',
},
});
Type: GET
GET api/commants/:id
fetch('api/commants/1', {
method: 'GET',
headers: {
Authentication: 'Beqrer 123',
},
});
{
"comment": {
"id": 1,
"title": "123",
"body": "123",
"author": {
},
"commentedVideo": {
"id": 1,
"title": "test",
"body": "test"
}
}
}
No needed fields
Required Authentication Required
Type: GET
fetch('api/commants/1', {
method: 'DELETE',
headers: {
Authentication: 'Beqrer 123',
},
});
Required Authentication Required
Type: PUT
# | 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',
},
});
{
"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
Base route api/like/
Required Authentication needed
Type: Post
# | naming | type | specs |
---|---|---|---|
1 | videoId | number | liked video id |
2 | commentId | number | liked comment id |
fetch('api/like/', {
body: {
commentId: 1,
},
method: 'POST',
headers: {
Authentication: 'Beqrer 123',
},
});
{
"like": {
"id": 1,
"author": {},
"likedVideo": {},
"likedComment": {
"id": 1,
"isLiked": true,
"likesCount": 1
}
}
}
Required Authentication needed
Type: DELETE
Note Expecting query
/api/like/../..?dislikeId=
fetch('api/like/vieo/1?likeId=1', {
method: 'DELETE',
headers: {
Authentication: 'Beqrer 123',
},
});
// nothing
Base route api/dislike/
Required Authentication needed
Type: Post
# | naming | type | specs |
---|---|---|---|
1 | videoId | number | liked video id |
2 | commentId | number | liked comment id |
fetch('api/dislike/', {
body: {
commentId: 1,
},
method: 'POST',
headers: {
Authentication: 'Beqrer 123',
},
});
{
"dislike": {
"id": 1,
"author": {},
"dislikedVideo": {},
"dislikedComment": {
"id": 1,
"isDisliked": true,
"dislikesCount": 1
}
}
}
Required Authentication needed
Type: DELETE
Note Expecting query
/api/dislike/../..?dislikeId=
fetch('api/dislike/vieo/1?likeId=1', {
method: 'DELETE',
headers: {
Authentication: 'Beqrer 123',
},
});
// nothing