const {authJwt} = require("../middlewares");
module.exports = app => {
    const customers = require("../controllers/customer.controller.js");
    app.use((req, res, next) => {
      res.header(
        "Access-Control-Allow-Headers",
        "x-access-token, Origin, Content-Type, Accept"
      );
      next();
    });
    var router = require("express").Router();
    // Retrieve all customer
    router.get("/", [authJwt.verifyToken], customers.getAllCustomers);
    // Get All active customers
    router.get("/active",[authJwt.verifyToken], customers.getAllActiveCustomers);
    // Create a new customer
    router.post("/",[authJwt.verifyToken], customers.createCustomer);
    // Get Customers with name or email
    router.get("/search", [authJwt.verifyToken], customers.getCustomersWithNameOrEmail);
    // Update Customer
    router.put("/:id",[authJwt.verifyToken], customers.updateCustomer );
    router.get("/:id", [authJwt.verifyToken], customers.getCustomer);
    app.use('/api/customers', router);
 };