Authored by ccbikai

add sub app passport

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