-
- 2.1 Ports
- 2.2 User Service Schema
- 2.3 Endpoints
- 2.3.1 Login a User
- 2.3.2 Update profile picture URL
- 2.3.3 Update banner picture URL
- 2.3.4 Update profile description
- 2.3.5 Get all Users
- 2.3.6 Get User by ID
- 2.3.7 Get User by username
- 2.3.8 Get Users by multiple IDs
- 2.3.9 Delete User by ID
- 2.3.10 Check if User ID exists
- 2.3.11 Check if username exists
- 2.3.12 Check if email exists
The User Service is a RESTful API that manages user data such as creation, retrieval, updates, and deletion of user profiles. It interacts with other services to handle user-related functionalities, such as authentication and authorization.
- Service port: 8083
- Database port: 5433
The database schema includes the following tables:
CREATE TABLE users (
user_id UUID PRIMARY KEY,
username VARCHAR(255) UNIQUE NOT NULL,
email VARCHAR(255) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL,
role VARCHAR(50) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
BASE URL: /api/user
.
All calls to this service must start with the base URL. Any additional URL fields will be specified if relevant.
-
Method: POST
-
Description: Creates a new User.
-
Request Body:
{
"userId": "string",
"username": "string",
"email": "string"
}
- Response:
{
"userId": "uuid",
"username": "string",
"email": "string",
"description": "string",
"profilePictureUrl": "string",
"profileBannerUrl": "string",
"timeCreated": "2024-07-27T00:00:00Z"
}
- Response HTTP Status:
-
200 OK
– Successfully completed request. -
201 Created
– User created successfully. -
400 Bad Request
– Invalid input data.
-
-
Method: POST
-
Endpoint:
/profile-picture-url
-
Description: Updates the User's profile picture URL.
-
Request Body:
{
"userId": "string",
"profilePictureUrl": "string"
}
- Response:
{
"userId": "uuid"
}
- Response HTTP Status:
-
200 OK
– Successfully completed request. -
400 Bad Request
– Invalid input data.
-
-
Method: POST
-
Endpoint:
/banner-picture-url
-
Description: Updates the User's banner picture URL.
-
Request Body:
{
"userId": "string",
"bannerPictureUrl": "string"
}
- Response:
{
"userId": "uuid"
}
- Response HTTP Status:
-
200 OK
– Successfully completed request. -
400 Bad Request
– Invalid input data.
-
-
Method: POST
-
Endpoint:
/description
-
Description: Updates the User's profile description.
-
Request Body:
{
"userId": "string",
"description": "string"
}
- Response:
{
"userId": "uuid"
}
- Response HTTP Status:
-
200 OK
– Successfully completed request. -
400 Bad Request
– Invalid input data.
-
-
Method: GET
-
Endpoint:
/all
-
Description: Retrieves all Users from the DB.
-
Response:
[
{
"userId": "uuid",
"username": "string",
"email": "string",
"description": "string",
"profilePictureUrl": "string",
"profileBannerUrl": "string",
"timeCreated": "2024-07-27T00:00:00Z"
}
]
- Response HTTP Status:
-
200 OK
– Successfully completed request. -
400 Bad Request
– Invalid input data.
-
-
Method: GET
-
Endpoint:
/by-user-id
-
Description: Retrieves a User by its ID.
-
Query Parameters:
userId
(UUID) – The ID of the user to retrieve.
-
Response:
{
"userId": "uuid",
"username": "string",
"email": "string",
"description": "string",
"profilePictureUrl": "string",
"profileBannerUrl": "string",
"timeCreated": "2024-07-27T00:00:00Z"
}
- Response HTTP Status:
-
200 OK
– Successfully completed request. -
400 Bad Request
– Invalid input data.
-
-
Method: GET
-
Endpoint:
/by-username
-
Description: Retrieves a User by its username.
-
Query Parameters:
username
(string) – The username of the user to retrieve.
-
Response:
{
"userId": "uuid",
"username": "string",
"email": "string",
"description": "string",
"profilePictureUrl": "string",
"profileBannerUrl": "string",
"timeCreated": "2024-07-27T00:00:00Z"
}
- Response HTTP Status:
-
200 OK
– Successfully completed request. -
400 Bad Request
– Invalid input data.
-
-
Method: GET
-
Endpoint:
/list-by-user-ids
-
Description: Retrieves a Users list by their IDs.
-
Query Parameters:
userIds
(List) – The IDs of the users to retrieve.
-
Response:
[
{
"userId": "uuid",
"username": "string",
"email": "string",
"description": "string",
"profilePictureUrl": "string",
"profileBannerUrl": "string",
"timeCreated": "2024-07-27T00:00:00Z"
}
]
- Response HTTP Status:
-
200 OK
– Successfully completed request. -
400 Bad Request
– Invalid input data.
-
-
Method: DELETE
-
Endpoint:
/by-user-id
-
Description: Deletes a User by its ID.
-
Query Parameters:
userId
(UUID) – The ID of the user to delete.
-
Response:
{
"userId": "uuid"
}
- Response HTTP Status:
-
200 OK
– Successfully completed request. -
400 Bad Request
– Invalid input data.
-
-
Method: GET
-
Endpoint:
/id
-
Description: Retrieves true if the User ID exists. Otherwise retrieves false.
-
Query Parameters:
userId
(UUID) – The ID of the user to check.
-
Response:
{
"isExists": "boolean"
}
- Response HTTP Status:
-
200 OK
– Successfully completed request. -
400 Bad Request
– Invalid input data.
-
-
Method: GET
-
Endpoint:
/username
-
Description: Retrieves true if the username exists. Otherwise retrieves false.
-
Query Parameters:
username
(string) – The username of the user to check.
-
Response:
{
"isUsernameExists": "boolean"
}
- Response HTTP Status:
-
200 OK
– Successfully completed request. -
400 Bad Request
– Invalid input data.
-
-
Method: GET
-
Endpoint:
/email
-
Description: Retrieves true if the username exists. Otherwise retrieves false.
-
Query Parameters:
email
(string) – The email of the user to check.
-
Response:
{
"isEmailExists": "boolean"
}
- Response HTTP Status:
-
200 OK
– Successfully completed request. -
400 Bad Request
– Invalid input data.
-
-
400 Bad Request
– The request could not be understood or was missing required parameters. -
404 Not Found
– The specified resource could not be found. -
500 Internal Server Error
– An error occurred on the server.
- Make sure to include the
Content-Type: application/json
header in your requests.