This RESTful API was developed as part of the full-stack backend developer selection process. It's designed to assess the developer's skills and is freely available for use in frontend development or other applications.
To get started, follow these steps:
Make sure you have the following installed:
-
Clone the repository:
git clone https://github.com/Davidongo93/videoapp-API-challenge.git
-
Install dependencies:
cd videoapp-API-challenge npm install
-
paste .env file sended by mail into the project root directory
-
Start the server:
npm start
The server will be running at http://localhost:3000/
.
-
Test
npm test
- Login User: - POST -
/users/login
- New User: - POST -
/users
- Edit User: - PUT -
/users/edit
- Delete User: - DELETE -
/users/delete
- New Video: - POST -
/video/post
- Edit Video: - PUT -
/video/edit/${videoId}
- Delete Video: - DELETE -
/video/delete/${videoId}
- Videos By User: - GET -
/video/user/${userId}
- Private Videos: - GET -
/video/private
- Public Videos: - GET -
/video/public
- Video Comment: - POST -
/video/${videoId}/comment
- Video Reaction: - POST -
/video/${videoId}/like
- Videos by reactions: - GET -
/video/popular
- Endpoint:
POST /users
- Description: Register a new user.
- Request Body:
{ "username": "theUser", "email": "john@email.com", "password": "12345" }
- Response (success):
{ "success": true, "message": "User created successfully", "data": { "id": "6389a2df-e0a1-4bf5-9bca-5fef51024bd0", "username": "CypherBetray", "email": "cypher@zion.org", "password": "****", "updatedAt": "2024-01-27T18:23:25.814Z", "createdAt": "2024-01-27T18:23:25.814Z", "deletedAt": null } }
- Endpoint:
POST /users/login
- Description: Login with email and password.
- Request Body:
{ "email": "john@email.com", "password": "12345" }
- Response (Success):
{ "success": true, "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...." }
- Response (Invalid Credentials):
{ "success": false, "token": "Invalid credentials" }
-
Endpoint:
PUT /users
-
Description: Modify username or password.
-
Request Headers:
Authorization: Bearer <token>
-
Request Parameters:
{ "username": "newUsername", "password": "newPassword" }
-
Response:
{ "success": true, "message": "User information updated successfully" }
-
Endpoint:
DELETE /users
-
Description: Logical delete (deletedAt not null).
-
Request Headers:
Authorization: Bearer <token>
-
Response:
{ "success": true, "message": "User deleted successfully" }
-
Request Headers:
Authorization: Bearer <token>
-
Request Body:
{
"title": "Pranks Gone Wild",
"description": "A compilation of hilarious pranks caught on camera.",
"credits": "Credits: PranksterExtreme",
"isPublic": false,
"videoUrl": "https://www.funnyvideos.com/pranks-gone-wild.mp4"
}
{
"success": true,
"message": "Video created successfully",
"data": {
"title": "Pranks Gone Wild",
"description": "A compilation of hilarious pranks caught on camera.",
"credits": "Credits: PranksterExtreme",
"isPublic": false,
"videoUrl": "https://www.funnyvideos.com/pranks-gone-wild.mp4",
"userId": "6389a2df-e0a1-4bf5-9bca-5fef51024bd0"
}
}
- Request Headers:
Authorization: Bearer <token>
{
"title": "Pranks Gone Wild",
"description": "A compilation of hilarious pranks caught on camera.",
"credits": "Credits: PranksterExtreme",
"isPublic": false,
"videoUrl": "https://www.funnyvideos.com/pranks-gone-wild.mp4"
}
- Request Headers:
Authorization: Bearer <token>
{
"success": true,
"message": "Video deleted successfully"
}
- Request Headers:
Authorization: Bearer <token>
{
"success": true,
"videos": [
{
"id": "4c8a7783-60fe-4967-a49e-423414e99a3a",
"title": "Cats Dancing Ballet",
"description": "Adorable cats showing off their ballet skills.",
"credits": "Credits: Choreography by Whiskers, Music by Meowzart",
"isPublic": true,
"videoUrl": "https://www.funnyvideos.com/cats-ballet.mp4",
"createdAt": "2024-01-27T14:58:51.958Z",
"updatedAt": "2024-01-27T14:58:51.958Z",
"userId": "dc5761a5-5517-4602-ab4b-89779479061c"
},
{
"id": "f7b271ac-b63d-4e43-8f43-64608105e28e",
"title": "Epic Fail Compilation",
"description": "A compilation of hilarious fails from around the world.",
"credits": "Credits: None, because no one wants to claim these fails!",
"isPublic": false,
"videoUrl": "https://www.funnyvideos.com/epic-fail.mp4",
"createdAt": "2024-01-27T14:59:07.127Z",
"updatedAt": "2024-01-27T14:59:07.127Z",
"userId": "dc5761a5-5517-4602-ab4b-89779479061c"
},
{
"id": "4787445e-44d2-4a19-8437-6364d0221955",
"title": "Baby Laughing at Ripping Paper",
"description": "A baby's uncontrollable laughter at the sound of ripping paper.",
"credits": "Credits: Happy Baby Productions",
"isPublic": true,
"videoUrl": "https://www.funnyvideos.com/baby-laughing.mp4",
"createdAt": "2024-01-27T14:59:12.941Z",
"updatedAt": "2024-01-27T14:59:12.941Z",
"userId": "dc5761a5-5517-4602-ab4b-89779479061c"
},
{
"id": "a7ea4a13-362d-4b24-a6d0-8e946e1dab31",
"title": "Squirrel Olympics",
"description": "Squirrels showcasing their amazing acrobatic skills.",
"credits": "Credits: Squirrel Athletics Association",
"isPublic": false,
"videoUrl": "https://www.funnyvideos.com/squirrel-olympics.mp4",
"createdAt": "2024-01-27T14:59:28.553Z",
"updatedAt": "2024-01-27T14:59:28.553Z",
"userId": "dc5761a5-5517-4602-ab4b-89779479061c"
},
{
"id": "e9101d0f-5579-4ae8-aef9-05c358001e5c",
"title": "Dancing Penguin Party",
"description": "Penguins having a dance party in Antarctica.",
"credits": "Credits: DJ Penguin on the turntables",
"isPublic": true,
"videoUrl": "https://www.funnyvideos.com/dancing-penguins.mp4",
"createdAt": "2024-01-27T14:59:50.930Z",
"updatedAt": "2024-01-27T14:59:50.930Z",
"userId": "dc5761a5-5517-4602-ab4b-89779479061c"
}
]
}
- Request Headers:
Authorization: Bearer <token>
{
"success": true,
"videos": [
{
"id": "f7b271ac-b63d-4e43-8f43-64608105e28e",
"title": "Epic Fail Compilation",
"description": "A compilation of hilarious fails from around the world.",
"credits": "Credits: None, because no one wants to claim these fails!",
"isPublic": false,
"videoUrl": "https://www.funnyvideos.com/epic-fail.mp4",
"createdAt": "2024-01-27T14:59:07.127Z",
"updatedAt": "2024-01-27T14:59:07.127Z",
"userId": "dc5761a5-5517-4602-ab4b-89779479061c"
},
{
"id": "a7ea4a13-362d-4b24-a6d0-8e946e1dab31",
"title": "Squirrel Olympics",
"description": "Squirrels showcasing their amazing acrobatic skills.",
"credits": "Credits: Squirrel Athletics Association",
"isPublic": false,
"videoUrl": "https://www.funnyvideos.com/squirrel-olympics.mp4",
"createdAt": "2024-01-27T14:59:28.553Z",
"updatedAt": "2024-01-27T14:59:28.553Z",
"userId": "dc5761a5-5517-4602-ab4b-89779479061c"
}
]
}
{
"success": true,
"videos": [
{
"id": "ae30367c-fab7-41cd-981a-06e5d0dcd1ea",
"title": "Dancing Penguin Party",
"description": "Penguins having a dance party in Antarctica.",
"credits": "Credits: DJ Penguin on the turntables",
"isPublic": true,
"videoUrl": "https://www.funnyvideos.com/dancing-penguins.mp4",
"createdAt": "2024-01-27T17:26:45.994Z",
"updatedAt": "2024-01-27T17:26:45.994Z",
"userId": "529cce16-d219-4d27-b0b4-858b6a26b9a6"
}
]
}
- Request Headers:
Authorization: Bearer <token>
{
"content": "nice Video, thanks 4 sharing."
}
{
"success": true,
"message": "Comment created successfully",
"data": {
"id": "73ed8739-baec-4906-96f7-d2a6baa823ed",
"userId": "1af0f145-0560-4a6d-8dca-e6f82f07ac50",
"videoId": "093ebeb6-6931-413a-b316-f98fbed7fad6",
"content": "nice Video, thanks 4 sharing.",
"updatedAt": "2024-01-27T18:16:39.855Z",
"createdAt": "2024-01-27T18:16:39.855Z"
}
}
- Request Headers:
Authorization: Bearer <token>
{
"success": true,
"message": "Video liked/unliked successfully"
}
- Request Headers:
Authorization: Bearer <token>
{
"success": true,
"videos": [
{
"id": "4c8a7783-60fe-4967-a49e-423414e99a3a",
"title": "Cats Dancing Ballet",
"description": "Adorable cats showing off their ballet skills.",
"credits": "Credits: Choreography by Whiskers, Music by Meowzart",
"isPublic": true,
"videoUrl": "https://www.funnyvideos.com/cats-ballet.mp4",
"createdAt": "2024-01-27T14:58:51.958Z",
"updatedAt": "2024-01-27T14:58:51.958Z",
"likeCount": "3"
},
{
"id": "e9101d0f-5579-4ae8-aef9-05c358001e5c",
"title": "Dancing Penguin Party",
"description": "Penguins having a dance party in Antarctica.",
"credits": "Credits: DJ Penguin on the turntables",
"isPublic": true,
"videoUrl": "https://www.funnyvideos.com/dancing-penguins.mp4",
"createdAt": "2024-01-27T14:59:50.930Z",
"updatedAt": "2024-01-27T14:59:50.930Z",
"likeCount": "3"
},
{
"id": "f7b271ac-b63d-4e43-8f43-64608105e28e",
"title": "Epic Fail Compilation",
"description": "A compilation of hilarious fails from around the world.",
"credits": "Credits: None, because no one wants to claim these fails!",
"isPublic": false,
"videoUrl": "https://www.funnyvideos.com/epic-fail.mp4",
"createdAt": "2024-01-27T14:59:07.127Z",
"updatedAt": "2024-01-27T14:59:07.127Z",
"likeCount": "2"
},
{
"id": "4787445e-44d2-4a19-8437-6364d0221955",
"title": "Baby Laughing at Ripping Paper",
"description": "A baby's uncontrollable laughter at the sound of ripping paper.",
"credits": "Credits: Happy Baby Productions",
"isPublic": true,
"videoUrl": "https://www.funnyvideos.com/baby-laughing.mp4",
"createdAt": "2024-01-27T14:59:12.941Z",
"updatedAt": "2024-01-27T14:59:12.941Z",
"likeCount": "2"
},
{
"id": "a7ea4a13-362d-4b24-a6d0-8e946e1dab31",
"title": "Squirrel Olympics",
"description": "Squirrels showcasing their amazing acrobatic skills.",
"credits": "Credits: Squirrel Athletics Association",
"isPublic": false,
"videoUrl": "https://www.funnyvideos.com/squirrel-olympics.mp4",
"createdAt": "2024-01-27T14:59:28.553Z",
"updatedAt": "2024-01-27T14:59:28.553Z",
"likeCount": "1"
}
]
}