From 2092439b3febd38a6cae6606ec79c2b504c016b2 Mon Sep 17 00:00:00 2001 From: Jyotirmoy Date: Tue, 27 Oct 2020 23:41:04 +0530 Subject: [PATCH] Fixed the endpoints --- backend/.env | 4 +- backend/.env.example | 4 +- backend/.gitignore | 2 + backend/DOCS.md | 142 +++-- backend/docs/api_data.js | 496 +++++++----------- backend/docs/api_data.json | 496 +++++++----------- backend/docs/api_project.js | 6 +- backend/docs/api_project.json | 6 +- .../fonts/glyphicons-halflings-regular.svg | 289 +++++++++- backend/package-lock.json | 64 +-- backend/package.json | 4 +- backend/src/api/apointment/controller.js | 41 ++ backend/src/api/apointment/index.js | 85 +++ backend/src/api/apointment/index.test.js | 86 +++ .../api/{appointment => apointment}/model.js | 18 +- backend/src/api/apointment/model.test.js | 41 ++ backend/src/api/appointment/controller.js | 41 -- backend/src/api/appointment/index.js | 94 ---- backend/src/api/appointment/index.test.js | 130 ----- backend/src/api/appointment/model.test.js | 37 -- backend/src/api/department/index.js | 40 +- backend/src/api/department/index.test.js | 91 +--- backend/src/api/department/model.js | 8 +- backend/src/api/department/model.test.js | 10 +- backend/src/api/doctor/index.js | 24 +- backend/src/api/doctor/index.test.js | 50 +- backend/src/api/doctor/model.js | 8 +- backend/src/api/doctor/model.test.js | 10 +- backend/src/api/index.js | 12 +- backend/src/api/user/controller.js | 8 +- backend/src/api/user/index.test.js | 12 +- backend/src/config.js | 4 +- 32 files changed, 1121 insertions(+), 1242 deletions(-) create mode 100644 backend/src/api/apointment/controller.js create mode 100644 backend/src/api/apointment/index.js create mode 100644 backend/src/api/apointment/index.test.js rename backend/src/api/{appointment => apointment}/model.js (72%) create mode 100644 backend/src/api/apointment/model.test.js delete mode 100644 backend/src/api/appointment/controller.js delete mode 100644 backend/src/api/appointment/index.js delete mode 100644 backend/src/api/appointment/index.test.js delete mode 100644 backend/src/api/appointment/model.test.js diff --git a/backend/.env b/backend/.env index ad527ae..7a5f5f0 100644 --- a/backend/.env +++ b/backend/.env @@ -1,3 +1,3 @@ -MASTER_KEY=dyB4cPIZpFV6X7VIYyKIWRC4GLUKQoV2 -JWT_SECRET=sfDI9AxQb5zpNqVuDB4uB9jw1asIETH2 +MASTER_KEY=n7qgqwuD7JVWL7cgVMuaqLn5LyWSw4Gf +JWT_SECRET=2TKqKamY6xlnogWXjHHy4phCxSidyyRx MONGODB_URI_DEV=mongodb://docapi:VJFj04JeR1amOLK9@cluster0-shard-00-00.9qfp7.mongodb.net:27017,cluster0-shard-00-01.9qfp7.mongodb.net:27017,cluster0-shard-00-02.9qfp7.mongodb.net:27017/doc-api?ssl=true&replicaSet=atlas-zvo94h-shard-0&authSource=admin&retryWrites=true&w=majority diff --git a/backend/.env.example b/backend/.env.example index 95a3cfd..46d9882 100644 --- a/backend/.env.example +++ b/backend/.env.example @@ -1,2 +1,2 @@ -MASTER_KEY=dyB4cPIZpFV6X7VIYyKIWRC4GLUKQoV2 -JWT_SECRET=sfDI9AxQb5zpNqVuDB4uB9jw1asIETH2 +MASTER_KEY=n7qgqwuD7JVWL7cgVMuaqLn5LyWSw4Gf +JWT_SECRET=2TKqKamY6xlnogWXjHHy4phCxSidyyRx \ No newline at end of file diff --git a/backend/.gitignore b/backend/.gitignore index 23d47e7..b8344a4 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -5,6 +5,8 @@ public .idea .log dist +docs +.env npm-debug.log .nyc_output coverage diff --git a/backend/DOCS.md b/backend/DOCS.md index e7fc892..389d410 100644 --- a/backend/DOCS.md +++ b/backend/DOCS.md @@ -1,13 +1,13 @@ -# docter-appointment v1.0.0 +# doctor-apointment v0.0.0 -- [Appointment](#appointment) - - [Create appointment](#create-appointment) - - [Delete appointment](#delete-appointment) - - [Retrieve appointment](#retrieve-appointment) - - [Retrieve appointments](#retrieve-appointments) - - [Update appointment](#update-appointment) +- [Apointment](#apointment) + - [Create apointment](#create-apointment) + - [Delete apointment](#delete-apointment) + - [Retrieve apointment](#retrieve-apointment) + - [Retrieve apointments](#retrieve-apointments) + - [Update apointment](#update-apointment) - [Auth](#auth) - [Authenticate](#authenticate) @@ -37,82 +37,78 @@ -# Appointment +# Apointment -## Create appointment +## Create apointment - POST /appointments + POST /apointments ### Parameters | Name | Type | Description | |---------|-----------|--------------------------------------| -| No | |

Appointment's No.

| -| PatientName | |

Appointment's PatientName.

| -| DocterName | |

Appointment's DocterName.

| -| Date | |

Appointment's Date.

| -| Time | |

Appointment's Time.

| -| Departent | |

Appointment's Departent.

| +| No | |

Apointment's No.

| +| PatientName | |

Apointment's PatientName.

| +| DocterName | |

Apointment's DocterName.

| +| Email | |

Apointment's Email.

| +| PhoneNo | |

Apointment's PhoneNo.

| +| Date | |

Apointment's Date.

| +| Time | |

Apointment's Time.

| +| Department | |

Apointment's Department.

| -## Delete appointment +## Delete apointment - DELETE /appointments/:id + DELETE /apointments/:id + + +## Retrieve apointment + + + + GET /apointments/:id + + +## Retrieve apointments + + + + GET /apointments ### Parameters | Name | Type | Description | |---------|-----------|--------------------------------------| -| access_token | String |

admin access token.

| - -## Retrieve appointment - - - - GET /appointments/:id - - -## Retrieve appointments - - - - GET /appointments - - -### Parameters - -| Name | Type | Description | -|---------|-----------|--------------------------------------| -| access_token | String |

admin access token.

| | q | String | **optional**

Query to search.

| | page | Number | **optional**

Page number.

| | limit | Number | **optional**

Amount of returned items.

| | sort | String[] | **optional**

Order of returned items.

| | fields | String[] | **optional**

Fields to be returned.

| -## Update appointment +## Update apointment - PUT /appointments/:id + PUT /apointments/:id ### Parameters | Name | Type | Description | |---------|-----------|--------------------------------------| -| access_token | String |

admin access token.

| -| No | |

Appointment's No.

| -| PatientName | |

Appointment's PatientName.

| -| DocterName | |

Appointment's DocterName.

| -| Date | |

Appointment's Date.

| -| Time | |

Appointment's Time.

| -| Departent | |

Appointment's Departent.

| +| No | |

Apointment's No.

| +| PatientName | |

Apointment's PatientName.

| +| DocterName | |

Apointment's DocterName.

| +| Email | |

Apointment's Email.

| +| PhoneNo | |

Apointment's PhoneNo.

| +| Date | |

Apointment's Date.

| +| Time | |

Apointment's Time.

| +| Department | |

Apointment's Department.

| # Auth @@ -140,7 +136,7 @@ - POST /departments + POST /Departments ### Parameters @@ -148,48 +144,35 @@ | Name | Type | Description | |---------|-----------|--------------------------------------| | access_token | String |

admin access token.

| -| Id | |

Department's Id.

| +| ID | |

Department's ID.

| | Name | |

Department's Name.

| -| Nos | |

of Doctor Department's NoofDoctor.

| +| Nos | |

Department's Nos.

| ## Delete department - DELETE /departments/:id + DELETE /Departments/:id -### Parameters - -| Name | Type | Description | -|---------|-----------|--------------------------------------| -| access_token | String |

admin access token.

| - ## Retrieve department - GET /departments/:id + GET /Departments/:id -### Parameters - -| Name | Type | Description | -|---------|-----------|--------------------------------------| -| access_token | String |

admin access token.

| - ## Retrieve departments - GET /departments + GET /Departments ### Parameters | Name | Type | Description | |---------|-----------|--------------------------------------| -| access_token | String |

admin access token.

| | q | String | **optional**

Query to search.

| | page | Number | **optional**

Page number.

| | limit | Number | **optional**

Amount of returned items.

| @@ -200,17 +183,16 @@ - PUT /departments/:id + PUT /Departments/:id ### Parameters | Name | Type | Description | |---------|-----------|--------------------------------------| -| access_token | String |

admin access token.

| -| Id | |

Department's Id.

| +| ID | |

Department's ID.

| | Name | |

Department's Name.

| -| Nos | |

of Doctor Department's NoofDoctor.

| +| Nos | |

Department's Nos.

| # Doctor @@ -218,7 +200,7 @@ - POST /doctors + POST /Doctors ### Parameters @@ -226,15 +208,15 @@ | Name | Type | Description | |---------|-----------|--------------------------------------| | access_token | String |

admin access token.

| -| Id | |

Doctor's Id.

| +| ID | |

Doctor's ID.

| | Name | |

Doctor's Name.

| -| Department | |

Doctor's Department.

| +| Dapartment | |

Doctor's Dapartment.

| ## Delete doctor - DELETE /doctors/:id + DELETE /Doctors/:id ### Parameters @@ -247,7 +229,7 @@ - GET /doctors/:id + GET /Doctors/:id ### Parameters @@ -260,7 +242,7 @@ - GET /doctors + GET /Doctors ### Parameters @@ -278,7 +260,7 @@ - PUT /doctors/:id + PUT /Doctors/:id ### Parameters @@ -286,9 +268,9 @@ | Name | Type | Description | |---------|-----------|--------------------------------------| | access_token | String |

admin access token.

| -| Id | |

Doctor's Id.

| +| ID | |

Doctor's ID.

| | Name | |

Doctor's Name.

| -| Department | |

Doctor's Department.

| +| Dapartment | |

Doctor's Dapartment.

| # User diff --git a/backend/docs/api_data.js b/backend/docs/api_data.js index 744eca4..9872e6b 100644 --- a/backend/docs/api_data.js +++ b/backend/docs/api_data.js @@ -1,10 +1,10 @@ define({ "api": [ { "type": "post", - "url": "/appointments", - "title": "Create appointment", - "name": "CreateAppointment", - "group": "Appointment", + "url": "/apointments", + "title": "Create apointment", + "name": "CreateApointment", + "group": "Apointment", "parameter": { "fields": { "Parameter": [ @@ -12,37 +12,49 @@ define({ "api": [ "group": "Parameter", "optional": false, "field": "No", - "description": "

Appointment's No.

" + "description": "

Apointment's No.

" }, { "group": "Parameter", "optional": false, "field": "PatientName", - "description": "

Appointment's PatientName.

" + "description": "

Apointment's PatientName.

" }, { "group": "Parameter", "optional": false, "field": "DocterName", - "description": "

Appointment's DocterName.

" + "description": "

Apointment's DocterName.

" + }, + { + "group": "Parameter", + "optional": false, + "field": "Email", + "description": "

Apointment's Email.

" + }, + { + "group": "Parameter", + "optional": false, + "field": "PhoneNo", + "description": "

Apointment's PhoneNo.

" }, { "group": "Parameter", "optional": false, "field": "Date", - "description": "

Appointment's Date.

" + "description": "

Apointment's Date.

" }, { "group": "Parameter", "optional": false, "field": "Time", - "description": "

Appointment's Time.

" + "description": "

Apointment's Time.

" }, { "group": "Parameter", "optional": false, - "field": "Departent", - "description": "

Appointment's Departent.

" + "field": "Department", + "description": "

Apointment's Department.

" } ] } @@ -54,8 +66,8 @@ define({ "api": [ "group": "Success 200", "type": "Object", "optional": false, - "field": "appointment", - "description": "

Appointment's data.

" + "field": "apointment", + "description": "

Apointment's data.

" } ] } @@ -74,41 +86,21 @@ define({ "api": [ "group": "Error 4xx", "optional": false, "field": "404", - "description": "

Appointment not found.

" + "description": "

Apointment not found.

