前言
基于node.js全栈的前后端分离开发模式
http://fex.baidu.com/yog2/
https://github.com/fex-team/yog2
安装
http://nodejs.org/
1
| sudo npm install -g yog2
|
1
2
3
4
5
6
7
8
9
10
11
12
13
| yog2 -v
v1.5.0
__/\\\\\\\\\\\\\\\__/\\\\\\\\\\\_____/\\\\\\\\\\\___
_\/\\\///////////__\/////\\\///____/\\\/////////\\\_
_\/\\\_________________\/\\\______\//\\\______\///__
_\/\\\\\\\\\\\_________\/\\\_______\////\\\_________
_\/\\\///////__________\/\\\__________\////\\\______
_\/\\\_________________\/\\\_____________\////\\\___
_\/\\\_________________\/\\\______/\\\______\//\\\__
_\/\\\______________/\\\\\\\\\\\_\///\\\\\\\\\\\/___
_\///______________\///////////____\///////////_____
|
创建项目
1
2
3
4
5
6
| mkdir yog2-test
cd yog2-test
yog2 init project
[NOTIC] Downloading and unzipping...
prompt: Enter your project name: (yog) yogServer
|
yog下载了一套模板
新建了项目目录
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| yogServer/
├── LICENSE
├── README.md
├── app
│ └── README.md
├── app.js
├── conf
│ ├── plugins
│ │ ├── dispatcher.js
│ │ ├── http.js
│ │ ├── log.js
│ │ ├── ral.js
│ │ ├── recv-reload.default.js
│ │ ├── reqlimit.js
│ │ └── views.js
│ └── ral
│ └── demo.js
├── package.json
├── plugins
│ └── README.md
├── static
└── views
|
创建应用
一个项目可以创建多个应用
1
2
3
4
5
6
7
8
| cd yog2-test
yog2 init app
[NOTIC] Downloading and unzipping...
prompt: Enter your app name: (home)
[NOTIC] Done
|
APP的名字我就用默认的
生成了
目录
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
| home
├── client
│ ├── page
│ │ ├── index.tpl
│ │ └── layout.tpl
│ ├── static
│ │ └── js
│ │ ├── README.md
│ │ ├── bigpipe.js
│ │ ├── index.js
│ │ ├── lazyload.js
│ │ ├── mod.js
│ │ └── page.js
│ └── widget
│ └── message
│ └── message.tpl
├── fis-conf.js
├── package.json
└── server
├── action
│ ├── book.js
│ └── index.js
├── lib
│ └── util.js
├── model
│ └── index.js
└── router.js
|
1
2
3
4
5
6
7
8
9
10
11
12
| cd yogServer
npm install
yog2 run
...
YOG/PLUGINS 24188: start debug mode for not found page
YOG/PLUGINS 24188: middleware [notFound] loaded in 0 ms
YOG/PLUGINS 24188: start debug mode for error page
YOG/PLUGINS 24188: middleware [error] loaded in 0 ms
YOG/LOADER 24188: plugin [http] loaded in 207 ms
plugins load completed
[NOTICE] recv-reload plugin is running in /yog/upload, please disable it in production
|
这是项目服务开启了
http://127.0.0.1:8085
现在还是空的
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| cd home
yog2 release --dest debug
δ 10ms
Ω ............... 88ms
- [14:45:38] client/static/js/index.js >> //static/home/static/js/index.js
- [14:45:38] client/page/index.tpl >> //views/home/page/index.tpl
- [14:45:38] client/page/layout.tpl >> //views/home/page/layout.tpl
- [14:45:38] client/static/js/README.md >> //static/home/static/js/README.md
- [14:45:38] client/static/js/bigpipe.js >> //static/home/static/js/bigpipe.js
- [14:45:38] client/static/js/lazyload.js >> //static/home/static/js/lazyload.js
- [14:45:38] client/static/js/page.js >> //static/home/static/js/page.js
- [14:45:38] client/static/js/mod.js >> //static/home/static/js/mod.js
- [14:45:38] client/widget/message/message.tpl >> //views/home/widget/message/message.tpl
- [14:45:38] package.json >> //app/home/package.json
- [14:45:38] server/action/book.js >> //app/home/action/book.js
- [14:45:38] server/action/index.js >> //app/home/action/index.js
- [14:45:38] server/lib/util.js >> //app/home/lib/util.js
- [14:45:38] server/model/index.js >> //app/home/model/index.js
- [14:45:38] server/router.js >> //app/home/router.js
- [14:45:38] home-map.json >> //conf/fis/home-map.json
|
部署成功
再次访问 http://127.0.0.1:8085
可以成功看到
文档参考
http://fex.baidu.com/yog2/docs/