"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.apiEndpoints = void 0;
const guards_1 = require("./guards");
const apiEndpoints = (lockedData, app, io) => {
    const apiStepChange = (step) => {
        if ((0, guards_1.isApiStep)(step))
            io.emit('api-endpoint-changed');
    };
    lockedData.onStep('step-created', apiStepChange);
    lockedData.onStep('step-updated', apiStepChange);
    lockedData.onStep('step-removed', apiStepChange);
    app.get('/api-endpoints', (_, res) => {
        const endpoints = lockedData.apiSteps().map((step) => ({
            method: step.config.method,
            path: step.config.path,
            description: step.config.description,
            queryParams: step.config.queryParams,
            responseSchema: step.config.responseSchema,
            bodySchema: step.config.bodySchema,
        }));
        res.status(200).send(endpoints);
    });
};
exports.apiEndpoints = apiEndpoints;
