public
Created

  • Download Gist
controllers-index.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
var web = require('webjs');
var MySQLSessionStore = require('connect-mysql-session')(web);
var config = require('../config');
var db = config.db;
 
web.run(8080/*parseInt(Math.random() * 10000)*/)
.config({
'view engine': 'ejs',
'views': __dirname + '/../views',
'mode': 'pro'
})
.use(
function(req, res, next) {
console.log('foo');
next();
},
web.cookieParser('huiben'),
web.session({
store: new MySQLSessionStore(db.database, db.user, db.password, {
host: 'localhost',
logging: false
}),
secret: "huiben"
}),
web.bodyParser({
uploadDir: config.config.images,
keepExtensions: true
}),
web.query(),
web.compress(),
function (req, res, next) {
var dynamicView = {
'user': req.session.user,
'admin': req.session.admin || '',
'vip': req.session.vip || false,
'first': req.session.first || false
};
res.dynamicView = dynamicView;
web.set('dynamicView', dynamicView);
next();
}
)
.extend(
__dirname + '/../models',
__dirname + '/routes',
__dirname + '/error'
);
 
/*require('pm').createWorker().ready(function (socket) {
web.server.self.emit('connection', socket);
});*/
 
console.log('The app is running!');
server.js
JavaScript
1 2 3 4 5 6 7 8 9
require(__dirname + '/controllers/');
 
/*var app = require('pm').createMaster({
'pidfile' : '/tmp/huiben.pid',
});
 
app.register('server', __dirname + '/controllers/index.js', {
'listen' : [3124, 8888]
});*/

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.