0.0.83 • Published 9 years ago

node-webserver v0.0.83

Weekly downloads
149
License
-
Repository
-
Last release
9 years ago

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

9 years ago

0.0.82

9 years ago

0.0.81

9 years ago

0.0.80

9 years ago

0.0.79

9 years ago

0.0.78

9 years ago

0.0.77

9 years ago

0.0.75

9 years ago

0.0.74

9 years ago

0.0.73

9 years ago

0.0.72

9 years ago

0.0.70

9 years ago

0.0.69

9 years ago

0.0.68

9 years ago

0.0.67

9 years ago

0.0.66

9 years ago

0.0.65

9 years ago

0.0.63

9 years ago

0.0.62

9 years ago

0.0.61

9 years ago

0.0.60

9 years ago

0.0.59

9 years ago

0.0.58

9 years ago

0.0.57

9 years ago

0.0.56

9 years ago

0.0.55

9 years ago

0.0.54

9 years ago

0.0.53

9 years ago

0.0.52

9 years ago

0.0.1

10 years ago