app.js 721 Bytes
/**
 * 服务端入口文件
 * @author: xuqi(qi.xu@yoho.cn)
 * @date: 2015/6/29
 */
var express = require('express'),
    path = require('path'),
    hbs = require('hbs'),
    bodyParser = require('body-parser'),
    app = express();

//configuration
app.set('views', path.join(__dirname, 'views'));

app.set('view engine', 'html');
app.engine('html', require('hbs').__express);
hbs.registerPartials(__dirname + '/views/partials');

//middleware
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));

app.use(express.static(path.join(__dirname, '/public')));

//router
require('./router')(app);

//server 
app.listen(5000, function() {
    console.log('server start');
});

module.exports = app;