/node-ut

small server with basic CRUD operations demonstrating unit testing with supertest

Primary LanguageJavaScript

General instructions:

  • Run the following command to install node_modules and required packages to run the server:
yarn 
  • Run the following command to start up the server:
node app.js
  • Server runs on localhost:4000

  • Run the following command to run the unit tests

yarn test

 

Routes for the various CRUD operations

Route - GET shopping list:

  • GET localhost:4000/allList

  • Request:

Nothing sent to backend
  • Response:

{
  "data": [
    {
      "id": "123",
      "item": "Eggs",
      "checked": false
    }
  ],
  "error": null
}

 

Route - Add shopping list:

  • POST localhost:4000/addList
  • Request:

{
  "id": "1234",
  "item": "Milk",
  "checked": true
}
  • Response:

{
  "data": [
    {
      "id": "1234",
      "item": "Milk",
      "checked": true
    }
  ],
  "error": null
}

 

Route - Delete shopping list by passing in an id:

  • DELETE localhost:4000/list/:id
  • Request:

Nothing in request body
  • Response:

{
  "data": [
    {
      "id": "123",
      "item": "Eggs",
      "checked": false
    }
  ],
  "error": null
}