Skip to content

Commit

Permalink
Merge pull request #4 from Ayush-Vish/aadil
Browse files Browse the repository at this point in the history
add a contoller to get all services
  • Loading branch information
Ayush-Vish authored Oct 29, 2024
2 parents b32988a + 99b5a6e commit 865adca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
19 changes: 6 additions & 13 deletions customer/src/controllers/booking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,20 +179,13 @@ export const deleteBooking = async (req: Request, res: Response): Promise<void>
}
};

export const getServices = async (
req: Request,
res: Response,
next: NextFunction
) => {

export const getAllServices = async (req: Request, res: Response, next: NextFunction) => {
try {
console.log('Get Services');
const { orgId } = req.params;
const services = await Service.find({ orgId });
if (!services) {
return next(new ApiError('No services found', 404));
}
return res.status(200).json(services);
const services = await Service.find({});
// console.log(services);
res.status(200).json(services);
} catch (error) {
return next(new ApiError('An error occurred: ' + error.message, 500));
next(error);
}
};
7 changes: 5 additions & 2 deletions customer/src/routes/bookingRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
createBooking,
getCustomerBookings,
deleteBooking,
getServices,
getAllServices,
// getServices,
} from '../controllers/booking';
// import { authenticateUser } from '../middleware/authMiddleware.js';
import { isAuthorized, verifyJWT } from '@org/utils';
Expand All @@ -13,12 +14,14 @@ const router = express.Router();
// Route to create a booking
router.post('/book', verifyJWT, isAuthorized(['CLIENT']), createBooking);

router.get('/services/:orgId', verifyJWT, getServices);
// router.get('/services/:orgId', verifyJWT, getServices);

// Route to get all bookings for a customer
router.get('/bookings', verifyJWT,isAuthorized(['CLIENT']),getCustomerBookings);

// Route to delete a booking
router.delete('/bookings/:id', verifyJWT,isAuthorized(['CLIENT']),deleteBooking);

router.get('/services',verifyJWT,getAllServices)

export default router;

0 comments on commit 865adca

Please sign in to comment.