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 section https://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
config
in the root directory of the project -
Create a file
dev.env
insideconfig
-
Paste the following code inside it
PORT=3000
SENDGRID_API_KEY=
YOUR KEY
JWT_SECRET=
YOUR SECRET
MONGODB_URI=mongodb://127.0.0.1:27017/task-manager-api
-
Create a file
test.env
insideconfig
-
Paste the following code inside it
PORT=3000
SENDGRID_API_KEY=
YOUR KEY
JWT_SECRET=
YOUR SECRET
MONGODB_URI=mongodb://127.0.0.1:27017/task-manager-api-test
npm run dev
npm run test
-
Signup User
/users
=> POST route. Providename
required,email
required,password
required in body.
Set Headers
KEY:Content-Type
VALUE:application/json
-
Login User
/users/login
=> POST route. Provideemail
andpassword
in 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/json
Provide 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:avatar
type File and VLAUE: select a image file of size less than 1 MB -
Delete Avatar
/users/me/avatar
=> DELETE route. Deletes avatar picture from the user's account -
Delete 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/json
-
Read a Task
/tasks/:id
=> GET route.id
of a task is obtained while creating or updating a task -
Read all Tasks
/tasks
=> GET route. Simply fetch all task.Query Parameters
completed
optional
Provide Boolean value to get list of all task that match the completion criteriasortBy
optional
ProvidecreatedAt:asc
to get list of tasks in ascending order of their creation time orcreatedAt:desc
to get list of tasks in descending order of their creation timelimit
optional
Provide Integer value. Setlimit
to get a given number of tasks out of total number of tasksskip
optional
Provide Integer value. Setskip
to skip a given number of tasks from the top
-
Update Task
/tasks/:id
=> PATCH route.id
of a task is obtained while creating or updating a task. Provide either or both of the parameters Stringdescription
or Booleancompleted
.
Set Headers
KEY:Content-Type
VALUE:application/json
-
Delete Task
/tasks/:id
=> DELETE route.id
of a task is obtained while creating or updating a task.