" } ] } }, "version": "0.0.0", - "filename": "src/api/appointment/index.js", - "groupTitle": "Appointment" + "filename": "src/api/apointment/index.js", + "groupTitle": "Apointment" }, { "type": "delete", - "url": "/appointments/:id", - "title": "Delete appointment", - "name": "DeleteAppointment", - "group": "Appointment", - "permission": [ - { - "name": "admin", - "title": "Admin access only", - "description": "

You must pass access_token parameter or a Bearer Token authorization header to access this endpoint.

" - } - ], - "parameter": { - "fields": { - "Parameter": [ - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "access_token", - "description": "

admin access token.

" - } - ] - } - }, + "url": "/apointments/:id", + "title": "Delete apointment", + "name": "DeleteApointment", + "group": "Apointment", "success": { "fields": { "Success 204": [ @@ -128,27 +120,21 @@ define({ "api": [ "group": "Error 4xx", "optional": false, "field": "404", - "description": "

Appointment not found.

" - }, - { - "group": "Error 4xx", - "optional": false, - "field": "401", - "description": "

admin access only.

" + "description": "

Apointment not found.

" } ] } }, "version": "0.0.0", - "filename": "src/api/appointment/index.js", - "groupTitle": "Appointment" + "filename": "src/api/apointment/index.js", + "groupTitle": "Apointment" }, { "type": "get", - "url": "/appointments/:id", - "title": "Retrieve appointment", - "name": "RetrieveAppointment", - "group": "Appointment", + "url": "/apointments/:id", + "title": "Retrieve apointment", + "name": "RetrieveApointment", + "group": "Apointment", "success": { "fields": { "Success 200": [ @@ -156,8 +142,8 @@ define({ "api": [ "group": "Success 200", "type": "Object", "optional": false, - "field": "appointment", - "description": "

Appointment's data.

" + "field": "apointment", + "description": "

Apointment's data.

" } ] } @@ -176,38 +162,60 @@ define({ "api": [ "group": "Error 4xx", "optional": false, "field": "404", - "description": "

Appointment not found.

" + "description": "

Apointment not found.

" } ] } }, "version": "0.0.0", - "filename": "src/api/appointment/index.js", - "groupTitle": "Appointment" + "filename": "src/api/apointment/index.js", + "groupTitle": "Apointment" }, { "type": "get", - "url": "/appointments", - "title": "Retrieve appointments", - "name": "RetrieveAppointments", - "group": "Appointment", - "permission": [ - { - "name": "admin", - "title": "Admin access only", - "description": "

You must pass access_token parameter or a Bearer Token authorization header to access this endpoint.

" + "url": "/apointments", + "title": "Retrieve apointments", + "name": "RetrieveApointments", + "group": "Apointment", + "success": { + "fields": { + "Success 200": [ + { + "group": "Success 200", + "type": "Number", + "optional": false, + "field": "count", + "description": "

Total amount of apointments.

" + }, + { + "group": "Success 200", + "type": "Object[]", + "optional": false, + "field": "rows", + "description": "

List of apointments.

" + } + ] } - ], + }, + "error": { + "fields": { + "Error 4xx": [ + { + "group": "Error 4xx", + "type": "Object", + "optional": false, + "field": "400", + "description": "

Some parameters may contain invalid values.

" + } + ] + } + }, + "version": "0.0.0", + "filename": "src/api/apointment/index.js", + "groupTitle": "Apointment", "parameter": { "fields": { "Parameter": [ - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "access_token", - "description": "

admin access token.

" - }, { "group": "Parameter", "type": "String", @@ -250,108 +258,64 @@ define({ "api": [ } ] } - }, - "success": { - "fields": { - "Success 200": [ - { - "group": "Success 200", - "type": "Number", - "optional": false, - "field": "count", - "description": "

Total amount of appointments.

" - }, - { - "group": "Success 200", - "type": "Object[]", - "optional": false, - "field": "rows", - "description": "

List of appointments.

" - } - ] - } - }, - "error": { - "fields": { - "Error 4xx": [ - { - "group": "Error 4xx", - "type": "Object", - "optional": false, - "field": "400", - "description": "

Some parameters may contain invalid values.

" - }, - { - "group": "Error 4xx", - "optional": false, - "field": "401", - "description": "

admin access only.

" - } - ] - } - }, - "version": "0.0.0", - "filename": "src/api/appointment/index.js", - "groupTitle": "Appointment" + } }, { "type": "put", - "url": "/appointments/:id", - "title": "Update appointment", - "name": "UpdateAppointment", - "group": "Appointment", - "permission": [ - { - "name": "admin", - "title": "Admin access only", - "description": "

You must pass access_token parameter or a Bearer Token authorization header to access this endpoint.

" - } - ], + "url": "/apointments/:id", + "title": "Update apointment", + "name": "UpdateApointment", + "group": "Apointment", "parameter": { "fields": { "Parameter": [ - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "access_token", - "description": "

admin access token.

" - }, { "group": "Parameter", "optional": false, "field": "No", - "description": "

Appointment's No.

" + "description": "

Apointment's No.

" }, { "group": "Parameter", "optional": false, "field": "PatientName", - "description": "

Appointment's PatientName.

" + "description": "

Apointment's PatientName.

" }, { "group": "Parameter", "optional": false, "field": "DocterName", - "description": "

Appointment's DocterName.

" + "description": "

Apointment's DocterName.

" + }, + { + "group": "Parameter", + "optional": false, + "field": "Email", + "description": "

Apointment's Email.

" + }, + { + "group": "Parameter", + "optional": false, + "field": "PhoneNo", + "description": "

Apointment's PhoneNo.

" }, { "group": "Parameter", "optional": false, "field": "Date", - "description": "

Appointment's Date.

" + "description": "

Apointment's Date.

" }, { "group": "Parameter", "optional": false, "field": "Time", - "description": "

Appointment's Time.

" + "description": "

Apointment's Time.

" }, { "group": "Parameter", "optional": false, - "field": "Departent", - "description": "

Appointment's Departent.

" + "field": "Department", + "description": "

Apointment's Department.

" } ] } @@ -363,8 +327,8 @@ define({ "api": [ "group": "Success 200", "type": "Object", "optional": false, - "field": "appointment", - "description": "

Appointment's data.

" + "field": "apointment", + "description": "

Apointment's data.

" } ] } @@ -383,20 +347,14 @@ define({ "api": [ "group": "Error 4xx", "optional": false, "field": "404", - "description": "

Appointment not found.

" - }, - { - "group": "Error 4xx", - "optional": false, - "field": "401", - "description": "

admin access only.

" + "description": "

Apointment not found.

" } ] } }, "version": "0.0.0", - "filename": "src/api/appointment/index.js", - "groupTitle": "Appointment" + "filename": "src/api/apointment/index.js", + "groupTitle": "Apointment" }, { "type": "post", @@ -475,7 +433,7 @@ define({ "api": [ }, { "type": "post", - "url": "/departments", + "url": "/Departments", "title": "Create department", "name": "CreateDepartment", "group": "Department", @@ -499,8 +457,8 @@ define({ "api": [ { "group": "Parameter", "optional": false, - "field": "Id", - "description": "

Department's Id.

" + "field": "ID", + "description": "

Department's ID.

" }, { "group": "Parameter", @@ -512,7 +470,7 @@ define({ "api": [ "group": "Parameter", "optional": false, "field": "Nos", - "description": "

of Doctor Department's NoofDoctor.

" + "description": "

Department's Nos.

" } ] } @@ -556,35 +514,15 @@ define({ "api": [ } }, "version": "0.0.0", - "filename": "src/api/department/index.js", + "filename": "src/api/Department/index.js", "groupTitle": "Department" }, { "type": "delete", - "url": "/departments/:id", + "url": "/Departments/:id", "title": "Delete department", "name": "DeleteDepartment", "group": "Department", - "permission": [ - { - "name": "admin", - "title": "Admin access only", - "description": "

You must pass access_token parameter or a Bearer Token authorization header to access this endpoint.

" - } - ], - "parameter": { - "fields": { - "Parameter": [ - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "access_token", - "description": "

admin access token.

" - } - ] - } - }, "success": { "fields": { "Success 204": [ @@ -605,46 +543,20 @@ define({ "api": [ "optional": false, "field": "404", "description": "

Department not found.

" - }, - { - "group": "Error 4xx", - "optional": false, - "field": "401", - "description": "

admin access only.

" } ] } }, "version": "0.0.0", - "filename": "src/api/department/index.js", + "filename": "src/api/Department/index.js", "groupTitle": "Department" }, { "type": "get", - "url": "/departments/:id", + "url": "/Departments/:id", "title": "Retrieve department", "name": "RetrieveDepartment", "group": "Department", - "permission": [ - { - "name": "admin", - "title": "Admin access only", - "description": "

You must pass access_token parameter or a Bearer Token authorization header to access this endpoint.

" - } - ], - "parameter": { - "fields": { - "Parameter": [ - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "access_token", - "description": "

admin access token.

" - } - ] - } - }, "success": { "fields": { "Success 200": [ @@ -673,43 +585,59 @@ define({ "api": [ "optional": false, "field": "404", "description": "

Department not found.

" - }, - { - "group": "Error 4xx", - "optional": false, - "field": "401", - "description": "

admin access only.

" } ] } }, "version": "0.0.0", - "filename": "src/api/department/index.js", + "filename": "src/api/Department/index.js", "groupTitle": "Department" }, { "type": "get", - "url": "/departments", + "url": "/Departments", "title": "Retrieve departments", "name": "RetrieveDepartments", "group": "Department", - "permission": [ - { - "name": "admin", - "title": "Admin access only", - "description": "

You must pass access_token parameter or a Bearer Token authorization header to access this endpoint.

" + "success": { + "fields": { + "Success 200": [ + { + "group": "Success 200", + "type": "Number", + "optional": false, + "field": "count", + "description": "

Total amount of departments.

" + }, + { + "group": "Success 200", + "type": "Object[]", + "optional": false, + "field": "rows", + "description": "

List of departments.

" + } + ] } - ], + }, + "error": { + "fields": { + "Error 4xx": [ + { + "group": "Error 4xx", + "type": "Object", + "optional": false, + "field": "400", + "description": "

Some parameters may contain invalid values.

" + } + ] + } + }, + "version": "0.0.0", + "filename": "src/api/Department/index.js", + "groupTitle": "Department", "parameter": { "fields": { "Parameter": [ - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "access_token", - "description": "

admin access token.

" - }, { "group": "Parameter", "type": "String", @@ -752,78 +680,22 @@ define({ "api": [ } ] } - }, - "success": { - "fields": { - "Success 200": [ - { - "group": "Success 200", - "type": "Number", - "optional": false, - "field": "count", - "description": "

Total amount of departments.

" - }, - { - "group": "Success 200", - "type": "Object[]", - "optional": false, - "field": "rows", - "description": "

List of departments.

" - } - ] - } - }, - "error": { - "fields": { - "Error 4xx": [ - { - "group": "Error 4xx", - "type": "Object", - "optional": false, - "field": "400", - "description": "

Some parameters may contain invalid values.

" - }, - { - "group": "Error 4xx", - "optional": false, - "field": "401", - "description": "

admin access only.

" - } - ] - } - }, - "version": "0.0.0", - "filename": "src/api/department/index.js", - "groupTitle": "Department" + } }, { "type": "put", - "url": "/departments/:id", + "url": "/Departments/:id", "title": "Update department", "name": "UpdateDepartment", "group": "Department", - "permission": [ - { - "name": "admin", - "title": "Admin access only", - "description": "

You must pass access_token parameter or a Bearer Token authorization header to access this endpoint.

" - } - ], "parameter": { "fields": { "Parameter": [ { "group": "Parameter", - "type": "String", "optional": false, - "field": "access_token", - "description": "

admin access token.

" - }, - { - "group": "Parameter", - "optional": false, - "field": "Id", - "description": "

Department's Id.

" + "field": "ID", + "description": "

Department's ID.

" }, { "group": "Parameter", @@ -835,7 +707,7 @@ define({ "api": [ "group": "Parameter", "optional": false, "field": "Nos", - "description": "

of Doctor Department's NoofDoctor.

" + "description": "

Department's Nos.

" } ] } @@ -868,23 +740,17 @@ define({ "api": [ "optional": false, "field": "404", "description": "

Department not found.

" - }, - { - "group": "Error 4xx", - "optional": false, - "field": "401", - "description": "

admin access only.

" } ] } }, "version": "0.0.0", - "filename": "src/api/department/index.js", + "filename": "src/api/Department/index.js", "groupTitle": "Department" }, { "type": "post", - "url": "/doctors", + "url": "/Doctors", "title": "Create doctor", "name": "CreateDoctor", "group": "Doctor", @@ -908,8 +774,8 @@ define({ "api": [ { "group": "Parameter", "optional": false, - "field": "Id", - "description": "

Doctor's Id.

