This is simple API that enables a logged in user to manage list of tasks via HTTP Requests. The API provides functionalities like
- Create a Task
- Read a Task
- Update a Task
- Delete a Task
- Get a list of all tasks sorted by
- Creation Time (ascending or descending)
- Complete or Incomplete
- Upload Avatar Picture
- Update account details
- Delete Account
To run the API directly from server, use Postman and simply use the follwoing url with various routes as listed in the Routes sectionhttps://rish-task-manager-api.herokuapp.com/{route}
To run the API locally, read the instructions below
Install all the dependencies by running the following command from the root directory
npm install
Create a folder
configin the root directory of the projectCreate a file
dev.envinsideconfigPaste the following code inside it
PORT=3000SENDGRID_API_KEY=YOUR KEYJWT_SECRET=YOUR SECRETMONGODB_URI=mongodb://127.0.0.1:27017/task-manager-apiCreate a file
test.envinsideconfigPaste the following code inside it
PORT=3000SENDGRID_API_KEY=YOUR KEYJWT_SECRET=YOUR SECRETMONGODB_URI=mongodb://127.0.0.1:27017/task-manager-api-test
npm run dev
npm run test
Signup User
/users=> POST route. Providenamerequired,emailrequired,passwordrequired in body.
Set Headers
KEY:Content-Type
VALUE:application/jsonLogin User
/users/login=> POST route. Provideemailandpasswordin body.
Set Headers
KEY:Content-Type
VALUE:application/json
For all the following routes, set Headers
KEY: Authorization
VALUE: Bearer token
Replace token with the token value obtained after Login or Signup request
Logout User
/users/logout=> POST route. Log out from currently logged in session (from current device)Logout from All
/users/logoutAll=> POST route. Log out from all logged in sessions (from all device)Read Profile
/users/me=> GET route.Update User
/users/me=> PATCH route. Set Headers
KEY:Content-Type
VALUE:application/jsonProvide any or all of the following in the body
- name
- password
- age
Upload Avatar
/users/me/avatar=> POST route. In Postman, set Body to from-data with KEY:avatartype File and VLAUE: select a image file of size less than 1 MBDelete Avatar
/users/me/avatar=> DELETE route. Deletes avatar picture from the user's accountDelete User Account
/users/me=> DELETE route. Delete the users account and all the tasks associated with it
Create Task
/tasks=> POST route. Provide Stringdescription(required) and Booleancompleted(optional).
Set Headers
KEY:Content-Type
VALUE:application/jsonRead a Task
/tasks/:id=> GET route.idof a task is obtained while creating or updating a taskRead all Tasks
/tasks=> GET route. Simply fetch all task.Query Parameters
completedoptional
Provide Boolean value to get list of all task that match the completion criteriasortByoptional
ProvidecreatedAt:ascto get list of tasks in ascending order of their creation time orcreatedAt:descto get list of tasks in descending order of their creation timelimitoptional
Provide Integer value. Setlimitto get a given number of tasks out of total number of tasksskipoptional
Provide Integer value. Setskipto skip a given number of tasks from the top
Update Task
/tasks/:id=> PATCH route.idof a task is obtained while creating or updating a task. Provide either or both of the parameters Stringdescriptionor Booleancompleted.
Set Headers
KEY:Content-Type
VALUE:application/jsonDelete Task
/tasks/:id=> DELETE route.idof a task is obtained while creating or updating a task.