NAV Navbar
javascript
  • Introduction
  • Development
  • Installation
  • Authentication
  • Api Summary
  • Users
  • Todos
  • Errors
  • Introduction

    Worklist is a simple todo list application that allows users to create lists of tasks to be completed and track their progress on these tasks.

    Development

    The application was developed with NodeJs and Express is used for routing. The MongoDb database was used with mongoose as the ODM

    Installation

    1. Ensure you have NodeJs and Mongodb installed
    2. Clone the repository https://github.com/jchinonso/WorkList
    3. Change your directory cd WorkList
    4. Install all dependencies npm install
    5. Start the app npm start for development Or
    6. Use [postman] to consume the API

    Authentication

    CheckList uses (email and password) to login to allow access to the API protected routes. On registering or login, a token is generated. CheckList expect the token to be included in the header as x-access-token: token. All API requests to the server are stated below

    Api Summary

    Below are the API endpoints and their functions

    EndPoint Functionality
    POST /api/v1/user/signin Logs a user in.
    POST /api/v1/user/signup Create a new user.
    GET /api/v1/user Get all users.
    POST /api/v1/todo Creates a new todo.
    POST /api/v1/todo/:todoId/task Add task to todo.
    POST /api/v1/todo/:todoId/collaborator Add collaborators to todo.
    PUT /api/v1/todo/task/:taskId Update a task.

    Users

    Sign up User

    Request

    Response

    Request:

     {
       "username": "okoro",
        "name": "releku ami",
        "email": "pythago@gmail.com",
        "password": "password"
      },
    
    

    Response:

     {
        "message": "Successfully Signed Up",
        "userObject": {
            "userId": "5a0c1707833187d957fca4d5",
            "username": "okoro",
            "name": "releku ami",
            "email": "pythago@gmail.com",
            "imageUrl": "http://res.cloudinary.com/dbczzmftw/image/upload/v1509127904/pojdk9ajmdgase3esgg2.png"
        },
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6Im9rb3JvIiwidXNlcklkIjoiNWEwYzE3MDc4MzMxODdkOTU3ZmNhNGQ1IiwibmFtZSI6InJlbGVrdSBhbWkiLCJlbWFpbCI6InB5dGhhZ29AZ21haWwuY29tIiwiaW1hZ2VVcmwiOiJodHRwOi8vcmVzLmNsb3VkaW5hcnkuY29tL2RiY3p6bWZ0dy9pbWFnZS91cGxvYWQvdjE1MDkxMjc5MDQvcG9qZGs5YWptZGdhc2UzZXNnZzIucG5nIiwiaWF0IjoxNTEwNzQxNzY3LCJleHAiOjE1MTA4MjgxNjd9.vmwlaxkBpoVJiPcNl2yEzBpZ18forFNNU0ze7rfpyPo"
    }
    
    

    Sign in User

    Request

    Response

    Request:

     {
        "email": "pythago@gmail.com",
        "password": "password",
     },
    
    

    Response:

    {
        "message": "Successfully login!",
        "userObject": {
            "userId": "5a0c1707833187d957fca4d5",
            "username": "okoro",
            "name": "releku ami",
            "email": "pythago@gmail.com",
            "imageUrl": "http://res.cloudinary.com/dbczzmftw/image/upload/v1509127904/pojdk9ajmdgase3esgg2.png"
        },
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6Im9rb3JvIiwidXNlcklkIjoiNWEwYzE3MDc4MzMxODdkOTU3ZmNhNGQ1IiwibmFtZSI6InJlbGVrdSBhbWkiLCJlbWFpbCI6InB5dGhhZ29AZ21haWwuY29tIiwiaW1hZ2VVcmwiOiJodHRwOi8vcmVzLmNsb3VkaW5hcnkuY29tL2RiY3p6bWZ0dy9pbWFnZS91cGxvYWQvdjE1MDkxMjc5MDQvcG9qZGs5YWptZGdhc2UzZXNnZzIucG5nIiwiaWF0IjoxNTEwNzQxODM2LCJleHAiOjE1MTA4MjgyMzZ9.iigrt7wfOHGPPGzigxG3hHCCgC7db6PN4DULgos5TXw"
    }
    
    

    Todos

    Create Todo

    Request

    Response

    Request:

     {
        "text": "Studying"
     },
    
    

    Response:

    {
        "todo": {
            "_id": "59fffb068ae3e0b2cd070d1f",
            "text": "Studying",
            "creator": {
                "_id": "59fc257d46900b201d9c1315",
                "username": "johnnyparagon",
                "name": "johnson chinonso"
            },
            "__v": 1,
            "tasks": [
                "59fffb278ae3e0b2cd070d20"
            ],
            "collaborators": [
                "59fc257d46900b201d9c1315"
            ]
        }
    }
    
    

    Retrieve all Todos

    Request

    Response

    Response:

    {
        "newTodo": [
            {
                "_id": "59fffb068ae3e0b2cd070d1f",
                "text": "Studying",
                "creator": {
                    "_id": "59fc257d46900b201d9c1315",
                    "username": "johnnyparagon",
                    "name": "johnson chinonso"
                },
                "__v": 1,
                "tasks": [
                    {
                        "_id": "59fffb278ae3e0b2cd070d20",
                        "text": "newtask",
                        "__v": 0,
                        "createdAt": "2017-11-06T06:01:33.825Z",
                        "priority": "normal",
                        "completed": false
                    }
                ],
                "collaborators": [
                    {
                        "_id": "59fc257d46900b201d9c1315",
                        "username": "johnnyparagon",
                        "name": "johnson chinonso"
                    }
                ]
            },
            {
                "_id": "5a002db64a7bfcc2a7908552",
                "text": "newtask",
                "creator": {
                    "_id": "59fc257d46900b201d9c1315",
                    "username": "johnnyparagon",
                    "name": "johnson chinonso"
                },
                "__v": 0,
                "tasks": [],
                "collaborators": [
                    {
                        "_id": "59fc257d46900b201d9c1315",
                        "username": "johnnyparagon",
                        "name": "johnson chinonso"
                    }
                ]
            },
            {
                "_id": "5a002df54a7bfcc2a7908553",
                "text": "Meditation",
                "creator": {
                    "_id": "59fc257d46900b201d9c1315",
                    "username": "johnnyparagon",
                    "name": "johnson chinonso"
                },
                "__v": 0,
                "tasks": [],
                "collaborators": [
                    {
                        "_id": "59fc257d46900b201d9c1315",
                        "username": "johnnyparagon",
                        "name": "johnson chinonso"
                    }
                ]
            }
        ]
    }
    

    Add Collaborators to Todo

    Request

    Response

    Request:

     {
        "username": "macdoe",
      },
    
    

    Response:

    {
      "message": "Collaborator have be successfully added"
    }
    
    

    Add task to todo

    Request

    Response

    Request:

     {
        "text": "newTask",
        "priority": "normal"
      },
    
    

    Response:

    {
        "task": {
            "__v": 0,
            "text": "newtask",
            "_id": "5a002fb54a7bfcc2a7908554",
            "createdAt": "2017-11-06T09:32:29.179Z",
            "priority": "normal",
            "completed": false
        }
    }
    
    

    Retrieve all Tasks that belongs to Todo

    Request

    Response

    Response:

    {
        "tasks": [
            {
                "_id": "59fffb278ae3e0b2cd070d20",
                "text": "newtask",
                "__v": 0,
                "createdAt": "2017-11-06T06:01:33.825Z",
                "priority": "normal",
                "completed": false
            },
            {
                "_id": "5a002fb54a7bfcc2a7908554",
                "text": "newtask",
                "__v": 0,
                "createdAt": "2017-11-06T09:32:29.179Z",
                "priority": "normal",
                "completed": false
            }
        ]
    }
    
    

    Update task

    Request

    Response

    Request:

     {
        "completed": true,
      },
    
    

    Response:

    {
        "editedTask": {
            "_id": "59fffb278ae3e0b2cd070d20",
            "completed": true,
            "__v": 0,
            "createdAt": "2017-11-06T06:01:33.825Z",
            "priority": "normal"
        }
    }
    
    

    Delete a task

    Request

    Response

    Response:

    {
        "message": "Successfully deleted"
    }
    
    

    Errors

    The PostIt API uses the following error codes:

    Error Code Meaning
    400 Bad Request -- You sent invalid url parameters.
    401 Unauthorized -- You are not authenticated or authentication fails.
    403 Forbidden -- You are not a member of the group you are trying to access
    or you tried to perform an operation that can only be done by the creator of the group.
    404 Not Found -- The specified User or Group could not be found..
    500 Internal Server Error -- We had a problem with our server. Try again later.