const axiosLoader = require('./axios');
const mongooseLoader = require('./mongoose');
const agendaLoader = require('./agenda');
const backendLoader = require('./backend');
const routesLoader = require('./routes');
const frontendLoader = require('./frontend');
const javaLoader = require('./java');
const log = require('loglevel');

const expressApp = async (backend, corsOptions, frontend) => {
    // axios instance
    global.axiosInstances = axiosLoader;

    // database connection
    await mongooseLoader();

    // job scheduling
    await agendaLoader();

    // java library
    await javaLoader();

    // backend
    await backendLoader(backend, corsOptions);

    // routes
    await routesLoader(backend);

    // frontend
    await frontendLoader(frontend);
}

module.exports = expressApp;
