Add edit history route/controller
This commit is contained in:
parent
c63f42f921
commit
aa59067d9e
@ -110,6 +110,17 @@ const getBuildingLikeById = asyncController(async (req: express.Request, res: ex
|
||||
}
|
||||
});
|
||||
|
||||
const getBuildingEditHistoryById = asyncController(async (req: express.Request, res: express.Response) => {
|
||||
const { building_id } = req.params;
|
||||
try {
|
||||
const editHistory = await buildingService.getBuildingEditHistory(building_id);
|
||||
|
||||
res.send({ history: editHistory });
|
||||
} catch(error) {
|
||||
res.send({ error: 'Database error' });
|
||||
}
|
||||
});
|
||||
|
||||
const updateBuildingLikeById = asyncController(async (req: express.Request, res: express.Response) => {
|
||||
if (!req.session.user_id) {
|
||||
return res.send({ error: 'Must be logged in' });
|
||||
@ -142,5 +153,6 @@ export default {
|
||||
updateBuildingById,
|
||||
getBuildingUPRNsById,
|
||||
getBuildingLikeById,
|
||||
updateBuildingLikeById
|
||||
};
|
||||
updateBuildingLikeById,
|
||||
getBuildingEditHistoryById
|
||||
};
|
||||
|
@ -29,4 +29,7 @@ router.route('/:building_id/like.json')
|
||||
.get(buildingController.getBuildingLikeById)
|
||||
.post(buildingController.updateBuildingLikeById);
|
||||
|
||||
export default router;
|
||||
router.route('/:building_id/history.json')
|
||||
.get(buildingController.getBuildingEditHistoryById);
|
||||
|
||||
export default router;
|
||||
|
@ -409,6 +409,7 @@ export {
|
||||
queryBuildingsByReference,
|
||||
getBuildingById,
|
||||
getBuildingLikeById,
|
||||
getBuildingEditHistory,
|
||||
getBuildingUPRNsById,
|
||||
saveBuilding,
|
||||
likeBuilding,
|
||||
|
Loading…
Reference in New Issue
Block a user