<commit_before>import * as express from "express";
import * as bodyParser from "body-parser";
import * as http from "http";
import * as helmet from "helmet";
import ConfigurationChooser from "./config/index";
import Configuration from "./config/configuration";
import RouterFacade from "./routes/routerFacade";

// Initializing app
let app : express.Express = express();
let configuration : Configuration = ConfigurationChooser.getConfig();

// Allow to get data from body in JSON format
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());

// Set helmet for security checks
app.use(helmet());

app.use(function (req : express.Request,
                  res : express.Response,
                  next : express.NextFunction) : void {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers",
        "Origin, X-Requested-With, Content-Type, Accept");
    next();
});

// Routes' require
app.use("/api", RouterFacade);

app.use("/", express.static(`${__dirname}/public/static`));
app.use("/bundle.js", express.static(`${__dirname}/public/bundle.js`));

// Starting the server
app.set("port", process.env.PORT || 3000);
let server : http.Server = app.listen(app.get("port"), function () : void {
    console.log("Express server is listening on port " + server.address().port +
        " in " + configuration.getEnvName() + " environment.");
});
<commit_msg>Create class MaaS<commit_after>import * as express from "express";
import * as bodyParser from "body-parser";
import * as http from "http";
import * as helmet from "helmet";
import ConfigurationChooser from "./config/index";
import Configuration from "./config/configuration";
import RouterFacade from "./routes/routerFacade";
import MongoConnection from "./config/mongoConnection";

/**
 * MaaS
 */
class MaaS {
    
    private app : express.Express;
    private configuration : Configuration;
    
    constructor(customDB? : MongoConnection, port? : number) {
           
           this.app = express();
           
           this.configuration = ConfigurationChooser.getConfig(customDB);
           
           console.log(this.configuration);
           
           port = port || 3000;
           
           // Allow to get data from body in JSON format
           this.app.use(bodyParser.urlencoded({extended: true}));
           this.app.use(bodyParser.json());

           // Set helmet for security checks
           this.app.use(helmet());

           this.app.use(function (req : express.Request,
                             res : express.Response,
                             next : express.NextFunction) : void {
                 res.header("Access-Control-Allow-Origin", "*");
                 res.header("Access-Control-Allow-Headers",
                     "Origin, X-Requested-With, Content-Type, Accept");
                 next();
           });

           // Routes' require
           this.app.use("/api", RouterFacade);

           this.app.use("/", express.static(`${__dirname}/public/static`));
           this.app.use("/bundle.js", express.static(`${__dirname}/public/bundle.js`));
           
           // Starting the server
           this.app.set("port", process.env.PORT || port);

    }
    
    public run () : void {
        
        let server : http.Server = this.app.listen(this.app.get("port"), () => {
        console.log("Express server is listening on port " + server.address().port +
        " in " + this.configuration.getEnvName() + " environment.");
        });
    }
}

export default MaaS;

let maas : MaaS = new MaaS();

maas.run();
{'fraction_non_alphanumeric': 0.145509977827051, 'fraction_numerical': 0.0022172949002217295, 'mean_word_length': 2.5004849660523765, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2164592', 'n_tokens_mistral': 995, 'n_tokens_neox': 972, 'n_words': 237}