This is an open source API for common social network features. It comes complete with Authentication, Messaging, and Posting, with Stories coming in the future.
To run this on a local machine, PostgreSQL must be started. This was tested with PostgreSQL 13, but that version is not necessarily a requirement. Once Postgres is running, the database can be set up - this can be done with the setup.sql
file in this repository. An environment variable file .env
must also be created to define at least the following variables. Five are used to connect to the PostgreSQL database, and one is used in JSON web token generation.
PGUSER=user
PGHOST=localhost
PGDATABASE=social_network
PGPASSWORD=password1
PGPORT=5432
TOKEN_SECRET=somesecret
SENDGRID_API_KEY=sendgridapikey # Optional - For sending emails with SendGrid
APP_DOMAIN_NAME=https://www.this-service-url.com # Optional - For generating links to the web app.
Once the database and environment variables are set up, the app can be run with npm run dev
. A production build can be generated with npm run build
, then it can be run with npm start
. After setting everything up, it is recommended to run npm test
to ensure everything is working.
This app can be run in docker as long as the required environment variables listed above are set. A port must also be mapped.
docker run -p 8080:8080 social-network-backend
If you're connecting to the database through a docker network, make sure the PGHOST environment variable is the name of the container running the database.
This API is the core of a three-part system to spin up a social network. If the frontend and database repositories are cloned in addition to this one, you can use Docker Compose to spin them all up properly. Follow the configuration instructions for each on setting up environment variables, then run the following command.Note that each folder on the drive must be named appropriately so the containers can communicate. By default, the container names are postgres
, backend
, and frontend
.
docker-compose up
Accounts on this social network require a unique email address, unique username, first name, last name, and a password of at least four characters. After signing up, the account must be activated before it is allowed to participate in the network.
GET /auth/ping
A token must be present in the Authorization header. This endpoint will return whether or not the token is still valid.
{
message: 'Authenticated',
user: {
id: '1234',
firstName: 'John',
lastName: 'Champion',
username: 'appdevjohn',
email: '[email protected]',
profilePicURL: 'http://localhost:8080/uploads/image.png'
}
}
PUT /auth/login
Gets an Authorization token for the client.
Field | Location | Required | Description |
---|---|---|---|
body | true | The email address for the account. | |
password | body | true | The password the account. |
{
user: {
id: '1234',
firstName: 'John',
lastName: 'Champion',
username: 'appdevjohn',
email: '[email protected]',
profilePicURL: 'http://localhost:8080/uploads/image.png'
}
token: 'eyJhbGciOiJIUzI1NiI...',
activated: true,
message: 'You are now logged in.'
}
POST /auth/signup
Creates a new account.
Field | Location | Required | Description |
---|---|---|---|
firstName | body | true | The first name of the user. |
lastName | body | true | The last name of the user. |
username | body | true | The username for the account. Must be alphanumeric and unique. |
body | true | The email address the account. | |
password | body | true | The password for the account. Must be at least four characters. |
{
user: {
id: '1234',
firstName: 'John',
lastName: 'Champion',
username: 'appdevjohn',
email: '[email protected]',
profilePicURL: null
}
token: 'eyJhbGciOiJIUzI1NiI...',
activated: false,
message: 'Find our activation email to activate your account.'
}
POST /auth/confirm-email
Activates the account using a code sent the the account holder's inbox.
Field | Location | Required | Description |
---|---|---|---|
activateToken | body | true | The activation token sent to the user's inbox. Needed to activate the account. |
{
activated: true,
token: 'eyJhbGciOiJIUzI1NiI...',
message: 'You can now sign into the account.'
}
PUT /auth/resend-verification-code
Sends a new email with a new account activation code to the user.
{
message: 'A new verification code has been emailed.'
}
PUT /auth/request-new-password
Sends a password reset link to an email address.
Field | Location | Required | Description |
---|---|---|---|
body | true | The email account to send the password reset link. |
{
status: 'Reset Email Sent',
message: 'A password reset email has been sent to the account holder.'
}
PUT /auth/reset-password
Resets an account's password.
Field | Location | Required | Description |
---|---|---|---|
resetPasswordToken | body | true | The password reset token that was embedded in the link emailed to the user. |
newPassword | body | true | The new account password. |
{
status: 'Password Reset',
message: 'You can now sign into the account.'
}
DELETE /auth/delete-account
Deletes a user account. The account to be deleted will be that which is embedded in the authentication token.
{
user: {
id: '1234',
firstName: 'John',
lastName: 'Champion',
username: 'appdevjohn',
email: '[email protected]',
profilePicURL: 'http://localhost:8080/uploads/image.png'
},
message: 'User account has been deleted.'
}
User endpoints are distinct from auth endpoints in that they deal with personal information about the account, such as the name and username.
GET /users/:userId
Returns data for a user.
Field | Location | Required | Description |
---|---|---|---|
userId | param | true | The ID of the user to get. |
{
user: {
id: '1234',
firstName: 'John',
lastName: 'Champion',
email: '[email protected]',
username: 'appdevjohn',
profilePicURL: 'http://localhost:8080/uploads/image.png'
}
}
PUT /users/edit
Edits a user's profile info.
Field | Location | Required | Description |
---|---|---|---|
userId | body | true | The ID of the user to update. |
firstName | body | false | The new first name for the user. |
lastName | body | false | The new last name for the user. |
username | body | false | The new username for the user. |
{
user: {
id: '1234',
firstName: 'John',
lastName: 'Champion',
email: '[email protected]',
username: 'appdevjohn',
profilePicURL: 'http://localhost:8080/uploads/image.png'
}
}
PUT /users/edit-image
Edits a user's profile picture.
Field | Location | Required | Description |
---|---|---|---|
image | file | true | The image to be set as the profile picture. |
{
user: {
id: '1234',
firstName: 'John',
lastName: 'Champion',
email: '[email protected]',
username: 'appdevjohn',
profilePicURL: 'http://localhost:8080/uploads/image.png'
}
}
A group is a community of users. Users can share posts within groups, and only other members of that group can view the posts. Posts can only be sent from within a group. Group members can see who else is in the group and send them direct messages.
GET /groups/validate/:groupName
Returns whether or not a group name references a real group.
Field | Location | Required | Description |
---|---|---|---|
groupName | param | true | The name of the group. |
{
groupName: 'Nintendo Gamers',
valid: true
}
GET /groups
Returns all of the groups the user is currently involved in.
{
groups: [
{
id: '1234',
name: 'Nintendo Gamers',
description: 'Group for Nintendo and gaming enthusiasts.',
approved: true,
admin: false,
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
}
]
}
GET /groups/:groupId
Returns details about the group, the members in the group, and the users requesting to join.
Field | Location | Required | Description |
---|---|---|---|
groupId | param | true | The ID of the group. |
{
group: {
id: '1234',
name: 'Nintendo Gamers',
description: 'Group for Nintendo and gaming enthusiasts.',
approved: true,
admin: false,
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
},
members: [
{
id: '1234',
firstName: 'John',
lastName: 'Champion',
username: 'appdevjohn',
email: '[email protected]',
admin: true,
profilePicURL: 'http://localhost:8080/uploads/image.png'
}
],
requests: [
{
id: '5678',
firstName: 'James',
lastName: 'Hamil',
username: 'jameshamil',
email: '[email protected]',
admin: false,
profilePicURL: 'http://localhost:8080/uploads/image2.png'
}
]
}
POST /groups/new
Creates a new group.
Field | Location | Required | Description |
---|---|---|---|
name | body | true | The name of the group. Must be unique. |
description | body | true | A group description. |
{
group: {
id: '1234',
name: 'Nintendo Gamers',
description: 'Group for Nintendo and gaming enthusiasts.',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
},
members: [
{
id: '1234',
firstName: 'John',
lastName: 'Champion',
username: 'appdevjohn',
email: '[email protected]',
admin: false,
profilePicURL: 'http://localhost:8080/uploads/image.png'
}
]
}
PUT /groups/edit
Edits the details of a group.
Field | Location | Required | Description |
---|---|---|---|
id | body | true | The ID of the group to modify. |
name | body | false | The updated name of the group. Must be unique. |
description | body | false | The updated description of the group. |
{
group: {
id: '1234',
name: 'Nintendo Gamers',
description: 'Group for Nintendo and gaming enthusiasts.',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
},
members: [
{
id: '1234',
firstName: 'John',
lastName: 'Champion',
username: 'appdevjohn',
email: '[email protected]',
admin: false,
profilePicURL: 'http://localhost:8080/uploads/image.png'
}
]
}
DELETE /groups/delete/:groupId
Deletes a group and all of the posts in that group.
Field | Location | Required | Description |
---|---|---|---|
groupId | param | true | The ID of the group to delete. |
{
group: {
id: '1234',
name: 'Nintendo Gamers',
description: 'Group for Nintendo and gaming enthusiasts.',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
}
}
POST /groups/:groupId/add-user
Adds a user to a group. Users can either be added pre-approved or in a pending-approval state.
Field | Location | Required | Description |
---|---|---|---|
groupId | param | true | The ID of the group which to add the user. |
userId | body | true | The ID of the user which to add to the group. |
approved | body | true | Boolean value representing whether this user is approved immediately. If false, they will have to be approved by an admin. |
{
group: {
id: '1234',
name: 'Nintendo Gamers',
approved: true,
admin: false,
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
}
}
POST /groups/:groupId/remove-user
Removes a user from a group. If user was pending approval to join the group, that request will be cancelled.
Field | Location | Required | Description |
---|---|---|---|
groupId | param | true | The ID of the group which to remove the user. |
userId | body | true | The ID of the user which to remove from the group. |
{
removed: true,
group: {
id: '1234',
name: 'Nintendo Gamers',
description: 'Group for Nintendo and gaming enthusiasts.',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
},
userId: '1234'
}
POST /groups/:groupId/requests/:userId/approve
Removes a user from a group. If user was pending approval to join the group, that request will be cancelled.
Field | Location | Required | Description |
---|---|---|---|
groupId | param | true | The ID of the group which to add the user. |
userId | param | true | The ID of the user which to add to the group. |
{
group: {
id: '1234',
name: 'Nintendo Gamers',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
},
userId: '1234'
}
PUT /groups/:groupId/set-admin
Sets the admin status of a user within a group to true or false. There must always be at least one admin user in a group.
Field | Location | Required | Description |
---|---|---|---|
groupId | param | true | The ID of the group which to add the user. |
userId | body | true | The ID of the user which to add to the group. |
admin | body | true | Whether or not this user is an admin. |
{
group: {
id: '1234',
name: 'Nintendo Gamers',
description: 'Group for Nintendo and gaming enthusiasts.',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
},
userId: '1234',
admin: true
}
GET /groups/:groupId/requests
Returns the complete list of requests to join a group.
Field | Location | Required | Description |
---|---|---|---|
groupId | param | true | The ID of the group which to get join requests. |
{
group: {
id: '1234',
name: 'Nintendo Gamers',
description: 'Group for Nintendo and gaming enthusiasts.',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
},
users: [
{
id: '1234',
firstName: 'John',
lastName: 'Champion',
username: 'appdevjohn',
email: '[email protected]',
profilePicURL: 'http://localhost:8080/uploads/image.png'
}
]
}
GET /groups/:groupId/admins
Returns the list of admins in a group.
Field | Location | Required | Description |
---|---|---|---|
groupId | param | true | The ID of the group which to find the admins. |
{
group: {
id: '1234',
name: 'Nintendo Gamers',
description: 'Group for Nintendo and gaming enthusiasts.',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
},
users: [
{
id: '1234',
firstName: 'John',
lastName: 'Champion',
username: 'appdevjohn',
email: '[email protected]',
profilePicURL: 'http://localhost:8080/uploads/image.png'
}
]
}
GET /groups/:groupId/members
Returns the complete list of members in a group.
Field | Location | Required | Description |
---|---|---|---|
groupId | param | true | The ID of the group which to get the members. |
{
group: {
id: '1234',
name: 'Nintendo Gamers',
description: 'Group for Nintendo and gaming enthusiasts.',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
},
users: [
{
id: '1234',
firstName: 'John',
lastName: 'Champion',
username: 'appdevjohn',
email: '[email protected]',
admin: false,
profilePicURL: 'http://localhost:8080/uploads/image.png'
}
]
}
A post contains a title and content, which can be text, media, or both. Users who are authorized to see the post can comment on the post.
GET /posts/?groupId=asdf
Returns all posts from a group.
Field | Location | Required | Description |
---|---|---|---|
groupId | query | true | The ID of the group from which to query posts. |
{
posts: [
{
userId: '1234',
groupId: '5678',
title: 'What are your predictions for WWDC 2021?',
text: 'I bet they'll announce a new MacBook Pro.',
media: null,
userData: {
firstName: 'John',
lastName: 'Champion',
email: '[email protected]',
username: 'appdevjohn',
profilePicURL: 'http://localhost:8080/uploads/image.png'
},
id: '7654',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
}
]
}
GET /posts/:postId
Returns data for a specific post.
Field | Location | Required | Description |
---|---|---|---|
postId | param | true | The ID of the post. |
{
post: {
userId: '1234',
groupId: '5678',
title: 'What are your predictions for WWDC 2021?',
text: 'I bet they'll announce a new MacBook Pro.',
media: null,
userData: {
firstName: 'John',
lastName: 'Champion',
email: '[email protected]',
username: 'appdevjohn',
profilePicURL: 'http://localhost:8080/uploads/image.png'
},
id: '7654',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
},
messages: [
{
userId: '1234',
convoId: null,
postId: '6543',
content: 'Chances of that are ~50/50',
type: 'text',
userData: {
firstName: 'John',
lastName: 'Champion',
email: '[email protected]',
username: 'appdevjohn',
profilePicURL: 'http://localhost:8080/uploads/image.png'
},
id: '2345',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
}
]
}
POST /posts/new
Creates a new post.
Field | Location | Required | Description |
---|---|---|---|
groupId | body | true | The ID of the group where this post should go. |
title | body | true | The title of the post. |
text | body | false | The text content of the post. |
{
post: {
userId: '1234',
groupId: '5678',
title: 'What are your predictions for WWDC 2021?',
text: 'I bet they'll announce a new MacBook Pro.',
media: null,
userData: {
firstName: 'John',
lastName: 'Champion',
email: '[email protected]',
username: 'appdevjohn',
profilePicURL: 'http://localhost:8080/uploads/image.png'
},
id: '7654',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
}
}
PUT /posts/edit
Edits an existing post.
Field | Location | Required | Description |
---|---|---|---|
postId | body | true | The ID of post to be edited. |
title | body | true | The title of the post. |
text | body | false | The text content of the post. |
{
post: {
userId: '1234',
groupId: '5678',
title: 'What are your predictions for WWDC 2021?',
text: 'I bet they'll announce a new MacBook Pro.',
media: null,
userData: {
firstName: 'John',
lastName: 'Champion',
email: '[email protected]',
username: 'appdevjohn',
profilePicURL: 'http://localhost:8080/uploads/image.png'
},
id: '7654',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
}
}
DELETE /posts/:postId
Edits an existing post.
Field | Location | Required | Description |
---|---|---|---|
postId | param | true | The ID of post to be deleted. |
{
post: {
userId: '1234',
groupId: '5678',
title: 'What are your predictions for WWDC 2021?',
text: 'I bet they'll announce a new MacBook Pro.',
media: null,
userData: {
firstName: 'John',
lastName: 'Champion',
email: '[email protected]',
username: 'appdevjohn',
profilePicURL: 'http://localhost:8080/uploads/image.png'
},
id: '7654',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
}
}
GET /posts/:postId/messages
Gets the current list of messages sent in a post.
Field | Location | Required | Description |
---|---|---|---|
postId | param | true | The ID of post where messages are to be retrieved. |
{
messages: [
{
userId: '1234',
convoId: null,
postId: '6543',
content: 'Chances of that are ~50/50',
type: 'text',
userData: {
firstName: 'John',
lastName: 'Champion',
email: '[email protected]',
username: 'appdevjohn',
profilePicURL: 'http://localhost:8080/uploads/image.png'
},
id: '2345',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
}
]
}
POST /posts/add-message
Sends a message from within a post.
Field | Location | Required | Description |
---|---|---|---|
postId | body | true | The ID of post where the message should be sent. |
content | body | true, if no attachment | The text content of the message. |
attachment | file | true, if no text content | The file to be uploaded as the message content. |
{
message: {
userId: '1234',
convoId: null,
postId: '6543',
content: 'Chances of that are ~50/50',
type: 'text',
userData: {
firstName: 'John',
lastName: 'Champion',
email: '[email protected]',
username: 'appdevjohn',
profilePicURL: 'http://localhost:8080/uploads/image.png'
},
id: '2345',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
}
}
POST /posts/delete-message
Deletes a message from a post.
Field | Location | Required | Description |
---|---|---|---|
messageId | body | true | The ID of message to be deleted. |
{
message: {
userId: '1234',
convoId: null,
postId: '6543',
content: 'Chances of that are ~50/50',
type: 'text',
userData: {
firstName: 'John',
lastName: 'Champion',
email: '[email protected]',
username: 'appdevjohn',
profilePicURL: 'http://localhost:8080/uploads/image.png'
},
id: '2345',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
}
}
Messaging works exaclty like one might expect. Multi-media messages are sent in a thread with one or more people. Conversations do not exist within groups; rather, users can start conversations with anyone on the platform.
GET /validate-recipient/:username
Returns whether or not a user exists, given a username.
Field | Location | Required | Description |
---|---|---|---|
username | param | true | The username of the user. |
{
username: 'appdevjohn',
valid: true
}
GET /conversations
Returns the conversations which the user is involved in. Also returns the last message that was sent so a preview or snippet might displayed.
{
conversations: [
{
name: 'Pokemangos',
id: '1234',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z',
lastReadMessageId: '5678',
snippet: {
userId: '1234',
convoId: '1234,
postId: null,
content: 'Hey folks',
type: 'text',
userData: {
firstName: 'John',
lastName: 'Champion',
email: '[email protected]',
username: 'appdevjohn',
profilePicURL: 'http://localhost:8080/uploads/image.png'
},
id: '5678',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
}
}
]
}
GET /conversations/:convoId
Returns data for a conversation.
Field | Location | Required | Description |
---|---|---|---|
convoId | param | true | The ID conversation to get. |
{
conversation: {
name: 'Pokemangos',
id: '1234',
lastReadMessageId: '5678',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
},
members: [
{
id: '1234',
firstName: 'John',
lastName: 'Champion',
username: 'appdevjohn',
email: '[email protected]',
profilePicURL: 'http://localhost:8080/uploads/image.png'
}
],
messages [
{
userId: '1234',
convoId: '1234,
postId: null,
content: 'Hey folks',
type: 'text',
userData: {
firstName: 'John',
lastName: 'Champion',
email: '[email protected]',
username: 'appdevjohn',
profilePicURL: 'http://localhost:8080/uploads/image.png'
},
id: '5678',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
}
]
}
GET /conversations/:convoId/messages
Returns only message data for a conversation.
Field | Location | Required | Description |
---|---|---|---|
convoId | param | true | The ID conversation to get. |
{
messages [
{
userId: '1234',
convoId: '1234,
postId: null,
content: 'Hey folks',
type: 'text',
userData: {
firstName: 'John',
lastName: 'Champion',
email: '[email protected]',
username: 'appdevjohn',
profilePicURL: 'http://localhost:8080/uploads/image.png'
},
id: '5678',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
}
]
}
GET /messages/:messageId
Returns a single message.
Field | Location | Required | Description |
---|---|---|---|
messageId | param | true | The ID of the message. |
{
message: {
userId: '1234',
convoId: '1234,
postId: null,
content: 'Hey folks',
type: 'text',
userData: {
firstName: 'John',
lastName: 'Champion',
email: '[email protected]',
username: 'appdevjohn',
profilePicURL: 'http://localhost:8080/uploads/image.png'
},
id: '5678',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
}
}
POST /conversations/new
Creates a new conversation.
Field | Location | Required | Description |
---|---|---|---|
name | body | true | The name of the conversation. |
members | body | true | An array of usernames to add as members. (JSON.stringify) |
{
conversation: {
name: 'Pokemangos',
id: '1234',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
},
members: [
{
id: '1234',
firstName: 'John',
lastName: 'Champion',
username: 'appdevjohn',
email: '[email protected]',
profilePicURL: 'http://localhost:8080/uploads/image.png'
}
]
}
PUT /conversations/edit
Creates a new conversation.
Field | Location | Required | Description |
---|---|---|---|
convoId | body | true | The ID of the conversation. |
newName | body | true | The updated name of the conversation |
{
conversation: {
name: 'Pokemangos',
id: '1234',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
},
members: [
{
id: '1234',
firstName: 'John',
lastName: 'Champion',
username: 'appdevjohn',
email: '[email protected]',
profilePicURL: 'http://localhost:8080/uploads/image.png'
}
]
}
PUT /conversations/leave
Removes this user from the conversation. Even if this user created the conversation, it cannot be deleted until everyone leaves.
Field | Location | Required | Description |
---|---|---|---|
convoId | body | true | The ID of the conversation. |
{
conversation: {
name: 'Pokemangos',
id: '1234',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
}
}
POST /messages/new
Sends a message in a conversation.
Field | Location | Required | Description |
---|---|---|---|
convoId | body | true | The ID of the conversation to send a message. |
content | body | true, if no attachment | The text content of the message. |
attachment | file | true, if no text content | The file to be uploaded as the message content. |
{
message: {
userId: '1234',
convoId: '1234,
postId: null,
content: 'Hey folks',
type: 'text',
userData: {
firstName: 'John',
lastName: 'Champion',
email: '[email protected]',
username: 'appdevjohn',
profilePicURL: 'http://localhost:8080/uploads/image.png'
},
id: '5678',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
}
}
DELETE /messages/delete
Deletes a message from a conversation.
Field | Location | Required | Description |
---|---|---|---|
messageId | body | true | The ID of the message to delete. |
{
message: {
userId: '1234',
convoId: '1234,
postId: null,
content: 'Hey folks',
type: 'text',
userData: {
firstName: 'John',
lastName: 'Champion',
email: '[email protected]',
username: 'appdevjohn',
profilePicURL: 'http://localhost:8080/uploads/image.png'
},
id: '5678',
createdAt: '2021-06-10T18:16:50.085Z',
updatedAt: '2021-06-10T18:16:50.085Z'
}
}
PUT /conversations/update-last-read-message
Updates the ID of the last read message of a conversation for a user.
Field | Location | Required | Description |
---|---|---|---|
convoId | body | true | The ID of the conversation of the message. |
messageId | body | true | The ID of the message. |
{
messageId: '1234'
}