"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const findVersions_1 = __importDefault(require("./requestHandlers/findVersions"));
const findVersionByID_1 = __importDefault(require("./requestHandlers/findVersionByID"));
const restoreVersion_1 = __importDefault(require("./requestHandlers/restoreVersion"));
const update_1 = __importDefault(require("./requestHandlers/update"));
const findOne_1 = __importDefault(require("./requestHandlers/findOne"));
const docAccess_1 = __importDefault(require("./requestHandlers/docAccess"));
const buildEndpoints = (global) => {
    const { endpoints, slug } = global;
    if (global.versions) {
        endpoints.push(...[
            {
                path: '/versions',
                method: 'get',
                handler: (0, findVersions_1.default)(global),
            },
            {
                path: '/versions/:id',
                method: 'get',
                handler: (0, findVersionByID_1.default)(global),
            },
            {
                path: '/versions/:id',
                method: 'post',
                handler: (0, restoreVersion_1.default)(global),
            },
        ]);
    }
    endpoints.push(...[
        {
            path: '/access',
            method: 'get',
            handler: async (req, res, next) => (0, docAccess_1.default)(req, res, next, global),
        },
        {
            path: '/',
            method: 'get',
            handler: (0, findOne_1.default)(global),
        },
        {
            path: '/',
            method: 'post',
            handler: (0, update_1.default)(global),
        },
    ]);
    return endpoints;
};
exports.default = buildEndpoints;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVpbGRFbmRwb2ludHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZ2xvYmFscy9idWlsZEVuZHBvaW50cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUNBLGtGQUEwRDtBQUMxRCx3RkFBZ0U7QUFDaEUsc0ZBQThEO0FBRTlELHNFQUE4QztBQUM5Qyx3RUFBZ0Q7QUFDaEQsNEVBQWtFO0FBRWxFLE1BQU0sY0FBYyxHQUFHLENBQUMsTUFBNkIsRUFBYyxFQUFFO0lBQ25FLE1BQU0sRUFBRSxTQUFT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