"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.startServer = void 0;
const http = require("http");
const utils_1 = require("@syftdata/common/lib/utils");
const PORT = 8085;
function startServer(getAST) {
    const server = http
        .createServer(function (req, res) {
        res.writeHead(200, { 'Content-Type': 'application/json' });
        const ast = getAST();
        if (ast == null) {
            res.end('{}');
            return;
        }
        res.end(JSON.stringify({
            schemas: ast.eventSchemas,
            config: ast.config
        }));
    })
        .listen(PORT);
    (0, utils_1.logInfo)(`AST Json Server is running at:  127.0.0.1:${PORT}`);
    return server;
}
exports.startServer = startServer;
