shaolinmkz / global-todo-be

Global todo

Home Page:https://global-todo.herokuapp.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Global Todo

global todo

Just a simple global todo app

Deploy To

Heroku

Installation

After cloning this repo, cd into it and on your command line run npm install to install the dependencies

git clone <GIT_REPO_URL> && cd global-todo-be && npm install

Environment

  • Create an .env file in the root directory and provide the values as specified below
PORT = 4040;
DATABASE_URL = "<MONGODB_URL>";
NODE_ENV = "development";
  • Use npm run start:dev to start the app
npm run start:dev

ENDPOINTS

S/NVERBSAPI ENDPOINTSACTION
1POST .../api/v1/todos Create a todo
2GET .../api/v1/todos Get all todos
3GET .../api/v1/todos/:id Get a single todo
4PUT .../api/v1/todos/:id Update a todo
5DELETE .../api/v1/todos/:id Delete a todo

SAMPLES

// GET (Fetch all todos)
// http://localhost:4040/api/v1/todos

// Response
{
  "method": "GET",
  "status": 200,
  "data": {
    "todos": [
      {
        "_id": "6074b121d5730cb7bc7178be",
        "userId": "1",
        "todoText": "Do some workout",
        "completed": false,
        "createdAt": "2021-04-12T20:44:17.782Z",
        "updatedAt": "2021-04-12T20:44:17.782Z",
      }
    ],
    "message": "Todos fetched successfully"
  }
}
// GET (Fetch a todo)
// http://localhost:4040/api/v1/todos/6074b121d5730cb7bc7178be

// Response
{
  "method": "GET",
  "status": 200,
  "data": {
    "todo": {
      "_id": "6074b121d5730cb7bc7178be",
      "userId": "1",
      "todoText": "Do some workout",
      "completed": false,
      "createdAt": "2021-04-12T20:44:17.782Z",
      "updatedAt": "2021-04-12T20:44:17.782Z",
    },
    "message": "Fetched todo successfully"
  }
}
// POST (Create a todo)
// http://localhost:4040/api/v1/todos

// Request
{
   "todoText": "Wash dishes again",
}

// Response
{
    "method": "POST",
    "status": 201,
    "data": {
        "todo": {
            "_id": "6074e6d2fcf5e02dc7c9260f",
            "userId": "1",
            "todoText": "Wash dishes again",
            "completed": false,
            "createdAt": "2021-04-13T00:33:22.576Z",
            "updatedAt": "2021-04-13T00:33:22.576Z",
        },
        "message": "Todo created successfully"
    }
}
// PUT
// http://localhost:4040/api/v1/todos/6074e6d2fcf5e02dc7c9260f

// Request
{
  "todoText": "Wash dishes again and again",
  "completed": true
}

// Response
{
    "method": "POST",
    "status": 201,
    "data": {
        "todo": {
            "_id": "6074e6d2fcf5e02dc7c9260f",
            "userId": "1",
            "todoText": "Wash dishes again and again",
            "completed": true,
            "createdAt": "2021-04-13T00:33:22.576Z",
            "updatedAt": "2021-04-13T00:33:22.576Z",
        },
        "message": "Todo updated successfully"
    }
}
// DELETE
// http://localhost:4040/api/v1/todos/6074e6d2fcf5e02dc7c9260f

// Response
{
  "method": "DELETE",
  "status": 200,
  "data": {
    "message": "Todo deleted successfully"
  }
}

About

Global todo

https://global-todo.herokuapp.com


Languages

Language:JavaScript 99.7%Language:Shell 0.3%