-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1184073
commit db88b3b
Showing
12 changed files
with
2,335 additions
and
198 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,44 @@ | ||
import ClinicService from "../service/clinic-service.js"; | ||
import ClinicService from '../service/clinic-service.js'; | ||
import { EMPTY_SIZE, ERROR_STATUS_CODE, NOT_FOUND_STATUS_CODE, OK_STATUS_CODE } from '../utils/Constants.js'; | ||
|
||
export const clinic = (app) =>{ | ||
const service = new ClinicService(); | ||
export const clinic = (app) => { | ||
const service = new ClinicService(); | ||
|
||
app.get('/all-packages', async (req,res)=>{ | ||
const allPackages = await service.getAllPackages(); | ||
if(allPackages.length > 0){ | ||
res.status(200).json({allPackages}); | ||
}else{ | ||
res.status(404).json({message:"patients not found"}); | ||
} | ||
}); | ||
app.get('/all-packages', async (req,res) => { | ||
const allPackages = await service.getAllPackages(); | ||
if(allPackages.length > EMPTY_SIZE){ | ||
res.status(OK_STATUS_CODE).json({ allPackages }); | ||
}else{ | ||
res.status(NOT_FOUND_STATUS_CODE).json({ message:'patients not found' }); | ||
} | ||
}); | ||
|
||
app.post('/new-package', async (req, res)=>{ | ||
app.post('/new-package', async (req, res) => { | ||
|
||
const {name, price, discountOfDoctor, discountOfMedicin, discountOfFamily} = req.body; | ||
console.log({name}); | ||
const { name, price, discountOfDoctor, discountOfMedicin, discountOfFamily } = req.body; | ||
console.log({ name }); | ||
|
||
const data = await service.createNewPackage(name, price, discountOfDoctor, discountOfMedicin, discountOfFamily); | ||
if(data){ | ||
res.status(200).json({data}); | ||
}else{ | ||
res.status(500); | ||
} | ||
}); | ||
const data = await service.createNewPackage(name, price, discountOfDoctor, discountOfMedicin, discountOfFamily); | ||
if(data){ | ||
res.status(OK_STATUS_CODE).json({ data }); | ||
}else{ | ||
res.status(ERROR_STATUS_CODE); | ||
} | ||
}); | ||
|
||
app.patch('/edit-package', async (req,res)=>{ | ||
// app.patch('/edit-package', async (req,res) => { | ||
|
||
}); | ||
// }); | ||
|
||
app.delete('/remove-package/:id', async (req,res)=>{ | ||
const id = req.params.id; | ||
try{ | ||
console.log(id); | ||
const deletedPackage = await service.deletePackage(id); | ||
res.status(200).json({deletedPackage}); | ||
}catch(err){ | ||
res.status(500).json({err : err.message}); | ||
} | ||
}); | ||
app.delete('/remove-package/:id', async (req,res) => { | ||
const id = req.params.id; | ||
try{ | ||
console.log(id); | ||
const deletedPackage = await service.deletePackage(id); | ||
res.status(OK_STATUS_CODE).json({ deletedPackage }); | ||
}catch(err){ | ||
res.status(ERROR_STATUS_CODE).json({ err : err.message }); | ||
} | ||
}); | ||
|
||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
import mongoose from "mongoose"; | ||
import mongoose from 'mongoose'; | ||
|
||
const UserSchema = mongoose.Schema({ | ||
name: { | ||
type: String, | ||
required: true | ||
}, | ||
name: { | ||
type: String, | ||
required: true | ||
}, | ||
|
||
userName: { | ||
type: String, | ||
required: true, | ||
unique: true | ||
}, | ||
userName: { | ||
type: String, | ||
required: true, | ||
unique: true | ||
}, | ||
|
||
email: { | ||
type: String, | ||
required: true, | ||
unique: true | ||
}, | ||
email: { | ||
type: String, | ||
required: true, | ||
unique: true | ||
}, | ||
|
||
password: { | ||
type: String, | ||
required: true | ||
}, | ||
password: { | ||
type: String, | ||
required: true | ||
}, | ||
|
||
dateOfBirth: { | ||
type: Date, | ||
required: true | ||
} | ||
dateOfBirth: { | ||
type: Date, | ||
required: true | ||
} | ||
}); | ||
|
||
export default UserSchema; |
Oops, something went wrong.