This project is a RESTful API developed using Node.js, Express.js, and NPM packages. The API allows users to perform CRUD operations (Create, Read, Update, and Delete) on tasks. Each task has a title, description, and completion status flag. The API can be tested using Postman or Curl.
GET /tasks
: Retrieve all tasks.GET /tasks/:id
: Retrieve a single task by its ID.POST /tasks
: Create a new task.PUT /tasks/:id
: Update an existing task by its ID.DELETE /tasks/:id
: Delete a task by its ID.GET /tasks?completed=true
: Retrieve all tasks filtered by completed status.GET /tasks?sortBy=createdOn
: Retrieve all tasks sorted by createdOn in ascending order .GET /tasks?sortBy=-createdOn
: Retrieve all tasks sorted by createdOn in descending order.GET /tasks/priority/:level
: Retrieve all tasks filtered by priority.
-
Clone the repository:
git clone <repository_url>
-
Install dependencies:
npm install
-
Start the server:
npm start
-
Access the API routes using the following URL:
http://localhost:3000/tasks
-
Test the API using Postman or Curl:
curl --location 'http://localhost:3000/tasks'
NOTE: Above GET /tasks API supports filter by field completed and sorting on field createdOn in query param. Example URIs are as follows:
curl --location 'http://localhost:3000/tasks?completed=true&sortBy=createdOn' // filter by completed status, sort by createdOn in ascending order
curl --location 'http://localhost:3000/tasks?completed=true&sortBy=-createdOn' // filter by completed status, sort by createdOn in descending order. Emphasis on the negative sign for descending order
curl --location 'http://localhost:3000/tasks' \
--data '{
"id": 5,
"title": "Task new",
"description": "Task new description",
"completed": false
}'
NOTE: By Default, tasks are assigned a priority of low out of high, medium and low
curl --location 'http://localhost:3000/tasks/5'
curl --location 'http://localhost:3000/tasks/priority/low'
curl --location 'http://localhost:3000/tasks/5' \
--data '{
"id": 5,
"title": "Task new",
"description": "Task new description",
"completed": true
}'
curl --location 'http://localhost:3000/tasks/5' \
--data '{
"priority": "high"
}'
curl --location 'http://localhost:3000/tasks/5'
Contributions are welcome! If you would like to contribute to this project, please fork the repository and submit a pull request.
For any further inquiries or feedback, please contact [[email protected]].