Authored by ccbikai

add sub app passport

/**
* 登录
* @author: Bi Kai<kai.bi@yoho.cn>
* @date: 2016/05/09
*/
'use strict';
// const library = '../../../library';
// const _ = require('lodash');
// const channelModel = require('../models/channel');
// const helpers = require(`${library}/helpers`);
// const log = require(`${library}/logger`);
/**
* 频道页底部 bannel
* @param {[object]} req
* @param {[object]} res
* @return {[type]}
*/
exports.index = (req, res) => {
res.send('login');
};
... ...
/**
* sub app channel
* @author: Bi Kai<kai.bi@yoho.cn>
* @date: 2016/05/09
*/
var express = require('express'),
path = require('path'),
hbs = require('express-handlebars');
var app = express();
// set view engin
var doraemon = path.join(__dirname, '../../doraemon/views'); // parent view root
app.on('mount', function(parent) {
delete parent.locals.settings; // 不继承父 App 的设置
Object.assign(app.locals, parent.locals);
});
app.set('views', path.join(__dirname, 'views/action'));
app.engine('.hbs', hbs({
extname: '.hbs',
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`],
helpers: require(`${global.library}/helpers`)
}));
// router
app.use(require('./router'));
module.exports = app;
... ...
/**
* router of sub app channel
* @author: Bi Kai<kai.bi@yoho.cn>
* @date: 2016/05/09
*/
'use strict';
const express = require('express');
const cRoot = './controllers';
const login = require(cRoot + '/login');
const router = express.Router(); // eslint-disable-line
router.get('/', login.index); // 登录
module.exports = router;
... ...
... ... @@ -13,4 +13,5 @@ module.exports = app => {
// 业务模块
app.use('/product', require('./apps/product'));
app.use('/passport', require('./apps/passport'));
};
... ...