" + "field": "ID", + "description": "

Doctor's ID.

" }, { "group": "Parameter", @@ -920,8 +786,8 @@ define({ "api": [ { "group": "Parameter", "optional": false, - "field": "Department", - "description": "

Doctor's Department.

" + "field": "Dapartment", + "description": "

Doctor's Dapartment.

" } ] } @@ -965,12 +831,12 @@ define({ "api": [ } }, "version": "0.0.0", - "filename": "src/api/doctor/index.js", + "filename": "src/api/Doctor/index.js", "groupTitle": "Doctor" }, { "type": "delete", - "url": "/doctors/:id", + "url": "/Doctors/:id", "title": "Delete doctor", "name": "DeleteDoctor", "group": "Doctor", @@ -1025,12 +891,12 @@ define({ "api": [ } }, "version": "0.0.0", - "filename": "src/api/doctor/index.js", + "filename": "src/api/Doctor/index.js", "groupTitle": "Doctor" }, { "type": "get", - "url": "/doctors/:id", + "url": "/Doctors/:id", "title": "Retrieve doctor", "name": "RetrieveDoctor", "group": "Doctor", @@ -1093,12 +959,12 @@ define({ "api": [ } }, "version": "0.0.0", - "filename": "src/api/doctor/index.js", + "filename": "src/api/Doctor/index.js", "groupTitle": "Doctor" }, { "type": "get", - "url": "/doctors", + "url": "/Doctors", "title": "Retrieve doctors", "name": "RetrieveDoctors", "group": "Doctor", @@ -1202,12 +1068,12 @@ define({ "api": [ } }, "version": "0.0.0", - "filename": "src/api/doctor/index.js", + "filename": "src/api/Doctor/index.js", "groupTitle": "Doctor" }, { "type": "put", - "url": "/doctors/:id", + "url": "/Doctors/:id", "title": "Update doctor", "name": "UpdateDoctor", "group": "Doctor", @@ -1231,8 +1097,8 @@ define({ "api": [ { "group": "Parameter", "optional": false, - "field": "Id", - "description": "

Doctor's Id.

" + "field": "ID", + "description": "

Doctor's ID.

" }, { "group": "Parameter", @@ -1243,8 +1109,8 @@ define({ "api": [ { "group": "Parameter", "optional": false, - "field": "Department", - "description": "

Doctor's Department.

" + "field": "Dapartment", + "description": "

Doctor's Dapartment.

" } ] } @@ -1288,7 +1154,7 @@ define({ "api": [ } }, "version": "0.0.0", - "filename": "src/api/doctor/index.js", + "filename": "src/api/Doctor/index.js", "groupTitle": "Doctor" }, { diff --git a/backend/docs/api_data.json b/backend/docs/api_data.json index bf3b050..5fd2928 100644 --- a/backend/docs/api_data.json +++ b/backend/docs/api_data.json @@ -1,10 +1,10 @@ [ { "type": "post", - "url": "/appointments", - "title": "Create appointment", - "name": "CreateAppointment", - "group": "Appointment", + "url": "/apointments", + "title": "Create apointment", + "name": "CreateApointment", + "group": "Apointment", "parameter": { "fields": { "Parameter": [ @@ -12,37 +12,49 @@ "group": "Parameter", "optional": false, "field": "No", - "description": "

Appointment's No.

" + "description": "

Apointment's No.

" }, { "group": "Parameter", "optional": false, "field": "PatientName", - "description": "

Appointment's PatientName.

" + "description": "

Apointment's PatientName.

" }, { "group": "Parameter", "optional": false, "field": "DocterName", - "description": "

Appointment's DocterName.

" + "description": "

Apointment's DocterName.

" + }, + { + "group": "Parameter", + "optional": false, + "field": "Email", + "description": "

Apointment's Email.

" + }, + { + "group": "Parameter", + "optional": false, + "field": "PhoneNo", + "description": "

Apointment's PhoneNo.

" }, { "group": "Parameter", "optional": false, "field": "Date", - "description": "

Appointment's Date.

" + "description": "

Apointment's Date.

" }, { "group": "Parameter", "optional": false, "field": "Time", - "description": "

Appointment's Time.

" + "description": "

Apointment's Time.

" }, { "group": "Parameter", "optional": false, - "field": "Departent", - "description": "

Appointment's Departent.

" + "field": "Department", + "description": "

Apointment's Department.

" } ] } @@ -54,8 +66,8 @@ "group": "Success 200", "type": "Object", "optional": false, - "field": "appointment", - "description": "

Appointment's data.

" + "field": "apointment", + "description": "

Apointment's data.

" } ] } @@ -74,41 +86,21 @@ "group": "Error 4xx", "optional": false, "field": "404", - "description": "

Appointment not found.

" + "description": "

Apointment not found.

" } ] } }, "version": "0.0.0", - "filename": "src/api/appointment/index.js", - "groupTitle": "Appointment" + "filename": "src/api/apointment/index.js", + "groupTitle": "Apointment" }, { "type": "delete", - "url": "/appointments/:id", - "title": "Delete appointment", - "name": "DeleteAppointment", - "group": "Appointment", - "permission": [ - { - "name": "admin", - "title": "Admin access only", - "description": "

You must pass access_token parameter or a Bearer Token authorization header to access this endpoint.

" - } - ], - "parameter": { - "fields": { - "Parameter": [ - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "access_token", - "description": "

admin access token.

" - } - ] - } - }, + "url": "/apointments/:id", + "title": "Delete apointment", + "name": "DeleteApointment", + "group": "Apointment", "success": { "fields": { "Success 204": [ @@ -128,27 +120,21 @@ "group": "Error 4xx", "optional": false, "field": "404", - "description": "

Appointment not found.

" - }, - { - "group": "Error 4xx", - "optional": false, - "field": "401", - "description": "

admin access only.

" + "description": "

Apointment not found.

" } ] } }, "version": "0.0.0", - "filename": "src/api/appointment/index.js", - "groupTitle": "Appointment" + "filename": "src/api/apointment/index.js", + "groupTitle": "Apointment" }, { "type": "get", - "url": "/appointments/:id", - "title": "Retrieve appointment", - "name": "RetrieveAppointment", - "group": "Appointment", + "url": "/apointments/:id", + "title": "Retrieve apointment", + "name": "RetrieveApointment", + "group": "Apointment", "success": { "fields": { "Success 200": [ @@ -156,8 +142,8 @@ "group": "Success 200", "type": "Object", "optional": false, - "field": "appointment", - "description": "

Appointment's data.

" + "field": "apointment", + "description": "

Apointment's data.

" } ] } @@ -176,38 +162,60 @@ "group": "Error 4xx", "optional": false, "field": "404", - "description": "

Appointment not found.

" + "description": "

Apointment not found.

" } ] } }, "version": "0.0.0", - "filename": "src/api/appointment/index.js", - "groupTitle": "Appointment" + "filename": "src/api/apointment/index.js", + "groupTitle": "Apointment" }, { "type": "get", - "url": "/appointments", - "title": "Retrieve appointments", - "name": "RetrieveAppointments", - "group": "Appointment", - "permission": [ - { - "name": "admin", - "title": "Admin access only", - "description": "

You must pass access_token parameter or a Bearer Token authorization header to access this endpoint.

" + "url": "/apointments", + "title": "Retrieve apointments", + "name": "RetrieveApointments", + "group": "Apointment", + "success": { + "fields": { + "Success 200": [ + { + "group": "Success 200", + "type": "Number", + "optional": false, + "field": "count", + "description": "

Total amount of apointments.

" + }, + { + "group": "Success 200", + "type": "Object[]", + "optional": false, + "field": "rows", + "description": "

List of apointments.

" + } + ] } - ], + }, + "error": { + "fields": { + "Error 4xx": [ + { + "group": "Error 4xx", + "type": "Object", + "optional": false, + "field": "400", + "description": "

Some parameters may contain invalid values.

" + } + ] + } + }, + "version": "0.0.0", + "filename": "src/api/apointment/index.js", + "groupTitle": "Apointment", "parameter": { "fields": { "Parameter": [ - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "access_token", - "description": "

admin access token.

" - }, { "group": "Parameter", "type": "String", @@ -250,108 +258,64 @@ } ] } - }, - "success": { - "fields": { - "Success 200": [ - { - "group": "Success 200", - "type": "Number", - "optional": false, - "field": "count", - "description": "

Total amount of appointments.

" - }, - { - "group": "Success 200", - "type": "Object[]", - "optional": false, - "field": "rows", - "description": "

List of appointments.

" - } - ] - } - }, - "error": { - "fields": { - "Error 4xx": [ - { - "group": "Error 4xx", - "type": "Object", - "optional": false, - "field": "400", - "description": "

Some parameters may contain invalid values.

" - }, - { - "group": "Error 4xx", - "optional": false, - "field": "401", - "description": "

admin access only.

" - } - ] - } - }, - "version": "0.0.0", - "filename": "src/api/appointment/index.js", - "groupTitle": "Appointment" + } }, { "type": "put", - "url": "/appointments/:id", - "title": "Update appointment", - "name": "UpdateAppointment", - "group": "Appointment", - "permission": [ - { - "name": "admin", - "title": "Admin access only", - "description": "

You must pass access_token parameter or a Bearer Token authorization header to access this endpoint.

" - } - ], + "url": "/apointments/:id", + "title": "Update apointment", + "name": "UpdateApointment", + "group": "Apointment", "parameter": { "fields": { "Parameter": [ - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "access_token", - "description": "

admin access token.

" - }, { "group": "Parameter", "optional": false, "field": "No", - "description": "

Appointment's No.

" + "description": "

Apointment's No.

" }, { "group": "Parameter", "optional": false, "field": "PatientName", - "description": "

Appointment's PatientName.

" + "description": "

Apointment's PatientName.

" }, { "group": "Parameter", "optional": false, "field": "DocterName", - "description": "

Appointment's DocterName.

" + "description": "

Apointment's DocterName.

" + }, + { + "group": "Parameter", + "optional": false, + "field": "Email", + "description": "

Apointment's Email.

" + }, + { + "group": "Parameter", + "optional": false, + "field": "PhoneNo", + "description": "

Apointment's PhoneNo.

" }, { "group": "Parameter", "optional": false, "field": "Date", - "description": "

Appointment's Date.

" + "description": "

Apointment's Date.

" }, { "group": "Parameter", "optional": false, "field": "Time", - "description": "

Appointment's Time.

" + "description": "

Apointment's Time.

" }, { "group": "Parameter", "optional": false, - "field": "Departent", - "description": "

Appointment's Departent.

" + "field": "Department", + "description": "

Apointment's Department.

" } ] } @@ -363,8 +327,8 @@ "group": "Success 200", "type": "Object", "optional": false, - "field": "appointment", - "description": "

Appointment's data.

" + "field": "apointment", + "description": "

Apointment's data.

" } ] } @@ -383,20 +347,14 @@ "group": "Error 4xx", "optional": false, "field": "404", - "description": "

Appointment not found.

" - }, - { - "group": "Error 4xx", - "optional": false, - "field": "401", - "description": "

admin access only.

" + "description": "

Apointment not found.

" } ] } }, "version": "0.0.0", - "filename": "src/api/appointment/index.js", - "groupTitle": "Appointment" + "filename": "src/api/apointment/index.js", + "groupTitle": "Apointment" }, { "type": "post", @@ -475,7 +433,7 @@ }, { "type": "post", - "url": "/departments", + "url": "/Departments", "title": "Create department", "name": "CreateDepartment", "group": "Department", @@ -499,8 +457,8 @@ { "group": "Parameter", "optional": false, - "field": "Id", - "description": "

Department's Id.

" + "field": "ID", + "description": "

Department's ID.

" }, { "group": "Parameter", @@ -512,7 +470,7 @@ "group": "Parameter", "optional": false, "field": "Nos", - "description": "

of Doctor Department's NoofDoctor.

" + "description": "

Department's Nos.

" } ] } @@ -556,35 +514,15 @@ } }, "version": "0.0.0", - "filename": "src/api/department/index.js", + "filename": "src/api/Department/index.js", "groupTitle": "Department" }, { "type": "delete", - "url": "/departments/:id", + "url": "/Departments/:id", "title": "Delete department", "name": "DeleteDepartment", "group": "Department", - "permission": [ - { - "name": "admin", - "title": "Admin access only", - "description": "

You must pass access_token parameter or a Bearer Token authorization header to access this endpoint.

" - } - ], - "parameter": { - "fields": { - "Parameter": [ - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "access_token", - "description": "

admin access token.

" - } - ] - } - }, "success": { "fields": { "Success 204": [ @@ -605,46 +543,20 @@ "optional": false, "field": "404", "description": "

Department not found.

