"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const http_status_1 = __importDefault(require("http-status"));
const findOne_1 = __importDefault(require("../operations/findOne"));
const isNumber_1 = require("../../utilities/isNumber");
function findOneHandler(globalConfig) {
    return async function handler(req, res, next) {
        var _a;
        try {
            const { slug } = globalConfig;
            const result = await (0, findOne_1.default)({
                req,
                globalConfig,
                slug,
                depth: (0, isNumber_1.isNumber)((_a = req.query) === null || _a === void 0 ? void 0 : _a.depth) ? Number(req.query.depth) : undefined,
                draft: req.query.draft === 'true',
            });
            return res.status(http_status_1.default.OK).json(result);
        }
        catch (error) {
            return next(error);
        }
    };
}
exports.default = findOneHandler;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmluZE9uZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9nbG9iYWxzL3JlcXVlc3RIYW5kbGVycy9maW5kT25lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQ0EsOERBQXFDO0FBSXJDLG9FQUE0QztBQUM1Qyx1REFBb0Q7QUFLcEQsU0FBd0IsY0FBYyxDQUFDLFlBQW1DO0lBQ3hFLE9BQU8sS0FBSyxVQUFVLE9BQU8sQ0FBQyxHQUFtQixFQUFFLEdBQWEsRUFBRSxJQUFrQjs7UUFDbEYsSUFBSTtZQUNGLE1BQU0sRUFBRSxJQUFJLEVBQUUsR0FBRyxZQUFZLENBQUM7WUFFOUIsTUFBTSxNQUFNLEdBQUcsTUFBTSxJQUFBLGlCQUFPLEVBQUM7Z0JBQzNCLEdBQUc7Z0JBQ0gsWUFBWTtnQkFDWixJQUFJO2dCQUNKLEtBQUssRUFBRSxJQUFBLG1CQUFRLEVBQUMsTUFBQSxHQUFHLENBQUMsS0FBSywwQ0FBRSxLQUFLLENBQUMsQ0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