An API for the doctors of a Hospital which has been allocated by the government for testing and quarantine + well being of COVID-19 patients applied with unit testings.
URL : http://localhost:8000/api/{routes}
- Register Doctor => (using: Username and Password).
- Login Doctor using passport-jwt-Strategy which returns a jwt-token.
- Jwt-Tokento will be used to access(authorize) protected routes.
- After logging-in the doctor can do various things such as :
- Register patient => (using: Name and Phone No)
- Generate a report of patient
- View all reports of a particular patient
- Display reports by particular status [Negative, Travelled-Quarantine, Symptoms-Quarantine, Positive-Admit].
- Generation of report(protecte by jwt) : A doctor has to enter enter the status for a particular patient and can generate the report according to it.
- View all reports of a patient(protected by jwt) : Only doctor can view reports of a patient.
- View all the reports of particular status(protected by jwt) : Only doctor can view the reports.
- /doctors/register → with username and password.
- /doctors/login → returns the JWT to be used.
- /patients/register → with mobile No and name..
- /patients/:id/create_report.
- /patients/:id/all_reports → List all the reports of a patient oldest to latest
- /reports/:status → List all the reports of all the patients filtered by a specific status
.
├── config
├── mongoose.js
├── passport-local-strategy.js
├── controllers
├── api
├── doctor_api_controller.js
├── patient_api_controller.js
├── report_api_controller.js
├── models
├── doctor.js
├── patient.js
├── report.js
├── routes
├── api
├── index.js
├── doctors.js
├── patients.js
├── reports.js
├── index.js
├── test
├── patientAllReportTest.js
├── patientRegisterTest.js
├── patientReportReportTest.js
├── index.js
├── package.json
├── .gitignore
- Used mocha as a server and chai for assertion library.
- testing for /patients/register
- testing for /patients/:id/create_report
- testing for /patients/:id/all_reports
Pass all the required field and bearer token and test for all different test cases possible.
-
Clone the project.
-
Go to folder.
-
Run following command:
npm install bcrypt npm install express npm install jsonwebtoken npm install mongoose npm install passport npm install passport-jwt npm install morgan npm install chai-http npm install mocha npm install chai
-
Run command:
npm start
. -
Open Postman and follow the routes.
-
Use jwt as header (Authorization: Bearer jwtToken).
-
Pass require params in form body.
-
Run command:
npm test
for unit-tesing . -
Happy Learning.