"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.v1JisRouter = exports.V1JISRouter = void 0;
const Di_1 = require("../../ioc/Di");
const OgJisToken_1 = require("../../ioc/OgJisToken");
const constants_1 = require("../../../shared/constants");
const jisEventType_1 = require("../../../../schema-definitions/jis/constants/jisEventType");
const AbstractRouter_1 = require("@golemio/core/dist/helpers/routing/AbstractRouter");
const ioc_1 = require("@golemio/core/dist/output-gateway/ioc");
const Validation_1 = require("@golemio/core/dist/output-gateway/Validation");
const express_1 = require("@golemio/core/dist/shared/express");
const express_validator_1 = require("@golemio/core/dist/shared/express-validator");
class V1JISRouter extends AbstractRouter_1.AbstractRouter {
    constructor() {
        super(constants_1.RouteVersion.v1, "jis");
        this.router = (0, express_1.Router)();
        this.initRoutes = () => {
            this.router.get("/events/custom-format", [
                (0, express_validator_1.query)("displayPeriodStart").optional().isISO8601(),
                (0, express_validator_1.query)("displayPeriodEnd").optional().isISO8601(),
                (0, express_validator_1.query)("organizationNames").optional().isArray(),
                (0, express_validator_1.query)("type").optional().isIn(jisEventType_1.jisEventType),
            ], Validation_1.checkErrors, 
            // // max-age 5 seconds, stale-while-revalidate 5 seconds
            this.cacheHeaderMiddleware.getMiddleware(5, 5), this.eventsController.getAllEventsInCustomFormat);
        };
        this.eventsController = Di_1.OgJisContainer.resolve(OgJisToken_1.OgJisToken.V1EventsController);
        this.cacheHeaderMiddleware = Di_1.OgJisContainer.resolve(ioc_1.ContainerToken.CacheHeaderMiddleware);
        this.initRoutes();
    }
}
exports.V1JISRouter = V1JISRouter;
const v1JisRouter = new V1JISRouter();
exports.v1JisRouter = v1JisRouter;
//# sourceMappingURL=V1JISRouter.js.map