Final Route File – Step 12

Final Route File – Step 12

Step 12:-Final Route File

const express = require("express");
const { protect, authorize } = require("../middleware/auth");
// for pagination
const advancedResult= require("../middleware/advancedResult");
const teamMember =require('../models/teamMember');
const services =require('../models/services');
const project =require('../models/project');
const {
  createMember,
  getAllMembers,
  readSingleMember,
  updateSingleMember,
  deleteSingleMember,
} = require("../controllers/teamMember");

const {
  createService,
  readServices,
  readSingleService,
  updateService,
  deleteService,
} = require("../controllers/services");

const {
  createProject,
  readProjects,
  readSingleProject,
  updateProject,
  deleteProject,
} = require("../controllers/project");

const { insertData, getData, getMe } = require("../controllers/login");

const router = express.Router();

router.route("/createMember").post(protect, authorize("admin"), createMember);
router.route("/readAllMembers").get(advancedResult(teamMember),protect, authorize("admin"), getAllMembers);
router
  .route("/readSingleMember/:id")
  .get(protect, authorize("admin"), readSingleMember);
router
  .route("/updateSingleMember/:id")
  .put(protect, authorize("admin"), updateSingleMember);
router
  .route("/deleteSingleMember/:id")
  .delete(protect, authorize("admin"), deleteSingleMember);

router.route("/createService").post(protect, authorize("admin"), createService);
router.route("/getServices").get(advancedResult(services),protect, authorize("admin"), readServices);
router
  .route("/getService/:id")
  .get(protect, authorize("admin"), readSingleService);
router
  .route("/updateService/:id")
  .put(protect, authorize("admin"), updateService);
router
  .route("/deleteService/:id")
  .delete(protect, authorize("admin"), deleteService);

router.route("/createProject").post(protect, authorize("admin"), createProject);
router.route("/readProjects").get(advancedResult(project),protect, authorize("admin"), readProjects);
router
  .route("/readSingleProject/:id")
  .get(protect, authorize("admin"), readSingleProject);
router
  .route("/updateProject/:id")
  .put(protect, authorize("admin"), updateProject);
router
  .route("/deleteProject/:id")
  .delete(protect, authorize("admin"), deleteProject);

router.route("/register").post(insertData);
router.route("/login").post(getData);
router.route("/getMe").get(protect, getMe);

module.exports = router;

Post Your Comments & Reviews

Your email address will not be published. Required fields are marked *

*

*