This commit is contained in:
Jyotirmoy Bandyopadhayaya 2020-10-23 13:56:46 +05:30
parent 4b79165027
commit 716eedf420
14 changed files with 73 additions and 70 deletions

View File

@ -1,2 +1,3 @@
MASTER_KEY=dyB4cPIZpFV6X7VIYyKIWRC4GLUKQoV2
JWT_SECRET=sfDI9AxQb5zpNqVuDB4uB9jw1asIETH2
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

2
backend/.env.example Normal file
View File

@ -0,0 +1,2 @@
MASTER_KEY=dyB4cPIZpFV6X7VIYyKIWRC4GLUKQoV2
JWT_SECRET=sfDI9AxQb5zpNqVuDB4uB9jw1asIETH2

View File

@ -51,8 +51,8 @@
| Name | Type | Description |
|---------|-----------|--------------------------------------|
| No | | <p>Appointment's No.</p> |
| Patient-Name | | <p>Appointment's Patient-Name.</p> |
| Docter-Name | | <p>Appointment's Docter-Name.</p> |
| PatientName | | <p>Appointment's PatientName.</p> |
| DocterName | | <p>Appointment's DocterName.</p> |
| Date | | <p>Appointment's Date.</p> |
| Time | | <p>Appointment's Time.</p> |
| Departent | | <p>Appointment's Departent.</p> |
@ -108,8 +108,8 @@
|---------|-----------|--------------------------------------|
| access_token | String | <p>admin access token.</p> |
| No | | <p>Appointment's No.</p> |
| Patient-Name | | <p>Appointment's Patient-Name.</p> |
| Docter-Name | | <p>Appointment's Docter-Name.</p> |
| PatientName | | <p>Appointment's PatientName.</p> |
| DocterName | | <p>Appointment's DocterName.</p> |
| Date | | <p>Appointment's Date.</p> |
| Time | | <p>Appointment's Time.</p> |
| Departent | | <p>Appointment's Departent.</p> |
@ -150,7 +150,7 @@
| access_token | String | <p>admin access token.</p> |
| Id | | <p>Department's Id.</p> |
| Name | | <p>Department's Name.</p> |
| Nos. | | <p>of Doctor Department's Nos. of Doctor.</p> |
| Nos | | <p>of Doctor Department's NoofDoctor.</p> |
## Delete department
@ -210,7 +210,7 @@
| access_token | String | <p>admin access token.</p> |
| Id | | <p>Department's Id.</p> |
| Name | | <p>Department's Name.</p> |
| Nos. | | <p>of Doctor Department's Nos. of Doctor.</p> |
| Nos | | <p>of Doctor Department's NoofDoctor.</p> |
# Doctor

View File

