4 Star 7 Fork 3

zensh / toa

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Toa

简洁而强大的 web 框架。

Toa

NPM version Build Status js-standard-style Coverage Status Downloads

Thanks to Koa and it's authors

Demo

const Toa = require('toa')
const app = Toa(function () {
  // this function will run after all middlewares
  this.body = this.state
})
// support sync function middleware
app.use(function () {
  this.state.syncFn = 'support!'
})
// support thunk function middleware
app.use(function (next) {
  this.state.thunkFn = 'support!'
  setTimeout(next, 10)
})
// support generator function middleware
app.use(function * () {
  this.state.generatorFn = yield Promise.resolve('support!')
})
// support async function middleware in babel or Node.js v7~
// babel-node --presets es2015 --plugins transform-async-to-generator example/simple.js
app.use(async function () {
  this.state.asyncFn = await Promise.resolve('support!')
})

app.listen(3000)

Install

npm install toa

Toa 简介

ToaKoa 的改进版。

Toa 修改自 Koa,基本架构原理与 Koa 相似,contextrequestresponse 三大基础对象几乎一样。但 Toa 是基于 thunks 组合业务逻辑,来实现异步流程控制和异常处理。

Toa 的异步核心是 thunk 函数,支持 node.js v0.10.x,但在支持 generator 的 node 环境中(io.js, node.js >= v0.11.9)将会有更好地编程体验:用同步逻辑编写非阻塞的异步程序

ToaKoa 学习成本和编程体验是一致的,两者之间几乎是无缝切换。但 Toa 去掉了 Koa级联(Cascading) 逻辑,强化中间件,强化模块化组件,尽量削弱第三方组件访问应用的能力,使得编写大型应用的结构逻辑更简洁明了,也更安全。

koa Process

koa Process

Toa Process

Toa Process

功能模块

与 Koa 一样, Toa 也没有绑定多余的功能,而仅仅提供了一个轻量优雅的函数库,异步控制处理器和强大的扩展能力。

使用者可以根据自己的需求选择独立的功能模块或中间件,或自己实现相关功能模块。以下是 Toajs 提供的基础性的功能模块。它们已能满足大多数的应用需求。


Bench

API

使用手册

Application

Context

Request

Response

Change Log

The MIT License (MIT) Copyright (c) 2015-2016 Toajs Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

新一代 node.js web server 框架 展开 收起
JavaScript
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/zensh/toa.git
git@gitee.com:zensh/toa.git
zensh
toa
toa
master

搜索帮助