thinknode
Version:
A fast, flexible and all-in-one web framework for node.js.
127 lines (94 loc) • 3.03 kB
Markdown
-----
[](https://badge.fury.io/js/thinknode)
[](https://travis-ci.org/richenlin/thinknode)
[](https://david-dm.org/richenlin/thinknode)
A fast, flexible and all-in-one web framework for node.js.
ThinkNode 是一款使用 ECMAScript 全新特性开发的 Node.js MVC 框架,使用 async/await 或者 Promise 解决了 Node.js 中异步嵌套的问题,并集成了项目开发中最常用的组件例如 Session、缓存、ORM等,开箱即用,让开发 Node.js 项目更加简单、高效。
-----
1. 使用 ES6/7 全新特性来开发项目
2. 微内核架构,合理解耦方便扩展
3. 支持 Mysql,MongoDB,postgresSql 等多种数据库,且书写语法一致(使用thinkorm支持)
4. Model 预加载机制,支持动态加载,动态切换数据源
5. 开发模式下代码自动更新,无需重启 Node 服务
6. 支持Http、WebSocket、Restful等多种访问方式
7. 支持 File、Redis、Memcache 等多种Session及Cache
8. 支持切面编程,支持 __before,_berore_xxx, _after_xxx 等多种魔术方法
9. 支持 ejs 模版引擎,可以自行扩展其他解析引擎
10. 支持国际化和多主题
src/Admin/Controller/Index.js
```
export default class extends THINK.Controller {
//构造方法
init(http){
//调用父类构造方法
super.init(http);
this.model = THINK.model('Home/User', {});
}
//控制器默认方法
async indexAction () {
let userInfo = await this.model.where({id: 1}).find();
this.set('userInfo', userInfo);
return this.display();
}
}
```
src/Admin/Controller/Index.js
```
export default class extends THINK.Controller {
//构造方法
init(http){
//调用父类构造方法
super.init(http);
this.model = THINK.model('Home/User', {});
}
//控制器默认方法
indexAction () {
return this.model.where({id: 1}).find().then(userInfo => {
this.set('userInfo', userInfo);
return this.display();
}).catch(e => {
return this.error(e.message);
});
}
}
```
-----
[](https://www.gitbook.com/book/richenlin/thinknode-doc/)
webstorm代码提示插件: File --> Import Settings 选择 /node_modules/thinknode/doc/webstrom_thinknode_settings.jar
-----
```sh
npm install -g thinknode_kit
```
```sh
thinknode new project_name
```
```sh
cd project_name
```
```sh
npm install
```
```sh
npm start
```
打开浏览器,访问http://localhost:3000
-----
richenlin
richerdlee
-----
MIT