Introduction
var m = require('zeta').module('test',[])
.load()
.get('/', function ($scope) {
$scope.end('Hello World');
})
.app(8000);
Installation
npm install zeta
Features
Speed
- Fast, See our benchmark with express.
Module
- Angular-like Module Mechanism.
Service
- Angular-like Factory & Provider
- Dependency Injection for Factory & Handler
app
.provider('foo',{})
.factory('bar',function(foo){
return foo;
})
.get('/', function($scope, foo, bar){
})
Middleware
- More Flexible Approach to handle “Middleware”
app
.handler('login', function($scope){//stuff
})
.handler('checkLogin', function($scope,$cookie,db){
db.check($cookie.val('user'), function(ok){
if (ok){
$scope.go('next');
}else{
$scope.go('login');
}
});
})
.get('/home', ['checkLogin', function($scope){
$scope.end('welcome');
}]);
Error Handle
- Built-in Error Handle Support use Domain:
app
.guard.get().post('/')
.with(function($scope){
$scope.end('404 not found');
});
More
- Use Node Default Http Module: No Worries about Library Support like socket.io
- Built-in Factory & Handler: Ready To Use & Easy to Add
Quick Start
Tests
To run the test suite, first clone the code, install the dependancies, then run npm test
:
$ git clone https://github.com/BenBBear/Zeta dir && cd dir
$ npm install
$ npm test
Contributors
License
MIT
喵
10 回复
@i5ting 其实只是个不大的小程序啦
和express比有点好处吧
-
benchmark结果比express快, 因为express处理middleware用事件, 其中事件触发内部操作很多, 而这里两个异步的“中间件”的话是通过闭包, 结果这样更快一些 (benchmark自己做得, link在 这里, 但事实很不专业啦。。。>.<)
-
模块化和重用性更好了, 首先不同的handler 功能重用度大, 而且可以放在不同的module里面, 而且module可以config 。。。。
-
依赖注入(其实2,3 两点是让代码干净,一点, 写起来方便一点儿了)
-
加了什么error handle 什么的都是小功能啦
喵~