const { route } = require("express/lib/application");
const {authJwt} = require("../middlewares");
module.exports = app => {
    const routePaths = require("../controllers/route-path.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 routes
    router.get("/", [authJwt.verifyToken], routePaths.getAllRoutes);
    router.get("/on-and-after-today", [authJwt.verifyToken], routePaths.getAllRoutesOnAndAfterToday);
    router.get("/:id", [authJwt.verifyToken], routePaths.getRoute);
    // Create a new route
    router.post("/", [authJwt.verifyToken], routePaths.createRoutePath);
    // Update a route with id
    router.put("/:id", [authJwt.verifyToken], routePaths.updateRoute);
    // Delete a route with id
    router.delete("/:id", [authJwt.verifyToken], routePaths.deleteRoute);
    router.post("/update-in-progress", [authJwt.verifyToken], routePaths.updateRouteInProgress);
    router.get("/routes-with-phone",  routePaths.getAllRoutesWithPhones);
    app.use('/api/routes', router);
 };