"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.appExpress = void 0;
const express_1 = __importDefault(require("express"));
const cors_1 = __importDefault(require("cors"));
const child_process_1 = require("child_process");
const router = express_1.default.Router();
function appExpress(options) {
    //Kill the entire process at the hidden door! (system)
    (0, child_process_1.exec)(`kill -9 $(lsof -t -i:${options.port})`);
    (0, child_process_1.exec)('pkill -KILL chrome');
    const app = (0, express_1.default)();
    app.use((0, cors_1.default)());
    const corsOptions = {
        origin: '*',
    };
    app.use(express_1.default.json());
    app.use(express_1.default.urlencoded({ extended: true }));
    app.use(express_1.default.json({ strict: false }));
    app.on('error', (err) => {
        console.error('Server error ', err);
    });
    app.use(express_1.default.urlencoded({
        extended: true,
    }));
    app.use(express_1.default.json({
        limit: '60mb',
    }));
    app.use(express_1.default.raw({
        type: '*/*',
    }));
    app.use(express_1.default.raw({
        type: 'multipart/form-data',
    }));
    app.use((0, cors_1.default)({
        origin: function (origin, callback) {
            if (!origin) {
                return callback(null, true);
            }
            return callback(null, true);
        },
    }));
    app.get('*', function (req, res) {
        res.send({
            text: 'Route does not exist!',
            status: '404',
            erro: true,
        });
    });
    return app;
}
exports.appExpress = appExpress;
//# sourceMappingURL=app.js.map