Skip to content

Commit

Permalink
merging with main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed-Khaled308 committed Oct 7, 2023
2 parents a1f1c06 + 97d0028 commit 2346f41
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion clinic/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@
"arrow-spacing": ["error", { "before": true, "after": true }],
"no-duplicate-imports": "error",
"prefer-const": "error"
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@

import HealthPackageService from '../service/healthpackage-service.js';
import HealthPackageService from '../service/health-package-service.js';
import { EMPTY_SIZE, ERROR_STATUS_CODE, NOT_FOUND_STATUS_CODE, OK_STATUS_CODE } from '../utils/Constants.js';

export const healthpackage = (app) => {
export const healthPackage = (app) => {
const service = new HealthPackageService();

app.get('/all-packages', async (req,res) => {
app.get('/packages', async (req, res) => {
const allPackages = await service.getAllPackages();
if(allPackages.length > EMPTY_SIZE){
if (allPackages.length > EMPTY_SIZE) {
res.status(OK_STATUS_CODE).json({ allPackages });
}else{
res.status(NOT_FOUND_STATUS_CODE).json({ message:'patients not found' });
} else {
res.status(NOT_FOUND_STATUS_CODE).json({ message: 'patients not found' });
}
});

app.post('/new-package', async (req, res) => {
app.post('/packages', async (req, res) => {

const { name, price, discountOfDoctor, discountOfMedicin, discountOfFamily } = req.body;
console.log({ name });

const data = await service.createNewPackage(name, price, discountOfDoctor, discountOfMedicin, discountOfFamily);
if(data){
if (data) {
res.status(OK_STATUS_CODE).json({ data });
}else{
} else {
res.status(ERROR_STATUS_CODE);
}
});
Expand All @@ -31,15 +31,15 @@ export const healthpackage = (app) => {

// });

app.delete('/remove-package/:id', async (req,res) => {
app.delete('/packages/:id', async (req, res) => {
const id = req.params.id;
try{
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 });
}
} catch (err) {
res.status(ERROR_STATUS_CODE).json({ err: err.message });
}
});

};
4 changes: 2 additions & 2 deletions clinic/src/app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import express from 'express';
import mongoose from 'mongoose';
import dotenv from 'dotenv';
import { healthpackage } from './api/healthpackage.js';
import { healthPackage } from './api/HealthPackageAPI.js';
import { PORT } from './utils/Constants.js';
//import {doctor } from './api/doctor.js';
//import {appointment } from './api/appointment.js';
Expand All @@ -26,7 +26,7 @@ await connect();

app.use(express.json());

healthpackage(app);
healthPackage(app);
//admin(app);
//doctor(app);
//appointment(app);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import HealthPackageRepository from '../database/repository/healthpackage-repository.js';
import HealthPackageRepository from '../database/repository/health-package-repository.js';

class HealthPackageService {
constructor() {
Expand Down

0 comments on commit 2346f41

Please sign in to comment.