Submission for test assignment.
Once the repository is cloned, run npm i
from the root of the repository. Add the .env
file from the Google Drive folder linked in the email to the root of the repository.
From the root of the repository,
- Run
docker compose up -d
to start the required Docker containers. docker ps
lists themysql
container, theSTATUS
column specifies the status of this container. Ensure that this container is healthy before proceeding. This usually takes about 30s after the containers have been started.- Run
npm start
to start the server.
If you use the .env
file as is from the Google Drive folder, the APIs will be hosted at http://localhost:8000
.
This API is used to create a message.
Endpoint: /message
Request type: POST
Content-type
: application/json
Sample request:
{
"senderPrivilege": "admin",
"content": "hi there! :D"
}
Sample response:
{
"success": true,
"data": {
"id": 3
}
}
This API is used to read a message.
Endpoint: /message/:id
Request type: GET
Sample response:
{
"success": true,
"data": {
"id": 3,
"senderPrivilege": "admin",
"content": "hi there! :D",
"sentAt": "2023-05-29T07:11:59.000Z"
}
}
This API is used to update a message.
Endpoint: /message/:id
Request type: PATCH
Content-type
: application/json
Sample request:
{
"content": "heyyoooo"
}
Sample response:
{
"success": true
}
This API is used to delete a message.
Endpoint: /message/:id
Request type: DELETE
Sample response:
{
"success": true
}
This API is used to retrieve all messages. Optional URL parameters limit
and page
can be used to specify the maximum number of search results per page and the page number respectively.
Endpoint: /get-all-messages
Request type: GET
Sample respose:
{
"success": true,
"count": 5,
"next": "/all-messages?page=2&limit=2",
"previous": null,
"data": [
{
"id": 1,
"senderPrivilege": "admin",
"content": "hey man",
"sentAt": "2023-05-26T16:04:33.000Z"
},
{
"id": 2,
"senderPrivilege": "member",
"content": "hey wassup",
"sentAt": "2023-05-26T16:04:33.000Z"
}
]
}