This route is responsible for registering a new user by creating a new user document in the database. It validates the input data, checks for existing users with the same email, and generates a JWT token upon successful registration.
The request body should contain the following fields:
username
: The desired username for the new user.email
: The unique email address for the new user.password
: The password for the new user.
The response includes a success message and a JWT token, which is stored in a cookie for future authentication.
This route is responsible for authenticating a user by checking the provided credentials against the database. It validates the input data, checks for existing users, and generates a JWT token upon successful authentication.
The request body should contain the following fields:
username
: The username of the user attempting to log in.password
: The password provided by the user.
The response includes a success message and a JWT token, which is stored in a cookie for future authentication. If the credentials are invalid, an error message is returned.
This route is responsible for following a channel by adding the channel ID to a user's followedChannels array in the database. It validates the input data, checks for existing users and followed channels, and updates the user document accordingly.
The request should include the user's authentication token inside cookie or header to identify the user. The request body should contain the following fields:
channelId
: The ID of the channel to follow.
The response includes a success message.
The route handles errors by returning appropriate HTTP status codes and error messages. For example, if the user is not found or the channel is already being followed, a 404 status code and an error message will be returned.
This route is responsible for retrieving a single channel's details from the database. It validates the provided channel ID, checks for the channel's activity, and returns the channel's details along with the username of the user who created the channel.
The request URL should contain the channel ID as a parameter.
The response includes the channel's details, the username of the user who created the channel, and additional metadata such as the channel's online status and stream URL.
The route handles errors by returning appropriate HTTP status codes and error messages. For example, if the channel is not found or the user is not found, a 404 status code and an error message will be returned.
This route is responsible for retrieving all active channels from the database. It fetches the details of each active channel, including the channel ID, title, and avatar URL. Additionally, it retrieves the username of the user who created each channel.
The response includes an array of channel objects, each containing the channel details, the username of the channel creator, and metadata such as the channel's online status.
The route handles errors by returning appropriate HTTP status codes and error messages. If no active channels are found, a 404 status code and an error message will be returned.
This route is responsible for retrieving all active channels from the database. It fetches the details of each active channel, including the channel ID, title, and avatar URL. Additionally, it retrieves the username of the user who created each channel.
The response includes an array of channel objects, each containing the channel details, the username of the channel creator, and metadata such as the channel's online status.
The route handles errors by returning appropriate HTTP status codes and error messages. If no active channels are found, a 404 status code and an error message will be returned.
This route is responsible for retrieving the channels that a user is following. It fetches the list of followed channels for the authenticated user from the database.
The request should include the user's authentication token inside cookie or header to identify the user.
The response includes an array of followed channels belonging to the user.
The route handles errors by returning appropriate HTTP status codes and error messages. If the user is not found, a 404 status code and an error message will be returned.
This route is responsible for retrieving the settings of the user's channel. It fetches the channel settings, including the channel ID, username, title, description, avatar URL, and stream key, from the database.
The request should include the user's authentication token inside cookie or header to identify the user.
The response includes the settings of the user's channel, such as the channel ID, username, title, description, avatar URL, and stream key.
The route handles errors by returning appropriate HTTP status codes and error messages. If the user or channel settings are not found, a 404 status code and an error message will be returned.
This route is responsible for updating the settings of the user's channel. It allows users to modify their channel details, such as username, description, title, and avatar URL, in the database.
The request should include the user's authentication token inside cookie or header to identify the user. The request body should contain the following fields to update the channel settings:
username
: The new username for the channel.description
: The updated description of the channel.title
: The new title for the channel.avatarURL
: The new avatar URL for the channel.
The response includes the updated channel settings, such as the channel's title, description, avatar URL, and status.
The route handles errors by returning appropriate HTTP status codes and error messages. If the user or channel settings are not found, a 404 status code and an error message will be returned.
This route is responsible for updating the user's password. It allows users to change their password by providing the current password and a new password, which will be encrypted and stored securely in the database.
The request should include the user's authentication token inside cookie or header to identify the user. The request body should contain the following fields to update the password:
password
: The current password for authentication.newPassword
: The new password to be set.
The response includes a success message confirming the password change and the updated user data.
The route handles errors by returning appropriate HTTP status codes and error messages. If the user is not found, the current password is incorrect, or there are any other issues, appropriate error messages will be returned.