"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Config = void 0;
const events_1 = require("events");
class Config extends events_1.EventEmitter {
    debug;
    port;
    url;
    apiPath;
    plugins;
    pluginsOpts;
}
exports.Config = Config;
const ExpressPlugin_1 = require("./plugins/ExpressPlugin");
const AuthPlugin_1 = require("./plugins/AuthPlugin");
const SslPlugin_1 = require("./plugins/SslPlugin");
const StaticPlugin_1 = require("./plugins/StaticPlugin");
const PublishPlugin_1 = require("./plugins/PublishPlugin");
const WebsitePlugin_1 = require("./plugins/WebsitePlugin");
const HooksPlugin_1 = require("./plugins/HooksPlugin");
function default_1() {
    const port = process.env.PORT || '6805';
    const debug = process.env.SILEX_DEBUG === 'true';
    const maxListeners = process.env.SILEX_MAX_LISTENERS ? parseInt(process.env.SILEX_MAX_LISTENERS) : 50;
    const config = new Config();
    config.setMaxListeners(maxListeners);
    config.port = port;
    config.debug = debug;
    config.url = process.env.SERVER_URL || `http://localhost:${port}`;
    config.apiPath = '/api';
    config.plugins = [
        ExpressPlugin_1.default,
        AuthPlugin_1.default,
        SslPlugin_1.default,
        StaticPlugin_1.default,
        PublishPlugin_1.default,
        WebsitePlugin_1.default,
        HooksPlugin_1.default,
    ];
    config.pluginsOpts = {
        [AuthPlugin_1.default]: {
            directusUrl: process.env.DIRECTUS_SERVER_TO_SERVER_URL || process.env.DIRECTUS_URL,
        },
    };
    return config;
}
exports.default = default_1;
