0.0.83 • Published 10 years ago
node-webserver v0.0.83
node-webserver
##Usage
Arguments
- port 端口
- controller controller配置
- filter filter配置
- serverRoot server根路径
- webRoot webroot根路径
- viewPath view根路径
- viewEngine 模板引擎
- uploadPath 文件上传路径
- session
- key session key
- redisStore
- host redis host
- port redis port
Method
start 服务启动 stop 服务停止
Event
error 异常日志
filter和controller配置说明
filter 配置
{
"rootPath": "/filter", //filter根路径
"filters": [{
"path": "/", //匹配路径,支持正则
"handler": "indexFilter.index1" //filter名+.+method名
},{
"regPath": "/.*",
"handler": "indexFilter.index2"
},{
"path": "/demo",
"handler": "loginFilter.demo"
}]
}
controller 配置
{
"rootPath": "/controller", //controller根路径
"controllers": [{
"path": "/", //匹配路径,支持正则
"handler": "indexController.index" //controller名+.+method名
}, {
"path": "/demo",
"handler": "indexController.demo"
}, {
"regPath": "/api/(.*)/(.*)",
"method": "all",
"handler": "$1Controller.$2"
}]
}
Example
var server = new WebServer({
port:5000,
controller:require('./conf/controller.json'),
filter:require('./conf/filter.json'),
serverRoot:__dirname,
webRoot:path.join(__dirname,'../webapp'),
uploadPath:'./uploads',
viewPath:'./views',
viewEngine:'ejs',
session:{
key:'SESSION_DEMO',
redisStore:{
host: process.appConfig.redis.host,
port: process.appConfig.redis.port
}
}
});
server.on('error',function(err){
console.log('Error:%j'+err);
});
server.start();
0.0.83
10 years ago
0.0.82
10 years ago
0.0.81
10 years ago
0.0.80
10 years ago
0.0.79
10 years ago
0.0.78
10 years ago
0.0.77
10 years ago
0.0.75
10 years ago
0.0.74
10 years ago
0.0.73
10 years ago
0.0.72
10 years ago
0.0.70
10 years ago
0.0.69
10 years ago
0.0.68
10 years ago
0.0.67
10 years ago
0.0.66
10 years ago
0.0.65
10 years ago
0.0.63
10 years ago
0.0.62
10 years ago
0.0.61
10 years ago
0.0.60
10 years ago
0.0.59
10 years ago
0.0.58
10 years ago
0.0.57
10 years ago
0.0.56
10 years ago
0.0.55
10 years ago
0.0.54
10 years ago
0.0.53
10 years ago
0.0.52
10 years ago
0.0.1
12 years ago