Clinic
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
- PostMan ( https://documenter.getpostman.com/view/9357385/SzKZsbor )
- PostMan Collection ( public/postman/Clinic.postman_collection.json )
- docs
- Code Coverage ( -tests-/coverage/lcov-report/index.html )
Setting up local environment:
- Install Yarn;
- Using terminal, navigate to the folder where the project was cloned and run:
git clone https://github.com/k2madureira/clinic.git
- Using terminal, access the clinic folder and Run yarn install, to download all necessary dependencies;
- Using terminal run yarn start, to start the server on port 3334;
- For testing, the insomnia software is recommended;
- To perform the unit test yarn test
code formatter / Extensions:
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 |
- http://localhost:3334/ or http://localhost:3334/rules (get)
[{
"id": 1,
"type": "daily",
"date": null,
"days": [],
"hours": [
{
"start": "08:00",
"end": "10:05"
}
}]
- http://localhost:3334/rules/daily (post)
- 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.
http://localhost:3334/rules/daily
type: daily
types = ['specific', 'daily', 'weekly']
- Daily
{
"days": [],
"date_start": "2020-03-05 13:00:00",
"date_end": "2020-03-05 14:05:00"
}
- Weekly
{
"days": ["Sun","Mon"],
"date_start": "2020-03-05 09:00:00",
"date_end": "2020-03-05 10:00:00"
}
- Specific
{
"days": [],
"date_start": "2020-03-05 17:00:00",
"date_end": "2020-03-05 18:00:00"
}
- Daily
{
"menssage": "Successfully updated rule!",
"update":
[{
"id": 1,
"type": "daily",
"date": null,
"days": [],
"hours": [
{
"start": "13:00",
"end": "14:05"
}]
}
- Weekly
{
"menssage": "Successfully updated rule!",
"update":
[{
"id": 2,
"type": "Weekly",
"date": null,
"days": ["Sun", "Mon"],
"hours": [
{
"start": "09:00",
"end": "10:00"
}]
}
- 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"
}
]
}
- http://localhost:3334/period (post)
- This route receives two dates for the verification of the rules registered for the chosen days.
{
"since":"2019-11-01",
"until":"2019-11-13"
}
[
{
"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"
}
]
}
]
- http://localhost:3334/rules/5 (delete)
http://localhost:3334/rules/5
"id": 5