<commit_before>var http = require('http');
var path = require('path');
var router = require('./router');
var context = require('./context');

var snowf = {
    init: function (appsetting) {
        if (appsetting != undefined && appsetting != null) {
            this.setting = appsetting;
        }

        router.init(this.setting.router);
        context.init(this.setting);
    },
    start: function () {
        http.createServer((reqest, response) => {
            //过滤器对请求进行筛选
            //filters.auth(request);
            //处理请求
            router.requestHandler(reqest, function (routerData) {
                responseHandler(routerData, response);
            });

        }).listen(this.setting.port);
    },
    controllers: {},
    addController: function (name, conrollerHandler) {
        this.controllers[name] = conrollerHandler;
    },
    //更新配置节点
    set: function (key, value) {
        this.setting[key] = value;
    },
    setting: {
        "environment": "development",
        "port": "8080",
        "router": {
            "default": "home",
            "error": "/shared/error.html",
            "views": "./views",
            "root": "./wwwroot"
        }
    }
};

function responseHandler(routerData, response) {
    if (routerData.isStatic) {
        context.response.file(routerData.path, response);
    }
    else {
        try {
            var result = snowf.controllers[routerData.controller][routerData.action](routerData.request);
            switch (result.actionResult) {
                case 'view':
                    context.response.view(routerData.controller, routerData.action, response);
                    return;
                case 'file':
                    context.response.file(result.path, response);
                    return;
                case 'content':
                    context.response.content(result.data, result.contentType, response);
                    return;
                default:
                    context.response.error({ message: '未知返回类型' }, response);
                    return;
            }
        } catch (err) {
            console.log(err);
            context.response.error(err, response);
        }
    }
}

exports = module.exports = function createApp(appsetting) {
    snowf.init(appsetting);
    return snowf;
};

exports.context = context;
exports.router = router;<commit_msg>更新snowf<commit_after>var http = require('http');
var path = require('path');
var router = require('./router');
var context = require('./context');
var action = require('./action');

var snowf = {
    init: function (appsetting) {
        if (appsetting != undefined && appsetting != null) {
            this.setting = appsetting;
        }

        router.init(this.setting.router);
        context.init(this.setting);
    },
    start: function () {
        http.createServer((reqest, response) => {
            //过滤器对请求进行筛选
            //filters.auth(request);
            //处理请求
            router.requestHandler(reqest, function (routerData) {
                responseHandler(routerData, response);
            });

        }).listen(this.setting.port);
    },
    controllers: {},
    addController: function (name, conrollerHandler) {
        this.controllers[name] = conrollerHandler;
    },
    //更新配置节点
    set: function (key, value) {
        this.setting[key] = value;
    },
    setting: {
        "environment": "development",
        "port": "8080",
        "router": {
            "default": "home",
            "error": "/shared/error.html",
            "views": "./views",
            "root": "./wwwroot"
        }
    }
};

function responseHandler(routerData, response) {
    if (routerData.isStatic) {
        context.response.file(routerData.path, response);
    }
    else {
        try {
            var result = snowf.controllers[routerData.controller][routerData.action](routerData.request);
            switch (result.actionResult) {
                case 'view':
                    context.response.view(routerData.controller, routerData.action, response);
                    return;
                case 'file':
                    context.response.file(result.path, response);
                    return;
                case 'content':
                    context.response.content(result.data, result.contentType, response);
                    return;
                default:
                    context.response.error({ message: '未知返回类型' }, response);
                    return;
            }
        } catch (err) {
            console.log(err);
            context.response.error(err, response);
        }
    }
}

exports = module.exports = function createApp(appsetting) {
    snowf.init(appsetting);
    return snowf;
};

exports.context = context;
exports.router = router;
exports.action = action;
{'fraction_non_alphanumeric': 0.13124611237818784, 'fraction_numerical': 0.0016587186398507154, 'mean_word_length': 1.7868284228769498, 'pattern_counts': {'":': 14, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '561405', 'n_tokens_mistral': 1320, 'n_tokens_neox': 1290, 'n_words': 244}