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
- 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
S/N | VERBS | API ENDPOINTS | ACTION |
---|---|---|---|
1 | POST | .../api/v1/todos | Create a todo |
2 | GET | .../api/v1/todos | Get all todos |
3 | GET | .../api/v1/todos/:id | Get a single todo |
4 | PUT | .../api/v1/todos/:id | Update a todo |
5 | DELETE | .../api/v1/todos/:id | Delete a todo |
// 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"
}
}