const {authJwt} = require("../middlewares");
module.exports = app => {
    const reports = require("../controllers/report.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 reports
    router.get("/",[authJwt.verifyToken], reports.getAllReports);
    // Create a new report
    router.post("/", [authJwt.verifyToken], reports.createReport);
    // Update an report
    router.put("/:id",[authJwt.verifyToken], reports.updateReport );
    // Get reports by Date and Type
    router.get("/search", reports.getReportsByDateAndType);
    router.get("/search-route", reports.getReportsByRouteIdAndType);
    app.use('/api/reports', router);
 };