<commit_before>var express = require("express"),
    redis = require("redis").createClient(),
    RedisStore = require("connect-redis")(express),
    app = express();

// send redis errors to console
redis.on("error", function(err) {
    console.error(err);
});

// default configuration
app.set("port", 1007);

// serve static assets from public folder
app.use(express.static("public"));

// enable cookies
app.use(express.cookieParser());

// session middle-ware using redis for storage
app.use(express.session({
    secret: "the secret ingredient is love, dammit",
    store: new RedisStore({client: redis})
}));

// redirect homepage to appropriate static asset
app.get("/", function(req, rsp) {
    rsp.redirect("/tacdom.html");
});

// begin listening
app.listen(app.get("port"));<commit_msg>service for creating a new commander<commit_after>var express = require("express"),
    redis = require("redis").createClient(),
    RedisStore = require("connect-redis")(express),
    app = express();

// send redis errors to console
redis.on("error", function(err) {
    console.error(err);
});

// default configuration
app.set("port", 1007);

// serve static assets from public folder
app.use(express.static("public"));

// enable cookies
app.use(express.cookieParser());

// session middle-ware using redis for storage
app.use(express.session({
    secret: "the secret ingredient is love, dammit",
    store: new RedisStore({client: redis})
}));

// enable parsed post data
app.use(express.bodyParser());

// redirect homepage to appropriate static asset
app.get("/", function(req, rsp) {
    rsp.redirect("/tacdom.html");
});

// unit data
app.get("/unit/:id", function(req, rsp) {
    var host = req.headers.host + ":" + app.get("port"),
        baseUri = "//" + host;

    redis.hgetall(baseUri + req.url, function(err, reply) {
        if (err) {
            rsp.status(404);
            rsp.end();
        } else {
            rsp.setHeader("Content-Type", "application/json");
            rsp.end(JSON.stringify(reply));
        }
    });
});

// create a new commander for the current session
app.post("/commander", function(req, rsp) {
    var host = req.headers.host + ":" + app.get("port"),
        baseUri = "//" + host,
        idUri = "/id",
        name = req.body.name,
        commander = {
            id: null, uri: "/unit/", name: name,
            job: "commander",
            hea: 10, atk: 2, def: 2, spd: 2,
            hp: 10, act: 2,
            weap_dmg: 1, weap_rng: 1,
            special: "command"
        };

    if (!name) {
        rsp.status(500);
        rsp.end();
        return;
    }

    redis.incr(baseUri + idUri, function(err, reply) {
        // TODO: handle err
        commander.id = reply;
        commander.uri += reply;
        redis.hmset(baseUri + commander.uri, commander, function(err, reply) {
            // TODO: handle err
            rsp.redirect(303, commander.uri);
        });
    });
});

// begin listening
app.listen(app.get("port"));
{'fraction_non_alphanumeric': 0.16594468510496502, 'fraction_numerical': 0.008997000999666778, 'mean_word_length': 2.7016029593094943, 'pattern_counts': {'":': 2, '<': 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': '587718', 'n_tokens_mistral': 959, 'n_tokens_neox': 933, 'n_words': 230}