<commit_before>
const PATH = require("path");
const FS = require("fs");
const EXPRESS = require("express");
const ROLODEX = require("../");

const PORT = process.env.PORT || 8080;


exports.main = function(options, callback) {
    try {
        var app = EXPRESS();

        app.use(EXPRESS.logger());
        app.use(EXPRESS.cookieParser());
        app.use(EXPRESS.bodyParser());

        var path = PATH.join(__dirname, "rolodex.config.local.json");
        if (!FS.existsSync(path)) {
            path = PATH.join(__dirname, "rolodex.config.json");
        }

        return ROLODEX.hook(app, path, {
        	hostname: "localhost",
        	port: PORT,<commit_msg>read config from services.json; set response header<commit_after>
const PATH = require("path");
const FS = require("fs");
const EXPRESS = require("express");
const ROLODEX = require("../");

const PORT = process.env.PORT || 8080;


var config = null;
var serviceUid = false;
if (FS.existsSync(PATH.join(__dirname, "../service.json"))) {
    config = JSON.parse(FS.readFileSync(PATH.join(__dirname, "../service.json")));
    serviceUid = config.uid;
}


exports.main = function(options, callback) {
    try {
        var app = EXPRESS();

        app.use(function(req, res, next) {
            if (serviceUid) {
                res.setHeader("x-service-uid", serviceUid);
            }
            if (req.url === "/") {
                return res.end();
            }
            return next();
        });

        app.use(EXPRESS.logger());
        app.use(EXPRESS.cookieParser());
        app.use(EXPRESS.bodyParser());

        var path = null;
        if (config && config.config && config.config["rolodex.config.json"]) {
            path = config.config["rolodex.config.json"];
        } else {
            path = PATH.join(__dirname, "rolodex.config.local.json");
            if (!FS.existsSync(path)) {
                path = PATH.join(__dirname, "rolodex.config.json");
            }
        }

        console.log("use config", path);

        return ROLODEX.hook(app, path, {
        	hostname: "localhost",
        	port: PORT,
{'fraction_non_alphanumeric': 0.15979137031768612, 'fraction_numerical': 0.003793266951161688, 'mean_word_length': 2.246153846153846, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7347145', 'n_tokens_mistral': 648, 'n_tokens_neox': 626, 'n_words': 130}