This project mainly aims to provide APIs for Task Management Application. Designed using conventional MVC pattern. Used mongoose for cloud database. Used jest and supertest for testing the controllers. Codes for testing each controller separately are available in test folder.
- API to create task
- API to get all tasks
- API to get tasks by status(
pending,progress,done,) - API to update task
- API to update the status of the task separately
- API to delete task
- Unit test codes for all the controllers
After successfully cloning my GitHub Repo, type the below command in integrated terminal in the same directory as that of the project.
npm i- Create a
.envfile in the root directory. - Add the following configuration:
PORT=4500
MONGODB_URI=your_mongodb_connection_string- Run the server
npm start- Or for development:
npm run dev- Server will run at: http://localhost:4500
POST /api/createTask- Provide description,status of the task in json format.
- Status is optional. If not passed, default value of pending is assigned.
| Parameter | Type | Description |
|---|---|---|
description |
string |
Required. task description |
status |
string |
any 1 of (pending,progress,done) |
GET /api/getTask- Status can be passed as query to fetch tasks based on status.
- If status is not passed, then all the tasks will be retrieved.
| Parameter | Type | Description |
|---|---|---|
status |
string |
any 1 of (pending,progress,done) |
PUT /api/updateTask- Provide the id of the task as query.
| Query | Type | Description |
|---|---|---|
id |
string |
Required Task Id |
- Provide all the updated fields in the form of json.
| Parameter | Type | Description |
|---|---|---|
description |
string |
Required task description |
status |
string |
any 1 of (pending,progress,done) |
PUT /api/updateTask- Provide the id and new status of the task as query.
| Query | Type | Description |
|---|---|---|
id |
string |
Required Task Id |
status |
string |
any 1 of (pending,progress,done) |
DELETE /api/deleteTask- Provide the id of the task as query.
| Query | Type | Description |
|---|---|---|
id |
string |
Required Task Id |
- Install Jest (if not already installed):
npm install jest --save-dev- Install Supertest (if not already installed):
npm install supertest- Update the
package.jsonfile - runInBand is an additional command used to run tests parallely.
"scripts": {
"test": "jest --runInBand"
}
- Run the tests:
npm test-
Tests are located in the
__tests__folder, including: -
Unit tests for
createTasklogic is present in__tests__\createTask.test.js. -
Unit tests for
getTasklogic is present in__tests__\getTask.test.js. -
Unit tests for
updateTasklogic is present in__tests__\updateTask.test.js. -
Unit tests for
deleteTasklogic is present in__tests__\deleteTask.test.js.
- express: Fast and minimal web framework.
- mongoose: MongoDB object modeling.
- dotenv: Load environment variables.
- jest: JavaScript testing framework for unit testing.
- supertest: For testing HTTP requests.





