A successful response from the server will look like this:
{
"status": "OK",
"message": "Message for the developer",
"data": {
"All the data from server will be here"
}
}
An error response from the server will look like this:
{
"status": "error",
"error": "Error Message for the developer",
}
Note: You can use the response functions peovided in the
utils/responseCode.utils.js
file to send the response from the server.
The following properties of every endpoint will be descibed in this file:
- Method: GET | POST | PATCH | DELETE
- Authorized: (Authentication is required or not for this route) True | False
- Verified: (Account with Email verified is required or not for this route) True | False
- Request Parameters: (Requet-Body to be sent along with the request, for POST | PATCH | DELETE methods)
- Query Parameters: (Query Parameters available in GET requests to manipulate the response from the server)
- Success Status Code: (Status Code of a successful response) 2xx
- Response Data: (The format of data which is expected from the server with a successful response)
-
URL: /api/auth/register
-
Method: POST
-
Request Body:
- username: String
- password: String
- email: String
- name: String
-
Success Status Code: 201
-
Response Data:
{ "status": 'OK', "message": "User Registered Successfully", "data": { "username": String, "email": String, "name": String, "id": String, "token": String }, }
-
URL: /api/auth/login
-
Method: POST
-
Request Body:
- email: String
- password: String
-
Success Status Code: 200
-
Response Data:
{ "status": 'OK', "message": "User Logged In Successfully", "data": { "username": String, "email": String, "name": String, "id": String, "token": String }, }
-
URL: /api/auth/logout
-
Method: POST
-
Authorized: True
-
Success Status Code: 200
-
Response Data:
{ "status": 'OK', "message": "User Logged Out Successfully", "data": null, }
-
URL: /api/workspace/create
-
Method: POST
-
Authorized: True
-
Request Body:
- name: String
- description: String
- workspaceId: String -> This is like username for workspace
-
Success Status Code: 201
-
Response Data:
{ "status": 'OK', "message": "Workspace Created Successfully", "data": { "name": String, "description": String, "workspaceId": String, "id": String, }, }
-
URL: /api/workspace/update/:id -> MongooDB ID for workspace
-
Method: PUT
-
Authorized: True
-
Request Body:
- name: String So needed to verify that the user is the creator of the workspace
- description: String
- workspaceId: String -> This is like username for workspace
-
Success Status Code: 200
-
Response Data:
{ "status": 'OK', "message": "Workspace Updated Successfully", "data": { "name": String, "description": String, "workspaceId": String, "id": String, }, }
-
URL: /api/workspace/delete/:id -> MongooDB ID for workspace
-
Method: DELETE
-
Authorized: True
-
Success Status Code: 200
-
Response Data:
{ "status": 'OK', "message": "Workspace Deleted Successfully", "data": null, }
-
URL: /api/workspace/get
-
Method: GET
-
Authorized: True
-
Success Status Code: 200
-
Response Data:
{ "status": 'OK', "message": "Workspaces Found", "data": [ { "name": String, "description": String, "workspaceId": String, "id": String, "channels": [ { "name": String, "description": String, "id": String, }, ], }, ] }
-
URL: /api/channel/create/in/:id -> MongooDB ID for workspace
-
Method: POST
-
Authorized: True
-
Request Body:
- name: String
- description: String
- type: String -> This contains the values defined in enums > chanelType.enums.js
-
Success Status Code: 201
-
Response Data:
{ "status": 'OK', "message": "Channel Created Successfully", "data": { "name": String, "description": String, "workspaceId": String, "id": String, }, }
-
URL: /api/channel/update/:id -> MongooDB ID for channel
-
Method: PUT
-
Authorized: True
-
Request Body:
- name: String
- description: String
-
Success Status Code: 200
-
Response Data:
{ "status": 'OK', "message": "Channel Updated Successfully", "data": { "name": String, "description": String, "workspaceId": String, "id": String, }, }
-
URL: /api/channel/delete/:id -> MongooDB ID for channel
-
Method: DELETE
-
Authorized: True
-
Success Status Code: 200
-
Response Data:
{ "status": 'OK', "message": "Channel Deleted Successfully", "data": null, }
-
URL: /api/channel/get/:workspaceId
-
Method: GET
-
Authorized: True
-
Success Status Code: 200
-
Response Data:
{ "status": 'OK', "message": "Channels Found", "data": [ { "name": String, "description": String, "workspaceId": String, "id": String, }, ] }
-
URL: /api/channel/addUser/:id
-
Method: POST
-
Authorized: True
-
Request Body:
- userId: String
- role: String
-
Success Status Code: 201
-
Response Data:
{ "status": 'OK', "message": "User Added to Channel Successfully", "data": { "name": String, "description": String, "workspaceId": String, "id": String, }, }
-
URL: /api/channel/removeUser/:id
-
Method: DELETE
-
Authorized: True
-
Request Body:
- userId: String
-
Success Status Code: 200
-
Response Data:
{ "status": 'OK', "message": "User Removed from Channel Successfully", "data": null, }
-
URL: /api/channel/getUsers/:id
-
Method: GET
-
Authorized: True
-
Success Status Code: 200
-
Response Data:
{ "status": 'OK', "message": "Users Found", "data": [ { "username": String, "email": String, "name": String, "id": String, }, ] }
-
URL: /api/subchannel/create/in/:id -> MongooDB ID for channel
-
Method: POST
-
Authorized: True
-
Request Body:
- name: String
- description: String
-
Success Status Code: 201
-
Response Data:
{ "status": 'OK', "message": "SubChannel Created Successfully for channel {channel name}", "data": { "name": String, "description": String, "id": String, }, }
-
URL: /api/subchannel/update/:id -> MongooDB ID for subchannel
-
Method: PUT
-
Authorized: True
-
Request Body:
- name: String
- description: String
-
Success Status Code: 200
-
Response Data:
{ "status": 'OK', "message": "SubChannel Updated Successfully", "data": { "name": String, "description": String, "id": String, }, }
-
URL: /api/subchannel/delete/:id -> MongooDB ID for subchannel
-
Method: DELETE
-
Authorized: True
-
Success Status Code: 200
-
Response Data:
{ "status": 'OK', "message": "SubChannel Deleted Successfully", "data": null, }
-
URL: /api/subchannel/get/:id -> MongooDB ID for channel
-
Method: GET
-
Authorized: True
-
Success Status Code: 200
-
Response Data:
{ "status": 'OK', "message": "SubChannels Found", "data": [ { "name": String, "description": String, "id": String, }, ] }
-
URL: /api/message/send/in/:id -> MongooDB ID for subchannel
-
Method: POST
-
Authorized: True
-
Request Body:
- message: String
- attagements: Array of file objects
-
Success Status Code: 201
-
Response Data:
{ "status": 'OK', "message": "Message Sent Successfully", "data": { "id": String, -> Message ID }, }
-
URL: /api/message/getAll/in/:id -> MongooDB ID for subchannel
-
Method: GET
-
Authorized: True
-
Query Parameters:
- limit: Number
- skip: Number
-
Success Status Code: 200
-
Response Data:
{ "status": 'OK', "message": "Messages Found", "data": [ { "message": String, "attagements": Array of strings, "id": String, -> Message ID "createdAt": Date, "updatedAt": Date, "sender": { "profilePicUrl": String, "name": String, "id": String, }, }, ] }
-
URL: /api/user/query
-
Method: GET
-
Authorized: True
-
Success Status Code: 200
-
Response Data:
-
Query Parameters: -> Assume that the email or username is provided in partial form
- email: String and the server will return all the users which match the query
- username: String select the one whose either username or email matches the query
-
Response Data:
{ "status": 'OK', "message": "User Found", "data": [ { "username": String, "email": String, "name": String, "profilePicUrl": String, "id": String, }, ] }
-
URL: /api/user/add/pic
-
Method: POST
-
Authorized: True
-
Request Body:
- profilePic: File
-
Success Status Code: 200
-
Response Data:
{ "status": 'OK', "message": "Profile Picture Added Successfully", "data": { "profilePicUrl": String, }, }