Todo REST API complete with user accounts and authentication. This api was the final challenge from Udemy Course.
This was developed focus on TDD.
Demo : https://node-rest-api-todo.glitch.me
- Node.js
- Express
- MongoDB
- Mongoose
- Mocha
- REST API Design
- Clean Arquitecture
- Clean Code
- JWT Authentication
- Version control with Git
$ git clone git@github.com:AFGM/node-terminal-weather.git
$ cd node-terminal-weather
$ npm install
Write command above to create config.json.
$ echo "{\"development\": {\"PORT\": 3000, \"MONGODB_URI\": \"mongodb://localhost:27017/todoapp\",\"JWT_SECRET\": \"ultrasecret\"}}" >> server/config/config.json
$ npm start
Here's an example of how HTTP verbs map to create, read, update, delete operations in a particular context:
HTTP METHOD | POST | GET | PATCH | DELETE |
---|---|---|---|---|
/todos | Create new todo | List all todos from user | - | - |
/todos/:id | - | List specific todo | Update todo | Delete todo |
/users | Create user | - | - | - |
/users/me | - | List user informations | - | - |
/users/login | Login | - | - | - |
/users/me/token | - | - | - | Logout |
Error handling acording with REST API standards
Code | Description |
---|---|
200 |
The request has succeeded |
400 |
The request could not be understood by the server due to malformed syntax |
401 |
The request requires user authentication. The response must include a WWW-Authenticate header field |
404 |
The server has not found anything matching the Request-URI |
Request body:
{
"email": "test@gmail.com",
"password": "default"
}
Request body:
{
"text": "Sample todo"
}
Response body:
{
"todo": {
"_id": "5aa587d1cfce06ecbef0a7ae",
"text": "Sample Todo2",
"_creator": "5aa58675cfce06ecbef0a7a7",
"__v": 0,
"completedAt": null,
"completed": false
}
}