"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const isNumber_1 = require("../../utilities/isNumber");
const findVersionByID_1 = __importDefault(require("../operations/findVersionByID"));
function findVersionByIDHandler(globalConfig) {
    return async function handler(req, res, next) {
        var _a;
        const options = {
            req,
            globalConfig,
            id: req.params.id,
            depth: (0, isNumber_1.isNumber)((_a = req.query) === null || _a === void 0 ? void 0 : _a.depth) ? Number(req.query.depth) : undefined,
        };
        try {
            const doc = await (0, findVersionByID_1.default)(options);
            return res.json(doc);
        }
        catch (error) {
            return next(error);
        }
    };
}
exports.default = findVersionByIDHandler;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmluZFZlcnNpb25CeUlELmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2dsb2JhbHMvcmVxdWVzdEhhbmRsZXJzL2ZpbmRWZXJzaW9uQnlJRC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUdBLHVEQUFvRDtBQUVwRCxvRkFBNEQ7QUFFNUQsU0FBd0Isc0JBQXNCLENBQUMsWUFBbUM7SUFDaEYsT0FBTyxLQUFLLFVBQVUsT0FBTyxDQUFDLEdBQW1CLEVBQUUsR0FBYSxFQUFFLElBQWtCOztRQUNsRixNQUFNLE9BQU8sR0FBRztZQUNkLEdBQUc7WUFDSCxZQUFZO1lBQ1osRUFBRSxFQUFFLEdBQUcsQ0FBQyxNQUFNLENBQUMsRUFBRTtZQUNqQixLQUFLLEVBQUUsSUFBQSxtQkFBUSxFQUFDLE1BQUEsR0FBRyxDQUFDLEtBQUssMENBQUUsS0FBSyxDQUFDLENBQUMsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxHQUFHLENBQUMsS0FBSyxDQUFDLEtBQUssQ0FBQyxDQUFDLENBQUMsQ0FBQyxTQUFTO1NBQ3hFLENBQUM7UUFFRixJQUFJO1lBQ0YsTUFBTSxHQUFHLEdBQUcsTUFBTSxJQUFBLHlCQUFlLEVBQUMsT0FBTyxDQUFDLENBQUM7WUFDM0MsT0FBTyxHQUFHLENBQUMsSUFBSSxDQUFDLEdBQUcsQ0FBQyxDQUFDO1NBQ3RCO1FBQUMsT0FBTyxLQUFLLEVBQUU7WUFDZCxPQUFPLElBQUksQ0FBQyxLQUFLLENBQUMsQ0FBQztTQUNwQjtJQUNILENBQUMsQ0FBQztBQUNKLENBQUM7QUFoQkQseUNBZ0JDIn0=