const express = require('express');
const path = require('path');
const http = require('http');
// const compression = require('compression');



const runApp = () => {
    const app = express();
    const staticPath = 'fir_lib';
    const port = process.env.port || 3000;

    // const options = process.env.env == 'prod' ? {maxAge: '3d'} : {maxAge: '1m'};
    const options = {}
    const filePath = path.join(__dirname, staticPath);

    // app.use(express.compress());
    // app.use(compression({
    //     // level: 1
    // }));
    app.use(express.static(filePath, options));


    app.use("/**", function (req, res) {
    res.sendFile(filePath + "/index.html", {maxAge: 0});
    });

    const server = http.createServer(app);
    server.listen(port);
}

module.exports = runApp;