Messages

File Name : messages.js File Path : /server/routes/messages.js This route is used to handle user's chat (messages) related queries. For example: fetching favourite users and messages, fetching specific user messages, loading more messages etc

get
Fetch Users and Messages

/api/messages/usersMessages
Fetches the users's chat list (named as Favourites) of users and messages
Request
Response
Request
Headers
Authorization
required
string
Authentication Token
Response
200: OK
{
success: true,
data: [
{
text,
image,
location,
createdAt,
senderId,
receiverId,
}
. . .
. . .
]
}
or
{
success: true,
message: 'No favourite users',
data: null
}

get
Fetch Specific User Messages

/api/messages/?id=${_id}
Request
Response
Request
Headers
Authorization
required
string
Authentication Token
Response
200: OK
{
success: true,
data: {
_id,
profileUrl,
fname,
lname,
messages: [
{
text,
image,
location,
createdAt,
senderId,
receiverId,
}
. . .
. . .
]
}
}

get
Load More Messages

/api/messages/loadMoreMessages
this loads the messages when user scrolls for older messages. initially only 20 messages are loaded.
Request
Response
Request
Headers
msgBody
required
object
msgBody contains length (messages length), userId, receiverId.
Authorization
required
string
Authentication Token
Response
200: OK
{
messages : [
{
text,
image,
location,
createdAt,
senderId,
receiverId,
}
. . .
. . .
]
}