mkrotel14 / todo-node-app

A simple ToDo API with test validation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ToDo App

App Routes

User Routes

/POST

To create a new User you need to use the /users/new route passing a JSON as body of the requisition containing the required field. Returns a UserSchema, eg:
REQUEST

  
    {
      "firstName": "John",
      "lastName": "Wick",
      "username": "johnwick",
      "email": "john.wick@email.com",
      "password": "ilovemydog"
    }
  

RESPONSE
  
    {
      "todo": [],
      "_id": "5e6497e7bb5e856ac0eba795",
      "firstName": "John",
      "lastName": "Wick",
      "username": "johnwick",
      "email": "john.wick@email.com",
      "password": "$2b$10$dbCcGTwSHdLRaX46bpvkTOnff9OfmAffDQKCS.P2ozUemBOAuzeo6",
      "createdAt": "2020-03-08T06:53:00.096Z",
      "__v": 0
    }
  

/PUT

To update a existing User you need to use the /users/edit route passing a JSON as body of the requisition containing the user_id as required. Returns a UserSchema, eg:
REQUEST

  
    {
      "user_id": "5e6497e7bb5e856ac0eba795",
      "password": "dontkillmydog"
    }
  

RESPONSE
  
    {
      "todo": [],
      "_id": "5e6497e7bb5e856ac0eba795",
      "firstName": "John",
      "lastName": "Wick",
      "username": "johnwick",
      "email": "john.wick@email.com",
      "password": "$2b$10$8l/8JCZQrtIoka8UDQWbZOGdOi.D5MkaQSGWMib8YoJ0pLcXjqiB2",
      "createdAt": "2020-03-08T06:53:00.096Z",
      "__v": 0,
      "updatedAt": "2020-03-08T06:54:32.476Z"
    }
  

You can update the firstName, lastName and password fileds at the moment.

/DELETE

To delete a existing User you need to use the /users/delete route passing a JSON as body of the requisition containing the user_id as required, eg:

  
    {
      "user_id": "5e6497e7bb5e856ac0eba795"
    }
  

This may delete all the Todos related to the User


ToDo Routes

/GET

To get all the Todos for you user you need to use the /todo/?user_id=USER_ID&finished=(true,false). Returns a TodoSchema, eg:
RESPONSE

  
    [{
      "finished": false,
      "_id": "5e6497eebb5e856ac0eba796",
      "content": "Avenge my dog's death",
      "user": "5e6497e7bb5e856ac0eba795",
      "todoAt": "2020-03-15T00:00:00.000Z"
      "createdAt": "2020-03-08T06:59:58.047Z",
      "__v": 0
    }]
  

/POST

To create a new Todo you need to use the /todo/new route passing a JSON as body of the requisition containing the required field. Returns a array of TodoSchema, eg:
REQUEST

  
    {
      "content": "Avenge my dog",
      "user_id": "5e6497e7bb5e856ac0eba795"
    }
  

RESPONSE
  
    [{
      "finished": false,
      "_id": "5e649813ec5c906b53435e31",
      "content": "Avenge my dog's death",
      "user": "5e6497e7bb5e856ac0eba795",
      "createdAt": "2020-03-08T07:00:35.230Z",
      "__v": 0
    }]
  

/PUT

To update a existing Todo you need to use the /todo/edit route passing a JSON as body of the requisition containing the required field. Returns a array of TodoSchema, eg:
REQUEST

  
    {
      "content": "My dog was avenged",
      "user_id": "5e6497e7bb5e856ac0eba795"
    }
  

RESPONSE
  
    [{
      "finished": false,
      "_id": "5e649813ec5c906b53435e31",
      "content": "Avenge my dog's death",
      "user": "5e6497e7bb5e856ac0eba795",
      "createdAt": "2020-03-08T07:00:35.230Z",
      "__v": 0
    }]
  

About

A simple ToDo API with test validation


Languages

Language:JavaScript 75.6%Language:Gherkin 24.4%