@ -17,14 +17,14 @@ define({ "api": [
{
"group": "Parameter",
"optional": false,
"field": "Patient-Name",
"description": "<p>Appointment's Patient-Name.</p>"
"field": "PatientName",
"description": "<p>Appointment's PatientName.</p>"
},
{
"group": "Parameter",
"optional": false,
"field": "Docter-Name",
"description": "<p>Appointment's Docter-Name.</p>"
"field": "DocterName",
"description": "<p>Appointment's DocterName.</p>"
},
{
"group": "Parameter",
@ -326,14 +326,14 @@ define({ "api": [
{
"group": "Parameter",
"optional": false,
"field": "Patient-Name",
"description": "<p>Appointment's Patient-Name.</p>"
"field": "PatientName",
"description": "<p>Appointment's PatientName.</p>"
},
{
"group": "Parameter",
"optional": false,
"field": "Docter-Name",
"description": "<p>Appointment's Docter-Name.</p>"
"field": "DocterName",
"description": "<p>Appointment's DocterName.</p>"
},
{
"group": "Parameter",
@ -511,8 +511,8 @@ define({ "api": [
{
"group": "Parameter",
"optional": false,
"field": "Nos.",
"description": "<p>of Doctor Department's Nos. of Doctor.</p>"
"field": "Nos",
"description": "<p>of Doctor Department's NoofDoctor.</p>"
}
]
}
@ -834,8 +834,8 @@ define({ "api": [
{
"group": "Parameter",
"optional": false,
"field": "Nos.",
"description": "<p>of Doctor Department's Nos. of Doctor.</p>"
"field": "Nos",
"description": "<p>of Doctor Department's NoofDoctor.</p>"
}
]
}

View File

@ -17,14 +17,14 @@
{
"group": "Parameter",
"optional": false,
"field": "Patient-Name",
"description": "<p>Appointment's Patient-Name.</p>"
"field": "PatientName",
"description": "<p>Appointment's PatientName.</p>"
},
{
"group": "Parameter",
"optional": false,
"field": "Docter-Name",
"description": "<p>Appointment's Docter-Name.</p>"
"field": "DocterName",
"description": "<p>Appointment's DocterName.</p>"
},
{
"group": "Parameter",
@ -326,14 +326,14 @@
{
"group": "Parameter",
"optional": false,
"field": "Patient-Name",
"description": "<p>Appointment's Patient-Name.</p>"
"field": "PatientName",
"description": "<p>Appointment's PatientName.</p>"
},
{
"group": "Parameter",
"optional": false,
"field": "Docter-Name",
"description": "<p>Appointment's Docter-Name.</p>"
"field": "DocterName",
"description": "<p>Appointment's DocterName.</p>"
},
{
"group": "Parameter",
@ -511,8 +511,8 @@
{
"group": "Parameter",
"optional": false,
"field": "Nos.",
"description": "<p>of Doctor Department's Nos. of Doctor.</p>"
"field": "Nos",
"description": "<p>of Doctor Department's NoofDoctor.</p>"
}
]
}
@ -834,8 +834,8 @@
{
"group": "Parameter",
"optional": false,
"field": "Nos.",
"description": "<p>of Doctor Department's Nos. of Doctor.</p>"
"field": "Nos",
"description": "<p>of Doctor Department's NoofDoctor.</p>"
}
]
}

View File

@ -7,15 +7,15 @@ import { schema } from './model'
export Appointment, { schema } from './model'
const router = new Router()
const { No, Patient-Name, Docter-Name, Date, Time, Departent } = schema.tree
const { No, PatientName, DocterName, Date, Time, Departent } = schema.tree
/**
* @api {post} /appointments Create appointment
* @apiName CreateAppointment
* @apiGroup Appointment
* @apiParam No Appointment's No.
* @apiParam Patient-Name Appointment's Patient-Name.
* @apiParam Docter-Name Appointment's Docter-Name.
* @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.
@ -24,7 +24,7 @@ const { No, Patient-Name, Docter-Name, Date, Time, Departent } = schema.tree
* @apiError 404 Appointment not found.
*/
router.post('/',
body({ No, Patient-Name, Docter-Name, Date, Time, Departent }),
body({ No, PatientName, DocterName, Date, Time, Departent }),
create)
/**
@ -62,8 +62,8 @@ router.get('/:id',
* @apiPermission admin
* @apiParam {String} access_token admin access token.
* @apiParam No Appointment's No.
* @apiParam Patient-Name Appointment's Patient-Name.
* @apiParam Docter-Name Appointment's Docter-Name.
* @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.
@ -74,7 +74,7 @@ router.get('/:id',
*/
router.put('/:id',
token({ required: true, roles: ['admin'] }),
body({ No, Patient-Name, Docter-Name, Date, Time, Departent }),
body({ No, PatientName, DocterName, Date, Time, Departent }),
update)
/**

View File

@ -20,12 +20,12 @@ beforeEach(async () => {
test('POST /appointments 201', async () => {
const { status, body } = await request(app())
.post(`${apiRoot}`)
.send({ No: 'test', Patient-Name: 'test', Docter-Name: 'test', Date: 'test', Time: 'test', Departent: 'test' })
.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.Patient-Name).toEqual('test')
expect(body.Docter-Name).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')
@ -70,13 +70,13 @@ test('GET /appointments/:id 404', async () => {
test('PUT /appointments/:id 200 (admin)', async () => {
const { status, body } = await request(app())
.put(`${apiRoot}/${appointment.id}`)
.send({ access_token: adminSession, No: 'test', Patient-Name: 'test', Docter-Name: 'test', Date: 'test', Time: 'test', Departent: 'test' })
.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.Patient-Name).toEqual('test')
expect(body.Docter-Name).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')
@ -98,7 +98,7 @@ test('PUT /appointments/:id 401', async () => {
test('PUT /appointments/:id 404 (admin)', async () => {
const { status } = await request(app())
.put(apiRoot + '/123456789098765432123456')
.send({ access_token: adminSession, No: 'test', Patient-Name: 'test', Docter-Name: 'test', Date: 'test', Time: 'test', Departent: 'test' })
.send({ access_token: adminSession, No: 'test', PatientName: 'test', DocterName: 'test', Date: 'test', Time: 'test', Departent: 'test' })
expect(status).toBe(404)
})

View File

@ -4,10 +4,10 @@ const appointmentSchema = new Schema({
No: {
type: String
},
Patient-Name: {
PatientName: {
type: String
},
Docter-Name: {
DocterName: {
type: String
},
Date: {
@ -33,8 +33,8 @@ appointmentSchema.methods = {
// simple view
id: this.id,
No: this.No,
Patient-Name: this.Patient-Name,
Docter-Name: this.Docter-Name,
PatientName: this.PatientName,
DocterName: this.DocterName,
Date: this.Date,
Time: this.Time,
Departent: this.Departent,

View File

@ -3,7 +3,7 @@ import { Appointment } from '.'
let appointment
beforeEach(async () => {
appointment = await Appointment.create({ No: 'test', Patient-Name: 'test', Docter-Name: 'test', Date: 'test', Time: 'test', Departent: 'test' })
appointment = await Appointment.create({ No: 'test', PatientName: 'test', DocterName: 'test', Date: 'test', Time: 'test', Departent: 'test' })
})
describe('view', () => {
@ -12,8 +12,8 @@ describe('view', () => {
expect(typeof view).toBe('object')
expect(view.id).toBe(appointment.id)
expect(view.No).toBe(appointment.No)
expect(view.Patient-Name).toBe(appointment.Patient-Name)
expect(view.Docter-Name).toBe(appointment.Docter-Name)
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)
@ -26,8 +26,8 @@ describe('view', () => {
expect(typeof view).toBe('object')
expect(view.id).toBe(appointment.id)
expect(view.No).toBe(appointment.No)
expect(view.Patient-Name).toBe(appointment.Patient-Name)
expect(view.Docter-Name).toBe(appointment.Docter-Name)
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)

View File

@ -7,7 +7,7 @@ import { schema } from './model'
export Department, { schema } from './model'
const router = new Router()
const { Id, Name, Nos. of Doctor } = schema.tree
const { Id, Name, NoofDoctor } = schema.tree
/**
* @api {post} /departments Create department
@ -17,7 +17,7 @@ const { Id, Name, Nos. of Doctor } = schema.tree
* @apiParam {String} access_token admin access token.
* @apiParam Id Department's Id.
* @apiParam Name Department's Name.
* @apiParam Nos. of Doctor Department's Nos. of Doctor.
* @apiParam NoofDoctor Department's NoofDoctor.
* @apiSuccess {Object} department Department's data.
* @apiError {Object} 400 Some parameters may contain invalid values.
* @apiError 404 Department not found.
@ -25,7 +25,7 @@ const { Id, Name, Nos. of Doctor } = schema.tree
*/
router.post('/',
token({ required: true, roles: ['admin'] }),
body({ Id, Name, Nos. of Doctor }),
body({ Id, Name, NoofDoctor }),
create)
/**
@ -68,7 +68,7 @@ router.get('/:id',
* @apiParam {String} access_token admin access token.
* @apiParam Id Department's Id.
* @apiParam Name Department's Name.
* @apiParam Nos. of Doctor Department's Nos. of Doctor.
* @apiParam NoofDoctor Department's NoofDoctor.
* @apiSuccess {Object} department Department's data.
* @apiError {Object} 400 Some parameters may contain invalid values.
* @apiError 404 Department not found.
@ -76,7 +76,7 @@ router.get('/:id',
*/
router.put('/:id',
token({ required: true, roles: ['admin'] }),
body({ Id, Name, Nos. of Doctor }),
body({ Id, Name, NoofDoctor }),
update)
/**

View File

@ -20,12 +20,12 @@ beforeEach(async () => {
test('POST /departments 201 (admin)', async () => {
const { status, body } = await request(app())
.post(`${apiRoot}`)
.send({ access_token: adminSession, Id: 'test', Name: 'test', Nos. of Doctor: 'test' })
.send({ access_token: adminSession, Id: 'test', Name: 'test', NoofDoctor: 'test' })
expect(status).toBe(201)
expect(typeof body).toEqual('object')
expect(body.Id).toEqual('test')
expect(body.Name).toEqual('test')
expect(body.Nos. of Doctor).toEqual('test')
expect(body.NoofDoctor).toEqual('test')
})
test('POST /departments 401 (user)', async () => {
@ -95,13 +95,13 @@ test('GET /departments/:id 404 (admin)', async () => {
test('PUT /departments/:id 200 (admin)', async () => {
const { status, body } = await request(app())
.put(`${apiRoot}/${department.id}`)
.send({ access_token: adminSession, Id: 'test', Name: 'test', Nos. of Doctor: 'test' })
.send({ access_token: adminSession, Id: 'test', Name: 'test', NoofDoctor: 'test' })
expect(status).toBe(200)
expect(typeof body).toEqual('object')
expect(body.id).toEqual(department.id)
expect(body.Id).toEqual('test')
expect(body.Name).toEqual('test')
expect(body.Nos. of Doctor).toEqual('test')
expect(body.NoofDoctor).toEqual('test')
})
test('PUT /departments/:id 401 (user)', async () => {
@ -120,7 +120,7 @@ test('PUT /departments/:id 401', async () => {
test('PUT /departments/:id 404 (admin)', async () => {
const { status } = await request(app())
.put(apiRoot + '/123456789098765432123456')
.send({ access_token: adminSession, Id: 'test', Name: 'test', Nos. of Doctor: 'test' })
.send({ access_token: adminSession, Id: 'test', Name: 'test', NoofDoctor: 'test' })
expect(status).toBe(404)
})

View File

@ -7,7 +7,7 @@ const departmentSchema = new Schema({
Name: {
type: String
},
Nos. of Doctor: {
NoofDoctor: {
type: String
}
}, {
@ -25,7 +25,7 @@ departmentSchema.methods = {
id: this.id,
Id: this.Id,
Name: this.Name,
Nos. of Doctor: this.Nos. of Doctor,
NoofDoctor: this.NoofDoctor,
createdAt: this.createdAt,
updatedAt: this.updatedAt
}

View File

@ -3,7 +3,7 @@ import { Department } from '.'
let department
beforeEach(async () => {
department = await Department.create({ Id: 'test', Name: 'test', Nos. of Doctor: 'test' })
department = await Department.create({ Id: 'test', Name: 'test', NoofDoctor: 'test' })
})
describe('view', () => {
@ -13,7 +13,7 @@ describe('view', () => {
expect(view.id).toBe(department.id)
expect(view.Id).toBe(department.Id)
expect(view.Name).toBe(department.Name)
expect(view.Nos. of Doctor).toBe(department.Nos. of Doctor)
expect(view.NoofDoctor).toBe(department.NoofDoctor)
expect(view.createdAt).toBeTruthy()
expect(view.updatedAt).toBeTruthy()
})
@ -24,7 +24,7 @@ describe('view', () => {
expect(view.id).toBe(department.id)
expect(view.Id).toBe(department.Id)
expect(view.Name).toBe(department.Name)
expect(view.Nos. of Doctor).toBe(department.Nos. of Doctor)
expect(view.NoofDoctor).toBe(department.NoofDoctor)
expect(view.createdAt).toBeTruthy()
expect(view.updatedAt).toBeTruthy()
})

View File

@ -39,7 +39,7 @@ const config = {
test: { },
development: {
mongo: {
uri: 'mongodb://localhost/docter-appointment-dev',
uri: process.env.MONGODB_URI_DEV || 'mongodb://localhost/docter-appointment-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 || 'mongodb://localhost/docter-appointment'
uri: process.env.MONGODB_URI_DEV || 'mongodb://localhost/docter-appointment'
}
}
}