" - }, - { - "group": "Error 4xx", - "optional": false, - "field": "401", - "description": "

admin access only.

" } ] } }, "version": "0.0.0", - "filename": "src/api/department/index.js", + "filename": "src/api/Department/index.js", "groupTitle": "Department" }, { "type": "get", - "url": "/departments/:id", + "url": "/Departments/:id", "title": "Retrieve department", "name": "RetrieveDepartment", "group": "Department", - "permission": [ - { - "name": "admin", - "title": "Admin access only", - "description": "

You must pass access_token parameter or a Bearer Token authorization header to access this endpoint.

" - } - ], - "parameter": { - "fields": { - "Parameter": [ - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "access_token", - "description": "

admin access token.

" - } - ] - } - }, "success": { "fields": { "Success 200": [ @@ -673,43 +585,59 @@ "optional": false, "field": "404", "description": "

Department not found.

" - }, - { - "group": "Error 4xx", - "optional": false, - "field": "401", - "description": "

admin access only.

" } ] } }, "version": "0.0.0", - "filename": "src/api/department/index.js", + "filename": "src/api/Department/index.js", "groupTitle": "Department" }, { "type": "get", - "url": "/departments", + "url": "/Departments", "title": "Retrieve departments", "name": "RetrieveDepartments", "group": "Department", - "permission": [ - { - "name": "admin", - "title": "Admin access only", - "description": "

You must pass access_token parameter or a Bearer Token authorization header to access this endpoint.

" + "success": { + "fields": { + "Success 200": [ + { + "group": "Success 200", + "type": "Number", + "optional": false, + "field": "count", + "description": "

Total amount of departments.

" + }, + { + "group": "Success 200", + "type": "Object[]", + "optional": false, + "field": "rows", + "description": "

List of departments.

" + } + ] } - ], + }, + "error": { + "fields": { + "Error 4xx": [ + { + "group": "Error 4xx", + "type": "Object", + "optional": false, + "field": "400", + "description": "

Some parameters may contain invalid values.

" + } + ] + } + }, + "version": "0.0.0", + "filename": "src/api/Department/index.js", + "groupTitle": "Department", "parameter": { "fields": { "Parameter": [ - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "access_token", - "description": "

admin access token.

" - }, { "group": "Parameter", "type": "String", @@ -752,78 +680,22 @@ } ] } - }, - "success": { - "fields": { - "Success 200": [ - { - "group": "Success 200", - "type": "Number", - "optional": false, - "field": "count", - "description": "

Total amount of departments.

" - }, - { - "group": "Success 200", - "type": "Object[]", - "optional": false, - "field": "rows", - "description": "

List of departments.

" - } - ] - } - }, - "error": { - "fields": { - "Error 4xx": [ - { - "group": "Error 4xx", - "type": "Object", - "optional": false, - "field": "400", - "description": "

Some parameters may contain invalid values.

" - }, - { - "group": "Error 4xx", - "optional": false, - "field": "401", - "description": "

admin access only.

" - } - ] - } - }, - "version": "0.0.0", - "filename": "src/api/department/index.js", - "groupTitle": "Department" + } }, { "type": "put", - "url": "/departments/:id", + "url": "/Departments/:id", "title": "Update department", "name": "UpdateDepartment", "group": "Department", - "permission": [ - { - "name": "admin", - "title": "Admin access only", - "description": "

You must pass access_token parameter or a Bearer Token authorization header to access this endpoint.

" - } - ], "parameter": { "fields": { "Parameter": [ { "group": "Parameter", - "type": "String", "optional": false, - "field": "access_token", - "description": "

admin access token.

" - }, - { - "group": "Parameter", - "optional": false, - "field": "Id", - "description": "

Department's Id.

" + "field": "ID", + "description": "

Department's ID.

" }, { "group": "Parameter", @@ -835,7 +707,7 @@ "group": "Parameter", "optional": false, "field": "Nos", - "description": "

of Doctor Department's NoofDoctor.

" + "description": "

Department's Nos.

" } ] } @@ -868,23 +740,17 @@ "optional": false, "field": "404", "description": "

Department not found.

" - }, - { - "group": "Error 4xx", - "optional": false, - "field": "401", - "description": "

admin access only.

" } ] } }, "version": "0.0.0", - "filename": "src/api/department/index.js", + "filename": "src/api/Department/index.js", "groupTitle": "Department" }, { "type": "post", - "url": "/doctors", + "url": "/Doctors", "title": "Create doctor", "name": "CreateDoctor", "group": "Doctor", @@ -908,8 +774,8 @@ { "group": "Parameter", "optional": false, - "field": "Id", - "description": "

Doctor's Id.

" + "field": "ID", + "description": "

Doctor's ID.

" }, { "group": "Parameter", @@ -920,8 +786,8 @@ { "group": "Parameter", "optional": false, - "field": "Department", - "description": "

Doctor's Department.

" + "field": "Dapartment", + "description": "

Doctor's Dapartment.

" } ] } @@ -965,12 +831,12 @@ } }, "version": "0.0.0", - "filename": "src/api/doctor/index.js", + "filename": "src/api/Doctor/index.js", "groupTitle": "Doctor" }, { "type": "delete", - "url": "/doctors/:id", + "url": "/Doctors/:id", "title": "Delete doctor", "name": "DeleteDoctor", "group": "Doctor", @@ -1025,12 +891,12 @@ } }, "version": "0.0.0", - "filename": "src/api/doctor/index.js", + "filename": "src/api/Doctor/index.js", "groupTitle": "Doctor" }, { "type": "get", - "url": "/doctors/:id", + "url": "/Doctors/:id", "title": "Retrieve doctor", "name": "RetrieveDoctor", "group": "Doctor", @@ -1093,12 +959,12 @@ } }, "version": "0.0.0", - "filename": "src/api/doctor/index.js", + "filename": "src/api/Doctor/index.js", "groupTitle": "Doctor" }, { "type": "get", - "url": "/doctors", + "url": "/Doctors", "title": "Retrieve doctors", "name": "RetrieveDoctors", "group": "Doctor", @@ -1202,12 +1068,12 @@ } }, "version": "0.0.0", - "filename": "src/api/doctor/index.js", + "filename": "src/api/Doctor/index.js", "groupTitle": "Doctor" }, { "type": "put", - "url": "/doctors/:id", + "url": "/Doctors/:id", "title": "Update doctor", "name": "UpdateDoctor", "group": "Doctor", @@ -1231,8 +1097,8 @@ { "group": "Parameter", "optional": false, - "field": "Id", - "description": "

Doctor's Id.

" + "field": "ID", + "description": "

Doctor's ID.

" }, { "group": "Parameter", @@ -1243,8 +1109,8 @@ { "group": "Parameter", "optional": false, - "field": "Department", - "description": "

Doctor's Department.

" + "field": "Dapartment", + "description": "

Doctor's Dapartment.

