This API is used for managing conversations between users. It allows creating new conversations, sending messages, fetching messages, and fetching conversations.
The base URL for all endpoints is http://localhost:3001/api.
Creates a new conversation between two users.
Body parameters:
user1(string): The ID of the first user.user2(string): The ID of the second user.
Returns the MongoDB _id of the created or existing conversation.
Sends a message in a conversation.
Body parameters:
conversationId(string): The ID of the conversation.user(string): The ID of the user sending the message.message(string): The content of the message.
Returns a status message indicating whether the message was sent or the conversation was not found.
Fetches the last 10 messages from a conversation.
Path parameters:
conversationId(string): The ID of the conversation.
Returns an array of the last 10 messages in the conversation, or a status message if the conversation was not found.
Fetches all conversations involving a specific user.
Path parameters:
userId(string): The ID of the user.
Returns an array of objects, each containing the ID of a conversation and the last message in that conversation, or a status message if no conversations were found.
In case of an error, the API will return a JSON object with a status property containing a description of the error.