Authored by xuqi

build sub app

... ... @@ -13,15 +13,6 @@ var express = require('express'),
var app = express();
// set view engin
app.set('views', path.join(__dirname, 'app/views/action'));
app.engine('.hbs', hbs({
extname: '.hbs',
defaultLayout: 'layout',
layoutsDir: 'app/views/',
partialsDir: 'app/views/partial/',
helpers: 'helpers'
}));
app.set('view engine', '.hbs');
app.use(bodyParser.json());
... ... @@ -29,8 +20,8 @@ app.use(bodyParser.urlencoded({extended: false}));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
// router
app.use(require('./router'));
// dispatcher
require('./dispatch')(app);
// listener
app.listen(3000, function() {
... ...
hello hbs
\ No newline at end of file
# sub app
## 构建方法
`yo subapp`
## 目录说明
subapp
|
|____ controllers
|
|____ models
|
|____ views
. |
. |____action
. |
. |____partial
.
|
|____index.js //子模块入口文件
|
|____router.js
... ...
/**
* 路由分发
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2016/4/27
*/
module.exports = app => {
app.use('/guang', require('./apps/guang'));
};
... ...
# doraemon for everything
## middleware
## views contains **layout、header and footer** partial
\ No newline at end of file
... ...
/**
* router
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2016/4/25
*/
'use strict';
const app = new require('express').Router();
const cRoot = './app/controllers';
app.get('/', (req, res) => {
res.render('index');
});
module.exports = app;
\ No newline at end of file