Blame view

apps/channel/index.js 730 Bytes
毕凯 authored
1 2 3 4 5 6 7
/**
 * sub app channel
 * @author: Bi Kai<kai.bi@yoho.cn>
 * @date: 2016/05/09
 */

var express = require('express'),
姜枫 authored
8
    path = require('path');
毕凯 authored
9 10 11 12 13 14 15

var app = express();

// set view engin
var doraemon = path.join(__dirname, '../../doraemon/views'); // parent view root

app.on('mount', function(parent) {
姜枫 authored
16
毕凯 authored
17 18 19 20
    delete parent.locals.settings; // 不继承父 App 的设置
    Object.assign(app.locals, parent.locals);
});
姜枫 authored
21
app.use(global.yoho.hbs({
毕凯 authored
22 23 24
    extname: '.hbs',
    defaultLayout: 'layout',
    layoutsDir: doraemon,
姜枫 authored
25 26
    partialsDir: path.join(__dirname, 'views/partial'),
    views: path.join(__dirname, 'views/action'),
27
    helpers: global.yoho.helpers
毕凯 authored
28 29 30 31 32 33
}));

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

module.exports = app;