'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var express = require('express');
var controller = require('./controller.js');
var loadReportDefinition = require('../../../../middleware/loadReportDefinition.js');
var validateFilters = require('../../../../validation/validateFilters.js');

/* eslint-disable no-param-reassign */
function routes({ layoutPath, services }) {
    const router = express.Router({ mergeParams: true });
    const controller$1 = new controller.RequestReportController(layoutPath, services);
    /**
     *  Get the request page
     */
    router.get('/', controller$1.GET);
    /**
     *  Apply request filters
     */
    router.post('/', 
    // get the definition needed to get validation rules
    loadReportDefinition.loadReportDefinition(services), 
    // validate the filters based
    validateFilters.validateFilters({ interactive: false }), 
    // if valid continue with post
    controller$1.POST);
    /**
     * Filter actions
     */
    router.post('/resetFilters', controller$1.resetFilters);
    router.post('/save-defaults', controller$1.saveDefaultFilterValues);
    router.post('/remove-defaults', controller$1.removeDefaultFilterValues);
    return router;
}

exports.default = routes;
exports.routes = routes;
//# sourceMappingURL=routes.js.map
