'use strict';

var nginb = require("./requires/engine");

exports = module.exports = nginb;
exports.version = require('./package').version;

exports.start = function(app){

    app.use(function(req, res, next){

        res.json = function(s){
            res.writeHeader(200, {"content-type": "text/javascript", "content-length": Buffer.byteLength(s, 'utf8')});
            res.write(s, 'utf8');
            nginb.exit(res);
        }
        res.xml = function(s){
            res.writeHeader(200, {"content-type": "text/xml", "content-length": Buffer.byteLength(s, 'utf8')});
            res.write(s, 'utf8');
            nginb.exit(res);
        }
        res.html = function(s){
            res.writeHeader(200, {"content-type": "text/html", "content-length": Buffer.byteLength(s, 'utf8')});
            res.write(s, 'utf8');
            nginb.exit(res);
        }

        next();
    });
}
