Node.js和Express版本迁移不起作用

时间:2016-03-07 12:11:10

标签: node.js express

我无法连接到以下NODE.JS应用。也许,我将旧代码更改为最新的express和node.js版本时出了什么问题?

app.js

global.settings = {
    port:       8003,
    dbPort:     27017,
    dbHost:     'localhost',
    dbName:     "admin-linux",
    root_path:  __dirname
}
var DB = require('./app/server/modules/db-manager');

DB.init(function(){
    var express = require('express')
      , http = require('http');

    var app = express(); 
    var server = http.createServer(app);

    require('./app/setup')(app, express);
    require('./app/server/router')(app);

    app.listen(global.settings.port, function(){
        console.log("Express server listening on port %d in %s mode", global.settings.port, app.settings.env);
    });
}); 

setup.js

var DB = require('./server/modules/db-manager');

module.exports = function(app, exp) {
    app.get(function(){
        app.set('views', global.settings.root_path + '/app/server/views');
        app.set('view engine', 'jade');
        app.set('view options', { doctype : 'html', pretty : true });
        app.use(exp.bodyParser());
        app.use(exp.cookieParser());
        app.use(exp.session({ secret: 'super-duper-secret-secret' }));
        app.use(exp.methodOverride());
        app.use(require('stylus').middleware({ src: global.settings.root_path + '/app/public' }));
        app.use(exp.static(global.settings.root_path + '/app/common'));
        app.use(exp.static(global.settings.root_path + '/app/public'));
        app.use(exp.static(global.settings.root_path + '/customize'));
        app.use(DB.i18n.init);
    });
};  

0 个答案:

没有答案