" } ] } @@ -1288,7 +1154,7 @@ } }, "version": "0.0.0", - "filename": "src/api/doctor/index.js", + "filename": "src/api/Doctor/index.js", "groupTitle": "Doctor" }, { diff --git a/backend/docs/api_project.js b/backend/docs/api_project.js index c923e9e..d372d69 100644 --- a/backend/docs/api_project.js +++ b/backend/docs/api_project.js @@ -1,13 +1,13 @@ define({ - "name": "docter-appointment", - "version": "1.0.0", + "name": "doctor-apointment", + "version": "0.0.0", "description": "", "sampleUrl": false, "defaultVersion": "0.0.0", "apidoc": "0.3.0", "generator": { "name": "apidoc", - "time": "2020-10-22T19:01:49.797Z", + "time": "2020-10-27T18:03:57.724Z", "url": "http://apidocjs.com", "version": "0.20.1" } diff --git a/backend/docs/api_project.json b/backend/docs/api_project.json index d1da28f..bc7bb84 100644 --- a/backend/docs/api_project.json +++ b/backend/docs/api_project.json @@ -1,13 +1,13 @@ { - "name": "docter-appointment", - "version": "1.0.0", + "name": "doctor-apointment", + "version": "0.0.0", "description": "", "sampleUrl": false, "defaultVersion": "0.0.0", "apidoc": "0.3.0", "generator": { "name": "apidoc", - "time": "2020-10-22T19:01:49.797Z", + "time": "2020-10-27T18:03:57.724Z", "url": "http://apidocjs.com", "version": "0.20.1" } diff --git a/backend/docs/fonts/glyphicons-halflings-regular.svg b/backend/docs/fonts/glyphicons-halflings-regular.svg index b17ff26..94fb549 100644 --- a/backend/docs/fonts/glyphicons-halflings-regular.svg +++ b/backend/docs/fonts/glyphicons-halflings-regular.svg @@ -1 +1,288 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/package-lock.json b/backend/package-lock.json index 9938d36..be3c831 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -1,6 +1,6 @@ { - "name": "docter-appointment", - "version": "1.0.0", + "name": "doctor-apointment", + "version": "0.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1699,9 +1699,9 @@ "dev": true }, "@types/node": { - "version": "14.14.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.2.tgz", - "integrity": "sha512-jeYJU2kl7hL9U5xuI/BhKPZ4vqGM/OmK6whiFAXVhlstzZhVamWhDSmHyGLIp+RVyuF9/d0dqr2P85aFj4BvJg==", + "version": "14.14.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.5.tgz", + "integrity": "sha512-H5Wn24s/ZOukBmDn03nnGTp18A60ny9AmCwnEcgJiTgSGsCO7k+NWP7zjCCbhlcnVCoI+co52dUAt9GMhOSULw==", "dev": true }, "@types/normalize-package-data": { @@ -1800,9 +1800,9 @@ "dev": true }, "agent-base": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.1.tgz", - "integrity": "sha512-01q25QQDwLSsyfhrKbn8yuur+JNw0H+0Y4JiGIKd3z9aYk/w/2kxD/Upc+t2ZBBSUNff50VjPsSW2YxM8QYKVg==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", "dev": true, "requires": { "debug": "4" @@ -2610,13 +2610,13 @@ "integrity": "sha512-kDuEzldR21lHciPQAIulLs1LZlCXdLziXI6Mb/TDkwXhb//UORJNPXgcRs2CuO4H0DcMkpfT3/ySsP3unoZjBg==" }, "buffer": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.6.0.tgz", - "integrity": "sha512-/gDYp/UtU0eA1ys8bOs9J6a+E/KWIY+DZ+Q2WESNUA0jFRsJOc0SNUO6xJ5SGA1xueg3NL65W6s+NY5l9cunuw==", + "version": "5.6.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.6.1.tgz", + "integrity": "sha512-2z15UUHpS9/3tk9mY/q+Rl3rydOi7yMp5XWNQnRvoz+mJwiv8brqYwp9a+nOCtma6dwuEIxljD8W3ysVBZ05Vg==", "dev": true, "requires": { - "base64-js": "^1.0.2", - "ieee754": "^1.1.4" + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" } }, "buffer-crc32": { @@ -2713,9 +2713,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001150", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001150.tgz", - "integrity": "sha512-kiNKvihW0m36UhAFnl7bOAv0i1K1f6wpfVtTF5O5O82XzgtBnb05V0XeV3oZ968vfg2sRNChsHw8ASH2hDfoYQ==" + "version": "1.0.30001151", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001151.tgz", + "integrity": "sha512-Zh3sHqskX6mHNrqUerh+fkf0N72cMxrmflzje/JyVImfpknscMnkeJrlFGJcqTmaa0iszdYptGpWMJCRQDkBVw==" }, "capture-exit": { "version": "2.0.0", @@ -3500,9 +3500,9 @@ "dev": true }, "electron-to-chromium": { - "version": "1.3.582", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.582.tgz", - "integrity": "sha512-0nCJ7cSqnkMC+kUuPs0YgklFHraWGl/xHqtZWWtOeVtyi+YqkoAOMGuZQad43DscXCQI/yizcTa3u6B5r+BLww==" + "version": "1.3.584", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.584.tgz", + "integrity": "sha512-NB3DzrTzJFhWkUp+nl2KtUtoFzrfGXTir2S+BU4tXGyXH9vlluPuFpE3pTKeH7+PY460tHLjKzh6K2+TWwW+Ww==" }, "emoji-regex": { "version": "7.0.3", @@ -7756,9 +7756,9 @@ } }, "mongoose": { - "version": "5.10.9", - "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.10.9.tgz", - "integrity": "sha512-7dkr1d6Uyk87hELzoc6B7Zo7kkPTx8rKummk51Y0je2V2Ttsw0KFPwTp1G8JIbBta7Wpw8j15PJi0d33Ode2nw==", + "version": "5.10.11", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.10.11.tgz", + "integrity": "sha512-R5BFitKW94/S/Z48w+X+qi/eto66jWBcVEVA8nYVkBoBAPFGq7JSYP/0uso+ZHs+7XjSzTuui+SUllzxIrf9yA==", "requires": { "bson": "^1.1.4", "kareem": "2.3.1", @@ -8699,13 +8699,13 @@ "dev": true }, "prompts": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.3.2.tgz", - "integrity": "sha512-Q06uKs2CkNYVID0VqwfAl9mipo99zkBv/n2JtWY89Yxa3ZabWSrs0e2KTudKVa3peLUvYXMefDqIleLPVUBZMA==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.0.tgz", + "integrity": "sha512-awZAKrk3vN6CroQukBL+R9051a4R3zCZBlJm/HBfrSZ8iTpYix3VX1vU4mveiLpiwmOJT4wokTF9m6HUk4KqWQ==", "dev": true, "requires": { "kleur": "^3.0.3", - "sisteransi": "^1.0.4" + "sisteransi": "^1.0.5" } }, "propagate": { @@ -8750,9 +8750,9 @@ "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" }, "pupa": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/pupa/-/pupa-2.1.0.tgz", - "integrity": "sha512-Pj8EhJzFiPwnf4dEXpuUWwH8M/Yl4vpl4cN2RX1i3R77DWvbY5ZPKni7CCKkOYxz+XKt2fieemsV+WTZbIlYzg==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/pupa/-/pupa-2.1.1.tgz", + "integrity": "sha512-l1jNAspIBSFqbT+y+5FosojNpVpF94nlI+wDUpqP9enwOTfHx9f0gh5nB96vl+6yTpsJsypeNrwfzPrKuHB41A==", "dev": true, "requires": { "escape-goat": "^2.0.0" @@ -10229,9 +10229,9 @@ } }, "term-size": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/term-size/-/term-size-2.2.0.tgz", - "integrity": "sha512-a6sumDlzyHVJWb8+YofY4TW112G6p2FCPEAFk+59gIYHv3XHRhm9ltVQ9kli4hNWeQBwSpe8cRN25x0ROunMOw==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/term-size/-/term-size-2.2.1.tgz", + "integrity": "sha512-wK0Ri4fOGjv/XPy8SBHZChl8CM7uMc5VML7SqiQ0zG7+J5Vr+RMQDoHa2CNT6KHUnTGIXH34UDMkPzAUyapBZg==", "dev": true }, "terminal-link": { diff --git a/backend/package.json b/backend/package.json index 3f47abc..d11f061 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { - "name": "docter-appointment", - "version": "1.0.0", + "name": "doctor-apointment", + "version": "0.0.0", "main": "src", "private": true, "scripts": { diff --git a/backend/src/api/apointment/controller.js b/backend/src/api/apointment/controller.js new file mode 100644 index 0000000..b75bd36 --- /dev/null +++ b/backend/src/api/apointment/controller.js @@ -0,0 +1,41 @@ +import { success, notFound } from '../../services/response/' +import { Apointment } from '.' + +export const create = ({ bodymen: { body } }, res, next) => + Apointment.create(body) + .then((apointment) => apointment.view(true)) + .then(success(res, 201)) + .catch(next) + +export const index = ({ querymen: { query, select, cursor } }, res, next) => + Apointment.count(query) + .then(count => Apointment.find(query, select, cursor) + .then((apointments) => ({ + count, + rows: apointments.map((apointment) => apointment.view()) + })) + ) + .then(success(res)) + .catch(next) + +export const show = ({ params }, res, next) => + Apointment.findById(params.id) + .then(notFound(res)) + .then((apointment) => apointment ? apointment.view() : null) + .then(success(res)) + .catch(next) + +export const update = ({ bodymen: { body }, params }, res, next) => + Apointment.findById(params.id) + .then(notFound(res)) + .then((apointment) => apointment ? Object.assign(apointment, body).save() : null) + .then((apointment) => apointment ? apointment.view(true) : null) + .then(success(res)) + .catch(next) + +export const destroy = ({ params }, res, next) => + Apointment.findById(params.id) + .then(notFound(res)) + .then((apointment) => apointment ? apointment.remove() : null) + .then(success(res, 204)) + .catch(next) diff --git a/backend/src/api/apointment/index.js b/backend/src/api/apointment/index.js new file mode 100644 index 0000000..bbb1101 --- /dev/null +++ b/backend/src/api/apointment/index.js @@ -0,0 +1,85 @@ +import { Router } from 'express' +import { middleware as query } from 'querymen' +import { middleware as body } from 'bodymen' +import { create, index, show, update, destroy } from './controller' +import { schema } from './model' +export Apointment, { schema } from './model' + +const router = new Router() +const { No, PatientName, DocterName, Email, PhoneNo, Date, Time, Department } = schema.tree + +/** + * @api {post} /apointments Create apointment + * @apiName CreateApointment + * @apiGroup Apointment + * @apiParam No Apointment's No. + * @apiParam PatientName Apointment's PatientName. + * @apiParam DocterName Apointment's DocterName. + * @apiParam Email Apointment's Email. + * @apiParam PhoneNo Apointment's PhoneNo. + * @apiParam Date Apointment's Date. + * @apiParam Time Apointment's Time. + * @apiParam Department Apointment's Department. + * @apiSuccess {Object} apointment Apointment's data. + * @apiError {Object} 400 Some parameters may contain invalid values. + * @apiError 404 Apointment not found. + */ +router.post('/', + body({ No, PatientName, DocterName, Email, PhoneNo, Date, Time, Department }), + create) + +/** + * @api {get} /apointments Retrieve apointments + * @apiName RetrieveApointments + * @apiGroup Apointment + * @apiUse listParams + * @apiSuccess {Number} count Total amount of apointments. + * @apiSuccess {Object[]} rows List of apointments. + * @apiError {Object} 400 Some parameters may contain invalid values. + */ +router.get('/', + query(), + index) + +/** + * @api {get} /apointments/:id Retrieve apointment + * @apiName RetrieveApointment + * @apiGroup Apointment + * @apiSuccess {Object} apointment Apointment's data. + * @apiError {Object} 400 Some parameters may contain invalid values. + * @apiError 404 Apointment not found. + */ +router.get('/:id', + show) + +/** + * @api {put} /apointments/:id Update apointment + * @apiName UpdateApointment + * @apiGroup Apointment + * @apiParam No Apointment's No. + * @apiParam PatientName Apointment's PatientName. + * @apiParam DocterName Apointment's DocterName. + * @apiParam Email Apointment's Email. + * @apiParam PhoneNo Apointment's PhoneNo. + * @apiParam Date Apointment's Date. + * @apiParam Time Apointment's Time. + * @apiParam Department Apointment's Department. + * @apiSuccess {Object} apointment Apointment's data. + * @apiError {Object} 400 Some parameters may contain invalid values. + * @apiError 404 Apointment not found. + */ +router.put('/:id', + body({ No, PatientName, DocterName, Email, PhoneNo, Date, Time, Department }), + update) + +/** + * @api {delete} /apointments/:id Delete apointment + * @apiName DeleteApointment + * @apiGroup Apointment + * @apiSuccess (Success 204) 204 No Content. + * @apiError 404 Apointment not found. + */ +router.delete('/:id', + destroy) + +export default router diff --git a/backend/src/api/apointment/index.test.js b/backend/src/api/apointment/index.test.js new file mode 100644 index 0000000..4fc99ed --- /dev/null +++ b/backend/src/api/apointment/index.test.js @@ -0,0 +1,86 @@ +import request from 'supertest' +import { apiRoot } from '../../config' +import express from '../../services/express' +import routes, { Apointment } from '.' + +const app = () => express(apiRoot, routes) + +let apointment + +beforeEach(async () => { + apointment = await Apointment.create({}) +}) + +test('POST /apointments 201', async () => { + const { status, body } = await request(app()) + .post(`${apiRoot}`) + .send({ No: 'test', PatientName: 'test', DocterName: 'test', Email: 'test', PhoneNo: 'test', Date: 'test', Time: 'test', Department: 'test' }) + expect(status).toBe(201) + expect(typeof body).toEqual('object') + expect(body.No).toEqual('test') + expect(body.PatientName).toEqual('test') + expect(body.DocterName).toEqual('test') + expect(body.Email).toEqual('test') + expect(body.PhoneNo).toEqual('test') + expect(body.Date).toEqual('test') + expect(body.Time).toEqual('test') + expect(body.Department).toEqual('test') +}) + +test('GET /apointments 200', async () => { + const { status, body } = await request(app()) + .get(`${apiRoot}`) + expect(status).toBe(200) + expect(Array.isArray(body.rows)).toBe(true) + expect(Number.isNaN(body.count)).toBe(false) +}) + +test('GET /apointments/:id 200', async () => { + const { status, body } = await request(app()) + .get(`${apiRoot}/${apointment.id}`) + expect(status).toBe(200) + expect(typeof body).toEqual('object') + expect(body.id).toEqual(apointment.id) +}) + +test('GET /apointments/:id 404', async () => { + const { status } = await request(app()) + .get(apiRoot + '/123456789098765432123456') + expect(status).toBe(404) +}) + +test('PUT /apointments/:id 200', async () => { + const { status, body } = await request(app()) + .put(`${apiRoot}/${apointment.id}`) + .send({ No: 'test', PatientName: 'test', DocterName: 'test', Email: 'test', PhoneNo: 'test', Date: 'test', Time: 'test', Department: 'test' }) + expect(status).toBe(200) + expect(typeof body).toEqual('object') + expect(body.id).toEqual(apointment.id) + expect(body.No).toEqual('test') + expect(body.PatientName).toEqual('test') + expect(body.DocterName).toEqual('test') + expect(body.Email).toEqual('test') + expect(body.PhoneNo).toEqual('test') + expect(body.Date).toEqual('test') + expect(body.Time).toEqual('test') + expect(body.Department).toEqual('test') +}) + +test('PUT /apointments/:id 404', async () => { + const { status } = await request(app()) + .put(apiRoot + '/123456789098765432123456') + .send({ No: 'test', PatientName: 'test', DocterName: 'test', Email: 'test', PhoneNo: 'test', Date: 'test', Time: 'test', Department: 'test' }) + expect(status).toBe(404) +}) + +test('DELETE /apointments/:id 204', async () => { + const { status } = await request(app()) + .delete(`${apiRoot}/${apointment.id}`) + expect(status).toBe(204) +}) + +test('DELETE /apointments/:id 404', async () => { + const { status } = await request(app()) + .delete(apiRoot + '/123456789098765432123456') + expect(status).toBe(404) +}) diff --git a/backend/src/api/appointment/model.js b/backend/src/api/apointment/model.js similarity index 72% rename from backend/src/api/appointment/model.js rename to backend/src/api/apointment/model.js index bebd46e..86280a0 100644 --- a/backend/src/api/appointment/model.js +++ b/backend/src/api/apointment/model.js @@ -1,6 +1,6 @@ import mongoose, { Schema } from 'mongoose' -const appointmentSchema = new Schema({ +const apointmentSchema = new Schema({ No: { type: String }, @@ -10,13 +10,19 @@ const appointmentSchema = new Schema({ DocterName: { type: String }, + Email: { + type: String + }, + PhoneNo: { + type: String + }, Date: { type: String }, Time: { type: String }, - Departent: { + Department: { type: String } }, { @@ -27,7 +33,7 @@ const appointmentSchema = new Schema({ } }) -appointmentSchema.methods = { +apointmentSchema.methods = { view (full) { const view = { // simple view @@ -35,9 +41,11 @@ appointmentSchema.methods = { No: this.No, PatientName: this.PatientName, DocterName: this.DocterName, + Email: this.Email, + PhoneNo: this.PhoneNo, Date: this.Date, Time: this.Time, - Departent: this.Departent, + Department: this.Department, createdAt: this.createdAt, updatedAt: this.updatedAt } @@ -49,7 +57,7 @@ appointmentSchema.methods = { } } -const model = mongoose.model('Appointment', appointmentSchema) +const model = mongoose.model('Apointment', apointmentSchema) export const schema = model.schema export default model diff --git a/backend/src/api/apointment/model.test.js b/backend/src/api/apointment/model.test.js new file mode 100644 index 0000000..a7854d3 --- /dev/null +++ b/backend/src/api/apointment/model.test.js @@ -0,0 +1,41 @@ +import { Apointment } from '.' + +let apointment + +beforeEach(async () => { + apointment = await Apointment.create({ No: 'test', PatientName: 'test', DocterName: 'test', Email: 'test', PhoneNo: 'test', Date: 'test', Time: 'test', Department: 'test' }) +}) + +describe('view', () => { + it('returns simple view', () => { + const view = apointment.view() + expect(typeof view).toBe('object') + expect(view.id).toBe(apointment.id) + expect(view.No).toBe(apointment.No) + expect(view.PatientName).toBe(apointment.PatientName) + expect(view.DocterName).toBe(apointment.DocterName) + expect(view.Email).toBe(apointment.Email) + expect(view.PhoneNo).toBe(apointment.PhoneNo) + expect(view.Date).toBe(apointment.Date) + expect(view.Time).toBe(apointment.Time) + expect(view.Department).toBe(apointment.Department) + expect(view.createdAt).toBeTruthy() + expect(view.updatedAt).toBeTruthy() + }) + + it('returns full view', () => { + const view = apointment.view(true) + expect(typeof view).toBe('object') + expect(view.id).toBe(apointment.id) + expect(view.No).toBe(apointment.No) + expect(view.PatientName).toBe(apointment.PatientName) + expect(view.DocterName).toBe(apointment.DocterName) + expect(view.Email).toBe(apointment.Email) + expect(view.PhoneNo).toBe(apointment.PhoneNo) + expect(view.Date).toBe(apointment.Date) + expect(view.Time).toBe(apointment.Time) + expect(view.Department).toBe(apointment.Department) + expect(view.createdAt).toBeTruthy() + expect(view.updatedAt).toBeTruthy() + }) +}) diff --git a/backend/src/api/appointment/controller.js b/backend/src/api/appointment/controller.js deleted file mode 100644 index f3c46e8..0000000 --- a/backend/src/api/appointment/controller.js +++ /dev/null @@ -1,41 +0,0 @@ -import { success, notFound } from '../../services/response/' -import { Appointment } from '.' - -export const create = ({ bodymen: { body } }, res, next) => - Appointment.create(body) - .then((appointment) => appointment.view(true)) - .then(success(res, 201)) - .catch(next) - -export const index = ({ querymen: { query, select, cursor } }, res, next) => - Appointment.count(query) - .then(count => Appointment.find(query, select, cursor) - .then((appointments) => ({ - count, - rows: appointments.map((appointment) => appointment.view()) - })) - ) - .then(success(res)) - .catch(next) - -export const show = ({ params }, res, next) => - Appointment.findById(params.id) - .then(notFound(res)) - .then((appointment) => appointment ? appointment.view() : null) - .then(success(res)) - .catch(next) - -export const update = ({ bodymen: { body }, params }, res, next) => - Appointment.findById(params.id) - .then(notFound(res)) - .then((appointment) => appointment ? Object.assign(appointment, body).save() : null) - .then((appointment) => appointment ? appointment.view(true) : null) - .then(success(res)) - .catch(next) - -export const destroy = ({ params }, res, next) => - Appointment.findById(params.id) - .then(notFound(res)) - .then((appointment) => appointment ? appointment.remove() : null) - .then(success(res, 204)) - .catch(next) diff --git a/backend/src/api/appointment/index.js b/backend/src/api/appointment/index.js deleted file mode 100644 index e323625..0000000 --- a/backend/src/api/appointment/index.js +++ /dev/null @@ -1,94 +0,0 @@ -import { Router } from 'express' -import { middleware as query } from 'querymen' -import { middleware as body } from 'bodymen' -import { token } from '../../services/passport' -import { create, index, show, update, destroy } from './controller' -import { schema } from './model' -export Appointment, { schema } from './model' - -const router = new Router() -const { No, PatientName, DocterName, Date, Time, Departent } = schema.tree - -/** - * @api {post} /appointments Create appointment - * @apiName CreateAppointment - * @apiGroup Appointment - * @apiParam No Appointment's No. - * @apiParam PatientName Appointment's PatientName. - * @apiParam DocterName Appointment's DocterName. - * @apiParam Date Appointment's Date. - * @apiParam Time Appointment's Time. - * @apiParam Departent Appointment's Departent. - * @apiSuccess {Object} appointment Appointment's data. - * @apiError {Object} 400 Some parameters may contain invalid values. - * @apiError 404 Appointment not found. - */ -router.post('/', - body({ No, PatientName, DocterName, Date, Time, Departent }), - create) - -/** - * @api {get} /appointments Retrieve appointments - * @apiName RetrieveAppointments - * @apiGroup Appointment - * @apiPermission admin - * @apiParam {String} access_token admin access token. - * @apiUse listParams - * @apiSuccess {Number} count Total amount of appointments. - * @apiSuccess {Object[]} rows List of appointments. - * @apiError {Object} 400 Some parameters may contain invalid values. - * @apiError 401 admin access only. - */ -router.get('/', - token({ required: true, roles: ['admin'] }), - query(), - index) - -/** - * @api {get} /appointments/:id Retrieve appointment - * @apiName RetrieveAppointment - * @apiGroup Appointment - * @apiSuccess {Object} appointment Appointment's data. - * @apiError {Object} 400 Some parameters may contain invalid values. - * @apiError 404 Appointment not found. - */ -router.get('/:id', - show) - -/** - * @api {put} /appointments/:id Update appointment - * @apiName UpdateAppointment - * @apiGroup Appointment - * @apiPermission admin - * @apiParam {String} access_token admin access token. - * @apiParam No Appointment's No. - * @apiParam PatientName Appointment's PatientName. - * @apiParam DocterName Appointment's DocterName. - * @apiParam Date Appointment's Date. - * @apiParam Time Appointment's Time. - * @apiParam Departent Appointment's Departent. - * @apiSuccess {Object} appointment Appointment's data. - * @apiError {Object} 400 Some parameters may contain invalid values. - * @apiError 404 Appointment not found. - * @apiError 401 admin access only. - */ -router.put('/:id', - token({ required: true, roles: ['admin'] }), - body({ No, PatientName, DocterName, Date, Time, Departent }), - update) - -/** - * @api {delete} /appointments/:id Delete appointment - * @apiName DeleteAppointment - * @apiGroup Appointment - * @apiPermission admin - * @apiParam {String} access_token admin access token. - * @apiSuccess (Success 204) 204 No Content. - * @apiError 404 Appointment not found. - * @apiError 401 admin access only. - */ -router.delete('/:id', - token({ required: true, roles: ['admin'] }), - destroy) - -export default router diff --git a/backend/src/api/appointment/index.test.js b/backend/src/api/appointment/index.test.js deleted file mode 100644 index 7809365..0000000 --- a/backend/src/api/appointment/index.test.js +++ /dev/null @@ -1,130 +0,0 @@ -import request from 'supertest' -import { apiRoot } from '../../config' -import { signSync } from '../../services/jwt' -import express from '../../services/express' -import { User } from '../user' -import routes, { Appointment } from '.' - -const app = () => express(apiRoot, routes) - -let userSession, adminSession, appointment - -beforeEach(async () => { - const user = await User.create({ email: 'a@a.com', password: '123456' }) - const admin = await User.create({ email: 'c@c.com', password: '123456', role: 'admin' }) - userSession = signSync(user.id) - adminSession = signSync(admin.id) - appointment = await Appointment.create({}) -}) - -test('POST /appointments 201', async () => { - const { status, body } = await request(app()) - .post(`${apiRoot}`) - .send({ No: 'test', PatientName: 'test', DocterName: 'test', Date: 'test', Time: 'test', Departent: 'test' }) - expect(status).toBe(201) - expect(typeof body).toEqual('object') - expect(body.No).toEqual('test') - expect(body.PatientName).toEqual('test') - expect(body.DocterName).toEqual('test') - expect(body.Date).toEqual('test') - expect(body.Time).toEqual('test') - expect(body.Departent).toEqual('test') -}) - -test('GET /appointments 200 (admin)', async () => { - const { status, body } = await request(app()) - .get(`${apiRoot}`) - .query({ access_token: adminSession }) - expect(status).toBe(200) - expect(Array.isArray(body.rows)).toBe(true) - expect(Number.isNaN(body.count)).toBe(false) -}) - -test('GET /appointments 401 (user)', async () => { - const { status } = await request(app()) - .get(`${apiRoot}`) - .query({ access_token: userSession }) - expect(status).toBe(401) -}) - -test('GET /appointments 401', async () => { - const { status } = await request(app()) - .get(`${apiRoot}`) - expect(status).toBe(401) -}) - -test('GET /appointments/:id 200', async () => { - const { status, body } = await request(app()) - .get(`${apiRoot}/${appointment.id}`) - expect(status).toBe(200) - expect(typeof body).toEqual('object') - expect(body.id).toEqual(appointment.id) -}) - -test('GET /appointments/:id 404', async () => { - const { status } = await request(app()) - .get(apiRoot + '/123456789098765432123456') - expect(status).toBe(404) -}) - -test('PUT /appointments/:id 200 (admin)', async () => { - const { status, body } = await request(app()) - .put(`${apiRoot}/${appointment.id}`) - .send({ access_token: adminSession, No: 'test', PatientName: 'test', DocterName: 'test', Date: 'test', Time: 'test', Departent: 'test' }) - expect(status).toBe(200) - expect(typeof body).toEqual('object') - expect(body.id).toEqual(appointment.id) - expect(body.No).toEqual('test') - expect(body.PatientName).toEqual('test') - expect(body.DocterName).toEqual('test') - expect(body.Date).toEqual('test') - expect(body.Time).toEqual('test') - expect(body.Departent).toEqual('test') -}) - -test('PUT /appointments/:id 401 (user)', async () => { - const { status } = await request(app()) - .put(`${apiRoot}/${appointment.id}`) - .send({ access_token: userSession }) - expect(status).toBe(401) -}) - -test('PUT /appointments/:id 401', async () => { - const { status } = await request(app()) - .put(`${apiRoot}/${appointment.id}`) - expect(status).toBe(401) -}) - -test('PUT /appointments/:id 404 (admin)', async () => { - const { status } = await request(app()) - .put(apiRoot + '/123456789098765432123456') - .send({ access_token: adminSession, No: 'test', PatientName: 'test', DocterName: 'test', Date: 'test', Time: 'test', Departent: 'test' }) - expect(status).toBe(404) -}) - -test('DELETE /appointments/:id 204 (admin)', async () => { - const { status } = await request(app()) - .delete(`${apiRoot}/${appointment.id}`) - .query({ access_token: adminSession }) - expect(status).toBe(204) -}) - -test('DELETE /appointments/:id 401 (user)', async () => { - const { status } = await request(app()) - .delete(`${apiRoot}/${appointment.id}`) - .query({ access_token: userSession }) - expect(status).toBe(401) -}) - -test('DELETE /appointments/:id 401', async () => { - const { status } = await request(app()) - .delete(`${apiRoot}/${appointment.id}`) - expect(status).toBe(401) -}) - -test('DELETE /appointments/:id 404 (admin)', async () => { - const { status } = await request(app()) - .delete(apiRoot + '/123456789098765432123456') - .query({ access_token: adminSession }) - expect(status).toBe(404) -}) diff --git a/backend/src/api/appointment/model.test.js b/backend/src/api/appointment/model.test.js deleted file mode 100644 index 78f4959..0000000 --- a/backend/src/api/appointment/model.test.js +++ /dev/null @@ -1,37 +0,0 @@ -import { Appointment } from '.' - -let appointment - -beforeEach(async () => { - appointment = await Appointment.create({ No: 'test', PatientName: 'test', DocterName: 'test', Date: 'test', Time: 'test', Departent: 'test' }) -}) - -describe('view', () => { - it('returns simple view', () => { - const view = appointment.view() - expect(typeof view).toBe('object') - expect(view.id).toBe(appointment.id) - expect(view.No).toBe(appointment.No) - expect(view.PatientName).toBe(appointment.PatientName) - expect(view.DocterName).toBe(appointment.DocterName) - expect(view.Date).toBe(appointment.Date) - expect(view.Time).toBe(appointment.Time) - expect(view.Departent).toBe(appointment.Departent) - expect(view.createdAt).toBeTruthy() - expect(view.updatedAt).toBeTruthy() - }) - - it('returns full view', () => { - const view = appointment.view(true) - expect(typeof view).toBe('object') - expect(view.id).toBe(appointment.id) - expect(view.No).toBe(appointment.No) - expect(view.PatientName).toBe(appointment.PatientName) - expect(view.DocterName).toBe(appointment.DocterName) - expect(view.Date).toBe(appointment.Date) - expect(view.Time).toBe(appointment.Time) - expect(view.Departent).toBe(appointment.Departent) - expect(view.createdAt).toBeTruthy() - expect(view.updatedAt).toBeTruthy() - }) -}) diff --git a/backend/src/api/department/index.js b/backend/src/api/department/index.js index 9b1604c..258ea2b 100644 --- a/backend/src/api/department/index.js +++ b/backend/src/api/department/index.js @@ -7,17 +7,17 @@ import { schema } from './model' export Department, { schema } from './model' const router = new Router() -const { Id, Name, NoofDoctor } = schema.tree +const { ID, Name, Nos } = schema.tree /** - * @api {post} /departments Create department + * @api {post} /Departments Create department * @apiName CreateDepartment * @apiGroup Department * @apiPermission admin * @apiParam {String} access_token admin access token. - * @apiParam Id Department's Id. + * @apiParam ID Department's ID. * @apiParam Name Department's Name. - * @apiParam NoofDoctor Department's NoofDoctor. + * @apiParam Nos Department's Nos. * @apiSuccess {Object} department Department's data. * @apiError {Object} 400 Some parameters may contain invalid values. * @apiError 404 Department not found. @@ -25,72 +25,56 @@ const { Id, Name, NoofDoctor } = schema.tree */ router.post('/', token({ required: true, roles: ['admin'] }), - body({ Id, Name, NoofDoctor }), + body({ ID, Name, Nos }), create) /** - * @api {get} /departments Retrieve departments + * @api {get} /Departments Retrieve departments * @apiName RetrieveDepartments * @apiGroup Department - * @apiPermission admin - * @apiParam {String} access_token admin access token. * @apiUse listParams * @apiSuccess {Number} count Total amount of departments. * @apiSuccess {Object[]} rows List of departments. * @apiError {Object} 400 Some parameters may contain invalid values. - * @apiError 401 admin access only. */ router.get('/', - token({ required: true, roles: ['admin'] }), query(), index) /** - * @api {get} /departments/:id Retrieve department + * @api {get} /Departments/:id Retrieve department * @apiName RetrieveDepartment * @apiGroup Department - * @apiPermission admin - * @apiParam {String} access_token admin access token. * @apiSuccess {Object} department Department's data. * @apiError {Object} 400 Some parameters may contain invalid values. * @apiError 404 Department not found. - * @apiError 401 admin access only. */ router.get('/:id', - token({ required: true, roles: ['admin'] }), show) /** - * @api {put} /departments/:id Update department + * @api {put} /Departments/:id Update department * @apiName UpdateDepartment * @apiGroup Department - * @apiPermission admin - * @apiParam {String} access_token admin access token. - * @apiParam Id Department's Id. + * @apiParam ID Department's ID. * @apiParam Name Department's Name. - * @apiParam NoofDoctor Department's NoofDoctor. + * @apiParam Nos Department's Nos. * @apiSuccess {Object} department Department's data. * @apiError {Object} 400 Some parameters may contain invalid values. * @apiError 404 Department not found. - * @apiError 401 admin access only. */ router.put('/:id', - token({ required: true, roles: ['admin'] }), - body({ Id, Name, NoofDoctor }), + body({ ID, Name, Nos }), update) /** - * @api {delete} /departments/:id Delete department + * @api {delete} /Departments/:id Delete department * @apiName DeleteDepartment * @apiGroup Department - * @apiPermission admin - * @apiParam {String} access_token admin access token. * @apiSuccess (Success 204) 204 No Content. * @apiError 404 Department not found. - * @apiError 401 admin access only. */ router.delete('/:id', - token({ required: true, roles: ['admin'] }), destroy) export default router diff --git a/backend/src/api/department/index.test.js b/backend/src/api/department/index.test.js index f6151b8..e5fa193 100644 --- a/backend/src/api/department/index.test.js +++ b/backend/src/api/department/index.test.js @@ -17,136 +17,79 @@ beforeEach(async () => { department = await Department.create({}) }) -test('POST /departments 201 (admin)', async () => { +test('POST /Departments 201 (admin)', async () => { const { status, body } = await request(app()) .post(`${apiRoot}`) - .send({ access_token: adminSession, Id: 'test', Name: 'test', NoofDoctor: 'test' }) + .send({ access_token: adminSession, ID: 'test', Name: 'test', Nos: 'test' }) expect(status).toBe(201) expect(typeof body).toEqual('object') - expect(body.Id).toEqual('test') + expect(body.ID).toEqual('test') expect(body.Name).toEqual('test') - expect(body.NoofDoctor).toEqual('test') + expect(body.Nos).toEqual('test') }) -test('POST /departments 401 (user)', async () => { +test('POST /Departments 401 (user)', async () => { const { status } = await request(app()) .post(`${apiRoot}`) .send({ access_token: userSession }) expect(status).toBe(401) }) -test('POST /departments 401', async () => { +test('POST /Departments 401', async () => { const { status } = await request(app()) .post(`${apiRoot}`) expect(status).toBe(401) }) -test('GET /departments 200 (admin)', async () => { +test('GET /Departments 200', async () => { const { status, body } = await request(app()) .get(`${apiRoot}`) - .query({ access_token: adminSession }) expect(status).toBe(200) expect(Array.isArray(body.rows)).toBe(true) expect(Number.isNaN(body.count)).toBe(false) }) -test('GET /departments 401 (user)', async () => { - const { status } = await request(app()) - .get(`${apiRoot}`) - .query({ access_token: userSession }) - expect(status).toBe(401) -}) - -test('GET /departments 401', async () => { - const { status } = await request(app()) - .get(`${apiRoot}`) - expect(status).toBe(401) -}) - -test('GET /departments/:id 200 (admin)', async () => { +test('GET /Departments/:id 200', async () => { const { status, body } = await request(app()) .get(`${apiRoot}/${department.id}`) - .query({ access_token: adminSession }) expect(status).toBe(200) expect(typeof body).toEqual('object') expect(body.id).toEqual(department.id) }) -test('GET /departments/:id 401 (user)', async () => { - const { status } = await request(app()) - .get(`${apiRoot}/${department.id}`) - .query({ access_token: userSession }) - expect(status).toBe(401) -}) - -test('GET /departments/:id 401', async () => { - const { status } = await request(app()) - .get(`${apiRoot}/${department.id}`) - expect(status).toBe(401) -}) - -test('GET /departments/:id 404 (admin)', async () => { +test('GET /Departments/:id 404', async () => { const { status } = await request(app()) .get(apiRoot + '/123456789098765432123456') - .query({ access_token: adminSession }) expect(status).toBe(404) }) -test('PUT /departments/:id 200 (admin)', async () => { +test('PUT /Departments/:id 200', async () => { const { status, body } = await request(app()) .put(`${apiRoot}/${department.id}`) - .send({ access_token: adminSession, Id: 'test', Name: 'test', NoofDoctor: 'test' }) + .send({ ID: 'test', Name: 'test', Nos: 'test' }) expect(status).toBe(200) expect(typeof body).toEqual('object') expect(body.id).toEqual(department.id) - expect(body.Id).toEqual('test') + expect(body.ID).toEqual('test') expect(body.Name).toEqual('test') - expect(body.NoofDoctor).toEqual('test') + expect(body.Nos).toEqual('test') }) -test('PUT /departments/:id 401 (user)', async () => { - const { status } = await request(app()) - .put(`${apiRoot}/${department.id}`) - .send({ access_token: userSession }) - expect(status).toBe(401) -}) - -test('PUT /departments/:id 401', async () => { - const { status } = await request(app()) - .put(`${apiRoot}/${department.id}`) - expect(status).toBe(401) -}) - -test('PUT /departments/:id 404 (admin)', async () => { +test('PUT /Departments/:id 404', async () => { const { status } = await request(app()) .put(apiRoot + '/123456789098765432123456') - .send({ access_token: adminSession, Id: 'test', Name: 'test', NoofDoctor: 'test' }) + .send({ ID: 'test', Name: 'test', Nos: 'test' }) expect(status).toBe(404) }) -test('DELETE /departments/:id 204 (admin)', async () => { +test('DELETE /Departments/:id 204', async () => { const { status } = await request(app()) .delete(`${apiRoot}/${department.id}`) - .query({ access_token: adminSession }) expect(status).toBe(204) }) -test('DELETE /departments/:id 401 (user)', async () => { - const { status } = await request(app()) - .delete(`${apiRoot}/${department.id}`) - .query({ access_token: userSession }) - expect(status).toBe(401) -}) - -test('DELETE /departments/:id 401', async () => { - const { status } = await request(app()) - .delete(`${apiRoot}/${department.id}`) - expect(status).toBe(401) -}) - -test('DELETE /departments/:id 404 (admin)', async () => { +test('DELETE /Departments/:id 404', async () => { const { status } = await request(app()) .delete(apiRoot + '/123456789098765432123456') - .query({ access_token: adminSession }) expect(status).toBe(404) }) diff --git a/backend/src/api/department/model.js b/backend/src/api/department/model.js index fd3c007..b030b8f 100644 --- a/backend/src/api/department/model.js +++ b/backend/src/api/department/model.js @@ -1,13 +1,13 @@ import mongoose, { Schema } from 'mongoose' const departmentSchema = new Schema({ - Id: { + ID: { type: String }, Name: { type: String }, - NoofDoctor: { + Nos: { type: String } }, { @@ -23,9 +23,9 @@ departmentSchema.methods = { const view = { // simple view id: this.id, - Id: this.Id, + ID: this.ID, Name: this.Name, - NoofDoctor: this.NoofDoctor, + Nos: this.Nos, createdAt: this.createdAt, updatedAt: this.updatedAt } diff --git a/backend/src/api/department/model.test.js b/backend/src/api/department/model.test.js index 3d95398..6d04cfe 100644 --- a/backend/src/api/department/model.test.js +++ b/backend/src/api/department/model.test.js @@ -3,7 +3,7 @@ import { Department } from '.' let department beforeEach(async () => { - department = await Department.create({ Id: 'test', Name: 'test', NoofDoctor: 'test' }) + department = await Department.create({ ID: 'test', Name: 'test', Nos: 'test' }) }) describe('view', () => { @@ -11,9 +11,9 @@ describe('view', () => { const view = department.view() expect(typeof view).toBe('object') expect(view.id).toBe(department.id) - expect(view.Id).toBe(department.Id) + expect(view.ID).toBe(department.ID) expect(view.Name).toBe(department.Name) - expect(view.NoofDoctor).toBe(department.NoofDoctor) + expect(view.Nos).toBe(department.Nos) expect(view.createdAt).toBeTruthy() expect(view.updatedAt).toBeTruthy() }) @@ -22,9 +22,9 @@ describe('view', () => { const view = department.view(true) expect(typeof view).toBe('object') expect(view.id).toBe(department.id) - expect(view.Id).toBe(department.Id) + expect(view.ID).toBe(department.ID) expect(view.Name).toBe(department.Name) - expect(view.NoofDoctor).toBe(department.NoofDoctor) + expect(view.Nos).toBe(department.Nos) expect(view.createdAt).toBeTruthy() expect(view.updatedAt).toBeTruthy() }) diff --git a/backend/src/api/doctor/index.js b/backend/src/api/doctor/index.js index 38ab14a..857d0b5 100644 --- a/backend/src/api/doctor/index.js +++ b/backend/src/api/doctor/index.js @@ -7,17 +7,17 @@ import { schema } from './model' export Doctor, { schema } from './model' const router = new Router() -const { Id, Name, Department } = schema.tree +const { ID, Name, Dapartment } = schema.tree /** - * @api {post} /doctors Create doctor + * @api {post} /Doctors Create doctor * @apiName CreateDoctor * @apiGroup Doctor * @apiPermission admin * @apiParam {String} access_token admin access token. - * @apiParam Id Doctor's Id. + * @apiParam ID Doctor's ID. * @apiParam Name Doctor's Name. - * @apiParam Department Doctor's Department. + * @apiParam Dapartment Doctor's Dapartment. * @apiSuccess {Object} doctor Doctor's data. * @apiError {Object} 400 Some parameters may contain invalid values. * @apiError 404 Doctor not found. @@ -25,11 +25,11 @@ const { Id, Name, Department } = schema.tree */ router.post('/', token({ required: true, roles: ['admin'] }), - body({ Id, Name, Department }), + body({ ID, Name, Dapartment }), create) /** - * @api {get} /doctors Retrieve doctors + * @api {get} /Doctors Retrieve doctors * @apiName RetrieveDoctors * @apiGroup Doctor * @apiPermission admin @@ -46,7 +46,7 @@ router.get('/', index) /** - * @api {get} /doctors/:id Retrieve doctor + * @api {get} /Doctors/:id Retrieve doctor * @apiName RetrieveDoctor * @apiGroup Doctor * @apiPermission admin @@ -61,14 +61,14 @@ router.get('/:id', show) /** - * @api {put} /doctors/:id Update doctor + * @api {put} /Doctors/:id Update doctor * @apiName UpdateDoctor * @apiGroup Doctor * @apiPermission admin * @apiParam {String} access_token admin access token. - * @apiParam Id Doctor's Id. + * @apiParam ID Doctor's ID. * @apiParam Name Doctor's Name. - * @apiParam Department Doctor's Department. + * @apiParam Dapartment Doctor's Dapartment. * @apiSuccess {Object} doctor Doctor's data. * @apiError {Object} 400 Some parameters may contain invalid values. * @apiError 404 Doctor not found. @@ -76,11 +76,11 @@ router.get('/:id', */ router.put('/:id', token({ required: true, roles: ['admin'] }), - body({ Id, Name, Department }), + body({ ID, Name, Dapartment }), update) /** - * @api {delete} /doctors/:id Delete doctor + * @api {delete} /Doctors/:id Delete doctor * @apiName DeleteDoctor * @apiGroup Doctor * @apiPermission admin diff --git a/backend/src/api/doctor/index.test.js b/backend/src/api/doctor/index.test.js index 4a64c11..bf393fb 100644 --- a/backend/src/api/doctor/index.test.js +++ b/backend/src/api/doctor/index.test.js @@ -17,31 +17,31 @@ beforeEach(async () => { doctor = await Doctor.create({}) }) -test('POST /doctors 201 (admin)', async () => { +test('POST /Doctors 201 (admin)', async () => { const { status, body } = await request(app()) .post(`${apiRoot}`) - .send({ access_token: adminSession, Id: 'test', Name: 'test', Department: 'test' }) + .send({ access_token: adminSession, ID: 'test', Name: 'test', Dapartment: 'test' }) expect(status).toBe(201) expect(typeof body).toEqual('object') - expect(body.Id).toEqual('test') + expect(body.ID).toEqual('test') expect(body.Name).toEqual('test') - expect(body.Department).toEqual('test') + expect(body.Dapartment).toEqual('test') }) -test('POST /doctors 401 (user)', async () => { +test('POST /Doctors 401 (user)', async () => { const { status } = await request(app()) .post(`${apiRoot}`) .send({ access_token: userSession }) expect(status).toBe(401) }) -test('POST /doctors 401', async () => { +test('POST /Doctors 401', async () => { const { status } = await request(app()) .post(`${apiRoot}`) expect(status).toBe(401) }) -test('GET /doctors 200 (admin)', async () => { +test('GET /Doctors 200 (admin)', async () => { const { status, body } = await request(app()) .get(`${apiRoot}`) .query({ access_token: adminSession }) @@ -50,20 +50,20 @@ test('GET /doctors 200 (admin)', async () => { expect(Number.isNaN(body.count)).toBe(false) }) -test('GET /doctors 401 (user)', async () => { +test('GET /Doctors 401 (user)', async () => { const { status } = await request(app()) .get(`${apiRoot}`) .query({ access_token: userSession }) expect(status).toBe(401) }) -test('GET /doctors 401', async () => { +test('GET /Doctors 401', async () => { const { status } = await request(app()) .get(`${apiRoot}`) expect(status).toBe(401) }) -test('GET /doctors/:id 200 (admin)', async () => { +test('GET /Doctors/:id 200 (admin)', async () => { const { status, body } = await request(app()) .get(`${apiRoot}/${doctor.id}`) .query({ access_token: adminSession }) @@ -72,79 +72,79 @@ test('GET /doctors/:id 200 (admin)', async () => { expect(body.id).toEqual(doctor.id) }) -test('GET /doctors/:id 401 (user)', async () => { +test('GET /Doctors/:id 401 (user)', async () => { const { status } = await request(app()) .get(`${apiRoot}/${doctor.id}`) .query({ access_token: userSession }) expect(status).toBe(401) }) -test('GET /doctors/:id 401', async () => { +test('GET /Doctors/:id 401', async () => { const { status } = await request(app()) .get(`${apiRoot}/${doctor.id}`) expect(status).toBe(401) }) -test('GET /doctors/:id 404 (admin)', async () => { +test('GET /Doctors/:id 404 (admin)', async () => { const { status } = await request(app()) .get(apiRoot + '/123456789098765432123456') .query({ access_token: adminSession }) expect(status).toBe(404) }) -test('PUT /doctors/:id 200 (admin)', async () => { +test('PUT /Doctors/:id 200 (admin)', async () => { const { status, body } = await request(app()) .put(`${apiRoot}/${doctor.id}`) - .send({ access_token: adminSession, Id: 'test', Name: 'test', Department: 'test' }) + .send({ access_token: adminSession, ID: 'test', Name: 'test', Dapartment: 'test' }) expect(status).toBe(200) expect(typeof body).toEqual('object') expect(body.id).toEqual(doctor.id) - expect(body.Id).toEqual('test') + expect(body.ID).toEqual('test') expect(body.Name).toEqual('test') - expect(body.Department).toEqual('test') + expect(body.Dapartment).toEqual('test') }) -test('PUT /doctors/:id 401 (user)', async () => { +test('PUT /Doctors/:id 401 (user)', async () => { const { status } = await request(app()) .put(`${apiRoot}/${doctor.id}`) .send({ access_token: userSession }) expect(status).toBe(401) }) -test('PUT /doctors/:id 401', async () => { +test('PUT /Doctors/:id 401', async () => { const { status } = await request(app()) .put(`${apiRoot}/${doctor.id}`) expect(status).toBe(401) }) -test('PUT /doctors/:id 404 (admin)', async () => { +test('PUT /Doctors/:id 404 (admin)', async () => { const { status } = await request(app()) .put(apiRoot + '/123456789098765432123456') - .send({ access_token: adminSession, Id: 'test', Name: 'test', Department: 'test' }) + .send({ access_token: adminSession, ID: 'test', Name: 'test', Dapartment: 'test' }) expect(status).toBe(404) }) -test('DELETE /doctors/:id 204 (admin)', async () => { +test('DELETE /Doctors/:id 204 (admin)', async () => { const { status } = await request(app()) .delete(`${apiRoot}/${doctor.id}`) .query({ access_token: adminSession }) expect(status).toBe(204) }) -test('DELETE /doctors/:id 401 (user)', async () => { +test('DELETE /Doctors/:id 401 (user)', async () => { const { status } = await request(app()) .delete(`${apiRoot}/${doctor.id}`) .query({ access_token: userSession }) expect(status).toBe(401) }) -test('DELETE /doctors/:id 401', async () => { +test('DELETE /Doctors/:id 401', async () => { const { status } = await request(app()) .delete(`${apiRoot}/${doctor.id}`) expect(status).toBe(401) }) -test('DELETE /doctors/:id 404 (admin)', async () => { +test('DELETE /Doctors/:id 404 (admin)', async () => { const { status } = await request(app()) .delete(apiRoot + '/123456789098765432123456') .query({ access_token: adminSession }) diff --git a/backend/src/api/doctor/model.js b/backend/src/api/doctor/model.js index 01717ef..5c0283f 100644 --- a/backend/src/api/doctor/model.js +++ b/backend/src/api/doctor/model.js @@ -1,13 +1,13 @@ import mongoose, { Schema } from 'mongoose' const doctorSchema = new Schema({ - Id: { + ID: { type: String }, Name: { type: String }, - Department: { + Dapartment: { type: String } }, { @@ -23,9 +23,9 @@ doctorSchema.methods = { const view = { // simple view id: this.id, - Id: this.Id, + ID: this.ID, Name: this.Name, - Department: this.Department, + Dapartment: this.Dapartment, createdAt: this.createdAt, updatedAt: this.updatedAt } diff --git a/backend/src/api/doctor/model.test.js b/backend/src/api/doctor/model.test.js index 8b6153c..102a801 100644 --- a/backend/src/api/doctor/model.test.js +++ b/backend/src/api/doctor/model.test.js @@ -3,7 +3,7 @@ import { Doctor } from '.' let doctor beforeEach(async () => { - doctor = await Doctor.create({ Id: 'test', Name: 'test', Department: 'test' }) + doctor = await Doctor.create({ ID: 'test', Name: 'test', Dapartment: 'test' }) }) describe('view', () => { @@ -11,9 +11,9 @@ describe('view', () => { const view = doctor.view() expect(typeof view).toBe('object') expect(view.id).toBe(doctor.id) - expect(view.Id).toBe(doctor.Id) + expect(view.ID).toBe(doctor.ID) expect(view.Name).toBe(doctor.Name) - expect(view.Department).toBe(doctor.Department) + expect(view.Dapartment).toBe(doctor.Dapartment) expect(view.createdAt).toBeTruthy() expect(view.updatedAt).toBeTruthy() }) @@ -22,9 +22,9 @@ describe('view', () => { const view = doctor.view(true) expect(typeof view).toBe('object') expect(view.id).toBe(doctor.id) - expect(view.Id).toBe(doctor.Id) + expect(view.ID).toBe(doctor.ID) expect(view.Name).toBe(doctor.Name) - expect(view.Department).toBe(doctor.Department) + expect(view.Dapartment).toBe(doctor.Dapartment) expect(view.createdAt).toBeTruthy() expect(view.updatedAt).toBeTruthy() }) diff --git a/backend/src/api/index.js b/backend/src/api/index.js index 8ca4498..3f52c14 100644 --- a/backend/src/api/index.js +++ b/backend/src/api/index.js @@ -1,9 +1,9 @@ import { Router } from 'express' import user from './user' import auth from './auth' -import appointment from './appointment' -import department from './department' -import doctor from './doctor' +import apointment from './apointment' +import department from './Department' +import doctor from './Doctor' const router = new Router() @@ -32,8 +32,8 @@ const router = new Router() */ router.use('/users', user) router.use('/auth', auth) -router.use('/appointments', appointment) -router.use('/departments', department) -router.use('/doctors', doctor) +router.use('/apointments', apointment) +router.use('/Departments', department) +router.use('/Doctors', doctor) export default router diff --git a/backend/src/api/user/controller.js b/backend/src/api/user/controller.js index e1e5262..fd0562a 100644 --- a/backend/src/api/user/controller.js +++ b/backend/src/api/user/controller.js @@ -1,6 +1,5 @@ import { success, notFound } from '../../services/response/' import { User } from '.' -import { sign } from '../../services/jwt' export const index = ({ querymen: { query, select, cursor } }, res, next) => User.count(query) @@ -25,11 +24,8 @@ export const showMe = ({ user }, res) => export const create = ({ bodymen: { body } }, res, next) => User.create(body) - .then(user => { - sign(user.id) - .then((token) => ({ token, user: user.view(true) })) - .then(success(res, 201)) - }) + .then((user) => user.view(true)) + .then(success(res, 201)) .catch((err) => { /* istanbul ignore else */ if (err.name === 'MongoError' && err.code === 11000) { diff --git a/backend/src/api/user/index.test.js b/backend/src/api/user/index.test.js index 21afb96..5c0b1a3 100644 --- a/backend/src/api/user/index.test.js +++ b/backend/src/api/user/index.test.js @@ -104,9 +104,7 @@ test('POST /users 201 (master)', async () => { .send({ access_token: masterKey, email: 'd@d.com', password: '123456' }) expect(status).toBe(201) expect(typeof body).toBe('object') - expect(typeof body.user).toBe('object') - expect(typeof body.token).toBe('string') - expect(body.user.email).toBe('d@d.com') + expect(body.email).toBe('d@d.com') }) test('POST /users 201 (master)', async () => { @@ -115,9 +113,7 @@ test('POST /users 201 (master)', async () => { .send({ access_token: masterKey, email: 'd@d.com', password: '123456', role: 'user' }) expect(status).toBe(201) expect(typeof body).toBe('object') - expect(typeof body.user).toBe('object') - expect(typeof body.token).toBe('string') - expect(body.user.email).toBe('d@d.com') + expect(body.email).toBe('d@d.com') }) test('POST /users 201 (master)', async () => { @@ -126,9 +122,7 @@ test('POST /users 201 (master)', async () => { .send({ access_token: masterKey, email: 'd@d.com', password: '123456', role: 'admin' }) expect(status).toBe(201) expect(typeof body).toBe('object') - expect(typeof body.user).toBe('object') - expect(typeof body.token).toBe('string') - expect(body.user.email).toBe('d@d.com') + expect(body.email).toBe('d@d.com') }) test('POST /users 409 (master) - duplicated email', async () => { diff --git a/backend/src/config.js b/backend/src/config.js index 01a96d1..452f038 100644 --- a/backend/src/config.js +++ b/backend/src/config.js @@ -39,7 +39,7 @@ const config = { test: { }, development: { mongo: { - uri: process.env.MONGODB_URI_DEV || 'mongodb://localhost/docter-appointment-dev', + uri: 'mongodb://localhost/doctor-apointment-dev', options: { debug: true } @@ -49,7 +49,7 @@ const config = { ip: process.env.IP || undefined, port: process.env.PORT || 8080, mongo: { - uri: process.env.MONGODB_URI_DEV || 'mongodb://localhost/docter-appointment' + uri: process.env.MONGODB_URI || 'mongodb://localhost/doctor-apointment' } } }