Blame view

apps/product/index.js 992 Bytes
yyq authored
1 2 3 4 5 6
/**
 * sub app product
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2016/05/06
 */
yyq authored
7
var express = require('express'),
陈峰 authored
8 9
    path = require('path'),
    hbsEvent = require('../../config/hbsevent');
yyq authored
10 11

var app = express();
yyq authored
12
var router = require('./router');
yyq authored
13
yyq authored
14 15
var route = require('../../doraemon/middleware/route-intercept');
yyq authored
16 17 18
// set view engin
var doraemon = path.join(__dirname, '../../doraemon/views'); // parent view root
周少峰 authored
19 20
app.disable('x-powered-by');
姜枫 authored
21 22 23
app.on('mount', function(parent) {
    delete parent.locals.settings; // 不继承父 App 的设置
    Object.assign(app.locals, parent.locals);
yyq authored
24
yyq authored
25
    route.regist(app, parent, router);
姜枫 authored
26 27
});
周少峰 authored
28
app.use(global.yoho.hbs({
yyq authored
29 30 31
    extname: '.hbs',
    defaultLayout: 'layout',
    layoutsDir: doraemon,
周少峰 authored
32 33
    partialsDir: [path.join(__dirname, 'views/partial')],
    views: path.join(__dirname, 'views/action'),
陈峰 authored
34 35
    helpers: Object.assign(require('./helper'), global.yoho.helpers),
    cb: hbsEvent.cb
yyq authored
36 37 38
}));

// router
yyq authored
39
app.use(router);
yyq authored
40 41

module.exports = app;