<commit_before>/// <reference path="../typings/bluebird/bluebird.d.ts" />
/// <reference path="../typings/express/express.d.ts" />
/// <reference path="../typings/node/node.d.ts" />

import express = require('express');
import fs = require('fs');
import Promise = require('bluebird');

var app = express();
app.set('views', './views')
app.set('view engine', 'jade');

app.get('/', (req, res) => {
    var levelName = req.params.level;
    res.render('index');
});

app.get('/level/:levelName', (req, res) => {
    new Promise((resolve, reject) => {
        if (/[a-z]+/.test(req.params.levelName))
            resolve(req.params.levelName);
        else
            reject(void 0);
    })
    .then(levelName => Promise.promisify(fs.readFile)('static/level-assets/' + levelName + '/manifest.json'))
    .then(text => new Promise(r => r(JSON.parse(<any>text))))
    .then(level => res.render('level', { level: level }))
    .catch(err => {
        console.log(err);
        res.status(404);
        res.write('sorry');
        res.end();
    });
});

app.use('/static', express.static('static'));

var port: number = +process.env.PORT || 3000;

var server = app.listen(port, function() {
    console.log('Express server listening on port ' + port);
});<commit_msg>Redirect to the main nexus when loading the document root<commit_after>/// <reference path="../typings/bluebird/bluebird.d.ts" />
/// <reference path="../typings/express/express.d.ts" />
/// <reference path="../typings/node/node.d.ts" />

import express = require('express');
import fs = require('fs');
import Promise = require('bluebird');

var app = express();
app.set('views', './views')
app.set('view engine', 'jade');

app.get('/', (req, res) => {
    var levelName = req.params.level;
    res.redirect(302, '/level/Main Nexus DX');
});

app.get('/level/:levelName', (req, res) => {
    new Promise((resolve, reject) => {
        if (/[a-z]+/.test(req.params.levelName))
            resolve(req.params.levelName);
        else
            reject(void 0);
    })
    .then(levelName => Promise.promisify(fs.readFile)('static/level-assets/' + levelName + '/manifest.json'))
    .then(text => new Promise(r => r(JSON.parse(<any>text))))
    .then(level => res.render('level', { level: level }))
    .catch(err => {
        console.log(err);
        res.status(404);
        res.write('sorry');
        res.end();
    });
});

app.use('/static', express.static('static'));

var port: number = +process.env.PORT || 3000;

var server = app.listen(port, function() {
    console.log('Express server listening on port ' + port);
});
{'fraction_non_alphanumeric': 0.21720679012345678, 'fraction_numerical': 0.0073302469135802465, 'mean_word_length': 3.0963665086887837, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, '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': '1408399', 'n_tokens_mistral': 858, 'n_tokens_neox': 833, 'n_words': 166}