28 lines
1.0 KiB
JavaScript
28 lines
1.0 KiB
JavaScript
const express = require("express");
|
|
const {
|
|
createCrop,
|
|
getCropsByFarm,
|
|
getCropById,
|
|
updateCrop,
|
|
deleteCrop,
|
|
updateHealthStatus,
|
|
updateGrowthStage,
|
|
cropSuggest,
|
|
} = require("../Controllers/crop.controller.js");
|
|
const { checkAuthenticated } = require("../Middlewares/authentication.js");
|
|
const upload = require("../Middlewares/multer.js");
|
|
|
|
const router = express.Router();
|
|
|
|
// Routes for crop management
|
|
router.post("/", checkAuthenticated, upload.single("image"), createCrop); // Create a new crop
|
|
router.get("/farm/:farmId", checkAuthenticated, getCropsByFarm); // Get all crops
|
|
router.get("/:cropId", checkAuthenticated, getCropById); // Get a crop by ID
|
|
router.put("/:cropId", checkAuthenticated, updateCrop); // Update crop details
|
|
router.delete("/:cropId", checkAuthenticated, deleteCrop); // Delete a crop
|
|
router.put("/health/:cropId", checkAuthenticated, updateHealthStatus);
|
|
router.put("/growth/:cropId", checkAuthenticated, updateGrowthStage);
|
|
router.get("/suggest/:cropId", checkAuthenticated, cropSuggest);
|
|
|
|
module.exports = router;
|