Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/p-e-g-a-h/todoapp_mongoose_api

Simple CRUD API For Todo App
https://github.com/p-e-g-a-h/todoapp_mongoose_api

express javascript mocha mongodb mongoose nodejs nodemon supertest

Last synced: 9 days ago
JSON representation

Simple CRUD API For Todo App

Awesome Lists containing this project

README

        

# Todo App mongoose API

### Installation

1. Clone repository:
```
git clone https://github.com/p-e-g-a-h/todoapp_mongoose_api.git
```
2. Navigate to project directory:
```
cd todoapp_mongoose_api
```
3. Install dependencies:
```
npm install
```
4. Configure your MongoDB connection by updating server/config/config.js file.

5. Start server:
```
npm run dev
```

### API Routes

#### Create Todo and Get All Todos
* URL: `/api/todos`
* Method: `GET`, `POST`
* Request Body (POST):
```
{
"text": "Your todo text here"
}
```
* Response (POST):
```
{
"_id": "todoId",
"text": "Your todo text here",
"completed": false,
"completedAt": null
}
```
* Response (GET):
```
[
{
"_id": "todoId",
"text": "Todo 1",
"completed": false,
"completedAt": null
},
{
"_id": "todoId",
"text": "Todo 2",
"completed": false,
"completedAt": null
},
// ...
]
```
#### Get, Update, or Delete Todo by ID
* URL: `/api/todos/:id`
* Method: `GET`, `PATCH`, `DELETE`
* Request Body (PATCH):
```
{
"text": "update todo text",
"completed": true,
}
```
* Response (PATCH):
```
{
// old todo
"_id": "todoId",
"text": "Todo text",
"completed": false,
"completedAt": null
}
```
* Response (GET/DELETE):
```
{
"_id": "todoId",
"text": "Todo text",
"completed": false,
"completedAt": null
}
```