feat:Create and Test user,crop,farm

This commit is contained in:
2025-02-22 19:10:33 +05:30
parent 330589bdf1
commit 4897c53259
3 changed files with 56 additions and 20 deletions
+13 -8
View File
@@ -1,20 +1,25 @@
import express from "express";
import {
const express = require("express");
const {
createCrop,
getCrops,
getCropsByFarm,
getCropById,
updateCrop,
deleteCrop,
} from "../controllers/cropController.js";
import { checkAuthenticated } from "../Middlewares/authentication.js";
updateHealthStatus,
updateGrowthStage,
} = 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, createCrop); // Create a new crop
router.get("/", checkAuthenticated, getCrops); // Get all crops
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);
export default router;
module.exports = router;