"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.v2PublicVPRouter = exports.V2PublicVehiclePositionsRouter = void 0;
const V2PublicVehiclePositionsController_1 = require("../../controllers/v2/V2PublicVehiclePositionsController");
const Di_1 = require("../../ioc/Di");
const OgModuleToken_1 = require("../../ioc/OgModuleToken");
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 CustomBBoxValidator_1 = require("./helpers/CustomBBoxValidator");
const CustomScopeValidator_1 = require("./helpers/CustomScopeValidator");
const CustomTypeValidator_1 = require("./helpers/CustomTypeValidator");
class V2PublicVehiclePositionsRouter extends AbstractRouter_1.AbstractRouter {
    constructor() {
        super(constants_1.RouteVersion.v2, "public/vehiclepositions");
        this.router = (0, express_1.Router)();
        this.cacheHeaderMiddleware = Di_1.OgPublicContainer.resolve(ioc_1.ContainerToken.CacheHeaderMiddleware);
        this.compressionByDefaultMiddleware = Di_1.OgPublicContainer.resolve(ioc_1.ContainerToken.CompressionByDefaultMiddleware);
        this.vehiclePositionsController = new V2PublicVehiclePositionsController_1.V2PublicVehiclePositionsController();
        this.initRoutes();
        this.redisSubscriber = Di_1.OgPublicContainer.resolve(OgModuleToken_1.OgModuleToken.VPSubscriber);
        this.redisSubscriber.initialize();
    }
    initRoutes() {
        this.router.get("/", [
            (0, express_validator_1.query)("boundingBox").optional().custom(CustomBBoxValidator_1.CustomBBoxValidator.validate),
            (0, express_validator_1.query)("routeShortName").optional().not().isEmpty({ ignore_whitespace: true }),
            (0, express_validator_1.query)("routeType").optional().custom(CustomTypeValidator_1.CustomTypeValidator.validate),
        ], Validation_1.checkErrors, 
        // max-age 5 seconds, stale-while-revalidate 5 seconds
        this.cacheHeaderMiddleware.getMiddleware(5, 5), this.compressionByDefaultMiddleware.getMiddleware(), this.vehiclePositionsController.getAll);
        this.router.get("/:vehicleId;gtfsTripId=:gtfsTripId", [(0, express_validator_1.param)("vehicleId").exists(), (0, express_validator_1.param)("gtfsTripId").exists(), (0, express_validator_1.query)("scopes").custom(CustomScopeValidator_1.CustomScopeValidator.validate)], Validation_1.checkErrors, 
        // max-age 5 seconds, stale-while-revalidate 5 seconds
        this.cacheHeaderMiddleware.getMiddleware(5, 5), this.compressionByDefaultMiddleware.getMiddleware(), this.vehiclePositionsController.getOneByParamsCombination);
        this.router.get("/:vehicleId", [(0, express_validator_1.param)("vehicleId").exists(), (0, express_validator_1.query)("scopes").custom(CustomScopeValidator_1.CustomScopeValidator.validate)], Validation_1.checkErrors, 
        // max-age 5 seconds, stale-while-revalidate 5 seconds
        this.cacheHeaderMiddleware.getMiddleware(5, 5), this.compressionByDefaultMiddleware.getMiddleware(), this.vehiclePositionsController.getOneByVehicleId);
    }
}
exports.V2PublicVehiclePositionsRouter = V2PublicVehiclePositionsRouter;
const v2PublicVPRouter = new V2PublicVehiclePositionsRouter();
exports.v2PublicVPRouter = v2PublicVPRouter;
//# sourceMappingURL=V2PublicVehiclePositionsRouter.js.map