directory

This commit is contained in:
pawan-dot 2022-10-28 17:28:17 +05:30
parent aa3480d90a
commit e2cef4fc6d
2 changed files with 19 additions and 8 deletions

View File

@ -70,13 +70,24 @@ export const createDirectory = async (req, res) => {
export const getAllDirectory = async (req, res) => {
try {
const directory = await directoryModel.find();
// console.log(category)
res.status(200).json({
success: true,
msg: " fetch Successfully!!",
directory,
});
if (req.user.role === "admin") {
const directory = await directoryModel.find();
// console.log(category)
res.status(200).json({
success: true,
msg: " fetch Successfully!!",
directory,
});
}
else {
const directory = await directoryModel.find({ status: "true" });
res.status(200).json({
success: true,
msg: " fetch Successfully!!",
directory,
});
}
} catch (error) {
res.status(500).json({
success: false,

View File

@ -27,7 +27,7 @@ const uploaderImage = multer({
}
});
router.route("/directory/create/").post(isAuthenticatedUser, createDirectory)
router.route("/directory/getAll/").get(getAllDirectory)
router.route("/directory/getAll/").get(isAuthenticatedUser, getAllDirectory)
router.route("/directory/getOne/:id").get(getOneDirectory)
router.route("/directory/update/:id").put(isAuthenticatedUser, updateDirectory);
router.route("/directory/delete/:id").delete(isAuthenticatedUser, deleteOneDirectory);