Skip to content

Commit

Permalink
Merge pull request #2 from advanced-computer-lab-2023/SprintOneMark
Browse files Browse the repository at this point in the history
Sprint one mark
  • Loading branch information
abdulrhman500 authored Oct 10, 2023
2 parents d2bacb8 + 5223b86 commit bb3985c
Show file tree
Hide file tree
Showing 16 changed files with 238 additions and 83 deletions.
2 changes: 1 addition & 1 deletion server/.env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PORT=

MONGO_URI=
MONGO_URI=mongodb+srv://mark:s89sQCSg94VI3oO9@cluster0.hqmqtq1.mongodb.net/clinic?retryWrites=true&w=majority

TOKEN_SECRET=

Expand Down
147 changes: 147 additions & 0 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"prettier": "^3.0.0",
"supertest": "^6.3.3",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
},
"jest": {
Expand Down
25 changes: 19 additions & 6 deletions server/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ import helmet from 'helmet';
import compression from 'compression';
import { queryParser } from './middlewares';

import {
authRouter,
appointmentRouter,
chatroomRouter,
contractRouter,
notificationRouter,
packageRouter,
prescriptionRouter,
userRouter
} from './routes';

const app = express();

app.use(json());
Expand All @@ -26,12 +37,14 @@ app.use(compression());
// );
app.use(queryParser);

app.use('/auth');
app.use('/users');
app.use('/products');
app.use('/reviews');
app.use('/cart');
app.use('/orders');
app.use('/auth', authRouter);
app.use('/appointments', appointmentRouter);
app.use('/chatrooms', chatroomRouter);
app.use('/contracts', contractRouter);
app.use('/notifications', notificationRouter);
app.use('/packages', packageRouter);
app.use('/prescriptions', prescriptionRouter);
app.use('/users', userRouter);

app.all('*', (req: Request, res: Response) => res.status(404).send('NOT FOUND'));

Expand Down
3 changes: 1 addition & 2 deletions server/src/controllers/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ import { Response } from 'express';
import { StatusCodes } from 'http-status-codes';
import { HttpError } from '../utils';

const controller = (res: Response, session?: any) => {
const controller = (res: Response) => {
return (service: Function) => {
return async (...args: any[]) => {
try {
const result = await service(...args);
if (session && result.token) session.token = result.token;

res.status(result.status).json(result);
} catch (error: any) {
Expand Down
2 changes: 1 addition & 1 deletion server/src/routes/appointment.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const router = express.Router();

//

module.exports = router;
export default router;
3 changes: 2 additions & 1 deletion server/src/routes/auth.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ import express from 'express';
const router = express.Router();
// http methods required for this router

module.exports = router;
export default router;

3 changes: 2 additions & 1 deletion server/src/routes/chatroom.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ const router = express.Router();

//

module.exports = router;
export default router;

3 changes: 2 additions & 1 deletion server/src/routes/contract.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ const router = express.Router();

//

module.exports = router;
export default router;

19 changes: 19 additions & 0 deletions server/src/routes/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import authRouter from './auth.route';
import appointmentRouter from './appointment.route';
import chatroomRouter from './chatroom.route';
import contractRouter from './contract.route';
import notificationRouter from './notification.route';
import packageRouter from './package.route';
import prescriptionRouter from './prescription.route';
import userRouter from './user.route';

export {
authRouter,
appointmentRouter,
chatroomRouter,
contractRouter,
notificationRouter,
packageRouter,
prescriptionRouter,
userRouter
};
2 changes: 1 addition & 1 deletion server/src/routes/notification.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const router = express.Router();

//

module.exports = router;
export default router;
2 changes: 1 addition & 1 deletion server/src/routes/package.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const router = express.Router();

//

module.exports = router;
export default router;
2 changes: 1 addition & 1 deletion server/src/routes/prescription.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const router = express.Router();

//

module.exports = router;
export default router;
11 changes: 9 additions & 2 deletions server/src/routes/user.route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import express from 'express';
const router = express.Router();

import controller from '../controllers/controller';
import { isAuthenticated, isAuthorized, queryParser } from '../middlewares';

// import the user service
import { getPatients, selectPatient } from '../services/userService';
// http methods required for this router

//
router.get('/me/patient/', async (req, res) => controller(res)(getPatients)(req.query.doctorID));
router.get('/me/patient/:id', async (req, res) => controller(res)(selectPatient)(req.query.doctorID, req.params.id));

module.exports = router;
export default router;
Loading

0 comments on commit bb3985c

Please sign in to comment.