Talks API Documentation
Content Table
1. Overview
This API was structured with the aim of being the back-end part of the Talks application, a front-end project made by Matheus Vieira (Theus).
Talks is a social network based on posts, likes and comments. Therefore, the structure of this API is based on three main CRUD (Create-Read-Update-Delete):
Some other routes and entities were necessary, due to all the possible data and relationships of these three main entities like Likes and Notifications.
These were the main technologies used in this project:
Base URL: https://localhost:3001 mudar o link pelo amor de Deus
1.1. Project Creator
2. Entity Relationship Diagram
Back to the top

3. Authentication
Back to the top
Some routes need authentication. The authentication used is the Bearer Token type.
The token is automatically generated upon user login.
Thus, to access routes with authentication, it is necessary to have a user and be logged in with the user.
Also, some routes require the user to be the owner of the post, comment, or like in order to make the request.
Read the documentation for each route to understand which authentications are required.
4. Endpoints
Back to the top
Index
1. Users
Back to endpoints index
The User object is defined as:
| Field | Type | Description |
|---|
| id | string | User's unique identifier |
| firstName | string | User first name |
| lastName | string | User last name |
| email | string | User e-mail |
| password | string | User password |
| birthdate | string | User's date of birth |
| isAdm | boolean | Defines whether a user is an administrator or not |
| isActive | boolean | Defines whether a user is active or not |
| isVerified | boolean | Defines if the user has verified the registered email or not |
| profileImage | string | User's profile photo file sent in the request |
| bio | string | A small user definition |
| createdAt | Date | User creation date |
| updatedAt | Date | User update date |
Endpoints
| Method | Route | Description |
|---|
| POST | /users | Creates a user |
| GET | /users | List all users |
| GET | /users/:userId | Lists a user using its ID as a parameter |
| PATCH | /users/validate | Update isVerified field to true |
| PATCH | /users/:userId | Updates a user using its ID as a parameter |
| DELETE | /users/:userId | Soft-deletes a user using its ID as a parameter |
POST /users
Back to endpoints index
Request:
- Authorization: None
- Content-type: application/json
Request body example
{
"firstName": "Ícarus",
"lastName": "Maximus",
"email": "max.icarus@gmail.com",
"password": "Icarus!1234",
"birthdate": "1991-06-28",
"bio": "Just a single guy"
}
Expected Response:
Status 201 - Created
{
"id": "e14d80c9-a148-4208-8aa9-354a16da7852",
"firstName": "Ícarus",
"lastName": "Maximus",
"email": "max.icarus@gmail.com",
"bio": "Just a single guy",
"birthdate": "1991-06-28T00:00:00.000Z",
"profileImage": "https://i.ibb.co/hM0XsT4/21-214439-free-high-quality-person-icon-default-profile-picture.png",
"isAdm": false,
"createdAt": "2022-09-24T17:48:08.984Z",
"updatedAt": "2022-09-24T17:48:08.984Z",
"isActive": true,
"isVerified": false
}
Error Responses:
Status 400 - Missing required field
{
"status": "Error",
"code": 400,
"message": "The bio field is mandatory",
"image": "https://http.cat/400"
}
Status 400 - Invalid data type or length
{
"status": "Error",
"code": 400,
"message": "yup error message",
"image": "https://http.cat/400"
}
Status 409 - Email already exists
{
"status": "Error",
"code": 409,
"message": "This email already exists",
"image": "https://http.cat/409"
}
GET /users
Back to endpoints index
Request:
- Authorization: Bearer Token
- Content-type: application/json
- Empty Body
Request headers
{
"authorization": "Bearer Token"
}
Expected Response:
Status 200 - OK
[
{
"id": "e14d80c9-a148-4208-8aa9-354a16da7852",
"firstName": "Ícarus",
"lastName": "Maximus",
"email": "max.icarus@gmail.com",
"bio": "Just a single guy",
"birthdate": "1991-06-28T00:00:00.000Z",
"profileImage": "https://i.ibb.co/hM0XsT4/21-214439-free-high-quality-person-icon-default-profile-picture.png",
"isAdm": false,
"createdAt": "2022-09-24T17:48:08.984Z",
"updatedAt": "2022-09-24T17:48:08.984Z",
"isActive": true,
"isVerified": false
},
...
]
Error Responses:
Status 401 - Missing authorization token
{
"status": "Error",
"code": 401,
"message": "Missing authorization token",
"image": "https://http.cat/401"
}
Status 401 - Invalid token
{
"status": "Error",
"code": 401,
"message": "Invalid token",
"image": "https://http.cat/401"
}
GET /users/:userId
Back to endpoints index
Request:
- Authorization: Bearer Token
- Content-type: application/json
- Empty Body
Request headers
{
"authorization": "Bearer Token"
}
Expected Response:
Status 200 - OK
{
"id": "e14d80c9-a148-4208-8aa9-354a16da7852",
"firstName": "Ícarus",
"lastName": "Maximus",
"email": "max.icarus@gmail.com",
"bio": "Just a single guy",
"birthdate": "1991-06-28T00:00:00.000Z",
"profileImage": "https://i.ibb.co/hM0XsT4/21-214439-free-high-quality-person-icon-default-profile-picture.png",
"isAdm": false,
"createdAt": "2022-09-24T17:48:08.984Z",
"updatedAt": "2022-09-24T17:48:08.984Z",
"isActive": true,
"isVerified": false
}
Error Responses:
Status 401 - Missing authorization token
{
"status": "Error",
"code": 401,
"message": "Missing authorization token",
"image": "https://http.cat/401"
}
Status 401 - Invalid token
{
"status": "Error",
"code": 401,
"message": "Invalid token",
"image": "https://http.cat/401"
}
Status 404 - User not found
{
"status": "Error",
"code": 404,
"message": "User not found",
"image": "https://http.cat/404"
}
Status 401 - Account is deactivated
{
"status": "Error",
"code": 401,
"message": "Account deleted, please contact customer service",
"image": "https://http.cat/401"
}
PATCH /users/validate
Back to endpoints index
Request:
- Authorization: None
- Content-type: application/json
Request body example
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6Im1hdGhldXN0aC5kZXZAZ21haWwuY29tIiwiaWQiOiJlMTRkODBjOS1hMTQ4LTQyMDgtOGFhOS0zNTRhMTZkYTE0NTkiLCJpYXQiOjE2NjQwNDE2ODgsImV4cCI6MTY2NDIxNDQ4OH0.SMx0exifh8iAIufcBjYRO3FH8k7BE0W485PtklNopNh"
}
Expected Responses:
Status 202 - Accepted
{
"message": "Email successfully validated"
}
Expected Errors:
Status 401 - Missing token
{
"status": "Error",
"code": 401,
"message": "Token is missing",
"image": "https://http.cat/401"
}
Status 401 - Invalid token
{
"status": "Error",
"code": 401,
"message": "Invalid token",
"image": "https://http.cat/401"
}
Status 404 - E-mail not registered
{
"status": "Error",
"code": 404,
"message": "Email not registered in database",
"image": "https://http.cat/404"
}
PATCH /users/:userId
Back to endpoints index
Request:
- Authorization: Bearer Token
- User must be owner of the account
- Content-type: application/json
Request headers
{
"authorization": "Bearer Token"
}
Request body example
{
"firstName": "Ikarus",
"oldPassword": "Icarus!1234"
}
- At least one field and oldPassword is required
- User will be able to update bio, birthdate, firstName, lastName, password and profileImage
Expected Responses:
Status 200 - OK
{
"id": "e14d80c9-a148-4208-8aa9-354a16da7852",
"firstName": "Ikarus",
"lastName": "Maximus",
"email": "max.icarus@gmail.com",
"bio": "Just a single guy",
"birthdate": "1991-06-28T00:00:00.000Z",
"profileImage": "https://i.ibb.co/hM0XsT4/21-214439-free-high-quality-person-icon-default-profile-picture.png",
"isAdm": false,
"createdAt": "2022-09-24T17:48:08.984Z",
"updatedAt": "2022-09-24T17:48:08.984Z",
"isActive": true,
"isVerified": false
}
Expected Errors:
Status 401 - Missing authorization token
{
"status": "Error",
"code": 401,
"message": "Missing authorization token",
"image": "https://http.cat/401"
}
Status 401 - Invalid token
{
"status": "Error",
"code": 401,
"message": "Invalid token",
"image": "https://http.cat/401"
}
Status 400 - Invalid data type or length
{
"status": "Error",
"code": 400,
"message": "yup error message",
"image": "https://http.cat/400"
}
Status 404 - User not found
{
"status": "Error",
"code": 404,
"message": "User not found",
"image": "https://http.cat/404"
}
Status 401 - Account is deactivated
{
"status": "Error",
"code": 401,
"message": "Inactive account",
"image": "https://http.cat/401"
}
Status 401 - Invalid password
{
"status": "Error",
"code": 401,
"message": "Incorrect password",
"image": "https://http.cat/401"
}
DELETE /users/:use