"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.v3PidRouter = exports.V3PIDRouter = void 0;
const ParamValidatorManager_1 = require("../../helpers/ParamValidatorManager");
const Di_1 = require("../../ioc/Di");
const OgPidToken_1 = require("../../ioc/OgPidToken");
const constants_1 = require("../../../shared/constants");
const AbstractRouter_1 = require("@golemio/core/dist/helpers/routing/AbstractRouter");
const Validation_1 = require("@golemio/core/dist/output-gateway/Validation");
const ioc_1 = require("@golemio/core/dist/output-gateway/ioc");
const express_1 = require("@golemio/core/dist/shared/express");
const express_validator_1 = require("@golemio/core/dist/shared/express-validator");
const const_1 = require("../../../../const");
class V3PIDRouter extends AbstractRouter_1.AbstractRouter {
    constructor() {
        super(constants_1.RouteVersion.v3, "pid");
        this.router = (0, express_1.Router)();
        this.initRoutes = () => {
            this.registerInfotextsRoutes();
        };
        this.registerInfotextsRoutes = () => {
            this.router.get("/transferboards", [
                (0, express_validator_1.query)("cisId").exists().isInt({ min: const_1.PG_INT_MIN, max: const_1.PG_INT_MAX }).not().isArray(),
                (0, express_validator_1.query)("tripNumber").optional().isInt({ min: 0 }).not().isArray(),
                (0, express_validator_1.query)("timeFrom").optional().isISO8601().custom(ParamValidatorManager_1.ParamValidatorManager.getTimeFromValidator()).not().isArray(),
            ], Validation_1.checkErrors, 
            // max-age 5 seconds, stale-while-revalidate 5 seconds
            this.cacheHeaderMiddleware.getMiddleware(5, 5), this.transferBoardsController.getTransferDepartures);
            this.router.get("/infotexts", [(0, express_validator_1.query)("includeFuture").optional().isBoolean().not().isArray()], Validation_1.checkErrors, 
            // max-age 10 seconds, stale-while-revalidate 10 seconds
            this.cacheHeaderMiddleware.getMiddleware(10, 10), this.infotextsController.getJisInfotexts);
            this.router.get("/departurepresets", Validation_1.checkErrors, 
            // max-age 10 seconds, stale-while-revalidate 10 seconds
            this.cacheHeaderMiddleware.getMiddleware(10, 10), this.ropidDeparturesPresetController.getDeparturesPresets);
        };
        this.cacheHeaderMiddleware = Di_1.OgPidContainer.resolve(ioc_1.ContainerToken.CacheHeaderMiddleware);
        this.transferBoardsController = Di_1.OgPidContainer.resolve(OgPidToken_1.OgPidToken.V3TransferBoardsController);
        this.infotextsController = Di_1.OgPidContainer.resolve(OgPidToken_1.OgPidToken.V3InfotextsController);
        this.ropidDeparturesPresetController = Di_1.OgPidContainer.resolve(OgPidToken_1.OgPidToken.V3RopidDeparturesPresetController);
        this.initRoutes();
    }
}
exports.V3PIDRouter = V3PIDRouter;
const v3PidRouter = new V3PIDRouter();
exports.v3PidRouter = v3PidRouter;
//# sourceMappingURL=V3PIDRouter.js.map