Giter Club home page Giter Club logo

clinic's Introduction

Clinic node

Structure:

  clinic
    |_ public
        |_ __tests__
        |_ docs
        |_ postman
    |_ src
        |_ app
            |_ config
                  |_ > database.js
            |_ controllers
                  |_ > ruleController.js
            |_ models
                  |_ > Rule.js
        |_ database
              |_ > rules.json
        |_ > app.js
        |_ > routes.js
        |_ > server.js

Docs:

  1. PostMan ( https://documenter.getpostman.com/view/9357385/SzKZsbor )
  2. PostMan Collection ( public/postman/Clinic.postman_collection.json )
  3. docs
  4. Code Coverage ( -tests-/coverage/lcov-report/index.html )

Setting up local environment:

  1. Install Yarn;
  2. Using terminal, navigate to the folder where the project was cloned and run:
    git clone https://github.com/k2madureira/clinic.git
  3. Using terminal, access the clinic folder and Run yarn install, to download all necessary dependencies;
  4. Using terminal run yarn start, to start the server on port 3334;
  5. For testing, the insomnia software is recommended;
  6. To perform the unit test yarn test

Tests:

  • Jest
  • Code coverage

code formatter / Extensions:

  • Eslint (Airbnb)
  • Eslint (Visual Studio Code - Extension)
  • Prettier
  • EditorConfig (Visual Studio Code - Extension)

Endpoints:

Number Type Route Definition
1 Get / List All rules
1.1 Get /rules List All rules
2 Post /rules/type Create a new Rule
3 Get /rules/period List All rules in a period
4 Delete /rules/5 Delete rule by ID

Exemples:

  1. http://localhost:3334/ or http://localhost:3334/rules (get)
Response
[{
  "id": 1,
  "type": "daily",
  "date": null,
  "days": [],
  "hours": [
     {
     "start": "08:00",
     "end": "10:05"
     }
  }]

  1. http://localhost:3334/rules/daily (post)

Conditions :

  • If days is empty and date is filled it is considered a specific rule. That is, registration of a specific day;
  • If days and date is empty, is considered a daily rule;
  • If date empty, is considered a weekly rule;
  • If a specific day has already been registered. A time check is performed for the addition of a new time.
req.query
	http://localhost:3334/rules/daily
	type: daily
	types = ['specific', 'daily', 'weekly']

Exemples req.body (JSON)
  1. Daily
     {
	"days": [],
	"date_start": "2020-03-05 13:00:00",
	"date_end": "2020-03-05 14:05:00"
     }
  1. Weekly
     {
	"days": ["Sun","Mon"],
	"date_start": "2020-03-05 09:00:00",
	"date_end": "2020-03-05 10:00:00"
     }
  1. Specific
     {
	"days": [],
	"date_start": "2020-03-05 17:00:00",
	"date_end": "2020-03-05 18:00:00"
     }
Responses
  1. Daily
   {
  	"menssage": "Successfully updated rule!",
	"update":
            [{
	      "id": 1,
	      "type": "daily",
	      "date": null,
	      "days": [],
	      "hours": [
		{
		  "start": "13:00",
		  "end": "14:05"
	    }]
    }
  1. Weekly
   {
  	"menssage": "Successfully updated rule!",
	"update":
            [{
	      "id": 2,
	      "type": "Weekly",
	      "date": null,
	      "days": ["Sun", "Mon"],
	      "hours": [
		{
		  "start": "09:00",
		  "end": "10:00"
	    }]
    }
  1. Specific
   {
  	"menssage": "Successfully updated rule!",
	"update":
            [{
	      "id": 1,
	      "type": "daily",
	      "date": "2020-03-05",
	      "days": [],
	      "hours": [
		{
		  "start": "12:40",
		  "end": "13:20"
	        },
		{
		  "start": "17:00",
		  "end": "18:00"
	        }
	    ]
    }

  1. http://localhost:3334/period (post)
  • This route receives two dates for the verification of the rules registered for the chosen days.
req.body (JSON)
   {
	"since":"2019-11-01",
	"until":"2019-11-13"
   }
Response
[
  {
    "id": 2,
    "type": "specific",
    "date": "01-11-2019",
    "days": [],
    "hours": [
      {
        "start": "14:20",
        "end": "15:05"
      },
      {
        "start": "08:20",
        "end": "10:05"
      }
    ]
  },
  {
    "id": 4,
    "type": "specific",
    "date": "10-11-2019",
    "days": [],
    "hours": [
      {
        "start": "08:20",
        "end": "10:05"
      }
    ]
  },
  {
    "id": 5,
    "type": "specific",
    "date": "09-11-2019",
    "days": [],
    "hours": [
      {
        "start": "08:20",
        "end": "10:05"
      }
    ]
  }
]
  1. http://localhost:3334/rules/5 (delete)
Res
	true

req.query
	http://localhost:3334/rules/5
	"id": 5

clinic's People

Contributors

k2madureira avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.