"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.V2PublicGtfsController = void 0;
const Di_1 = require("../../ioc/Di");
const OgModuleToken_1 = require("../../ioc/OgModuleToken");
const trace_provider_1 = require("@golemio/core/dist/monitoring/opentelemetry/trace-provider");
const express_validator_1 = require("@golemio/core/dist/shared/express-validator");
class V2PublicGtfsController {
    constructor() {
        this.getOneTrip = async (req, res, next) => {
            const span = (0, trace_provider_1.createChildSpan)("V2PublicGtfsController.getOneTrip");
            try {
                const facade = Di_1.OgPublicContainer.resolve(OgModuleToken_1.OgModuleToken.GtfsTripLookupFacade);
                const params = this.parseGtfsTripLookupParams(req);
                const info = await facade.getOneByGtfsTripId(params.gtfsTripId, params.scopes);
                res.json(info);
            }
            catch (err) {
                next(err);
            }
            finally {
                span?.end();
            }
        };
    }
    parseGtfsTripLookupParams(req) {
        const queryData = (0, express_validator_1.matchedData)(req);
        return {
            gtfsTripId: req.params.gtfsTripId,
            scopes: queryData.scopes instanceof Array
                ? Array.from(new Set(queryData.scopes))
                : [queryData.scopes],
        };
    }
}
exports.V2PublicGtfsController = V2PublicGtfsController;
//# sourceMappingURL=V2PublicGtfsController.js.map