Skip to content

dev-rish/Task-Manager-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Task Manager API

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

Prerequisites

Installation

Install all the dependencies by running the following command from the root directory

npm install

Setup

  1. Create a folder config in the root directory of the project

  2. Create a file dev.env inside config

  3. 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

  4. Create a file test.env inside config

  5. 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

Start Project

npm run dev

Test Project

npm run test

Routes

Routes for users

  • Signup User
    /users => POST route. Provide name required, email required, password required in body.
    Set Headers
    KEY: Content-Type
    VALUE: application/json

  • Login User
    /users/login => POST route. Provide email and password 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
    • email
    • 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

Routes for tasks

  • Create Task
    /tasks => POST route. Provide String description (required) and Boolean completed (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 criteria
    • sortBy optional
      Provide createdAt:asc to get list of tasks in ascending order of their creation time or createdAt:desc to get list of tasks in descending order of their creation time
    • limit optional
      Provide Integer value. Set limit to get a given number of tasks out of total number of tasks
    • skip optional
      Provide Integer value. Set skip 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 String description or Boolean completed.
    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.

Dependencies

Development Dependencies

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published