@dfeidao/server

5.0.1 • Public • Published

Web Server, including HTTP and HTTPS.

Configuration

feidao.json

{
	"java": "http://192.168.40.196/router4js",
	"port": 8889,
	"timeout": 50000,
	"wx": {
		"getopenid": true,
		"getuserinfo": false,
		"token": "dfeidao",
		"appid": "wx7d84eff0fb9683e4",
		"appsecret": "63d1f587ee735140cbe653822c3f5823"
	},
	"max_file_size": 53687091200,
	"secure": {
		"redirect": "",
		"ignore": [
			"/home.html",
			"http://thirdpart.com"
		]
	},
	"favicon": "./favicon.ico",
	"spaceid": "webtest",
	"type": "web",
	"routers": [
		{
			"url": "/xxx",
			"method": "get",
			"service": "dataservice.nodejs",
			"data": {
				"modelid": "web/captcha"
			}
		}
	]
}

java

运维提供的java服务地址,如 http://192.168.40.196/router4js

max_file_size

支持的最大文件大小,计算方法为 x*1024*1024,比如要设置限制最大上传200兆的文件,那么这个值就应该配置为200*1024*1024=209715200,比如要设置限制最大上传500兆的文件,那么这个值就应该配置为500*1024*1024=524288000

port

web容器的端口号,通常我们使用88898890

timeout

请求服务的超时时间(非客户端请求的时间),单位为毫秒,通常设置为5秒5000

wx.appid

微信公众号,微信小程序,均须配置该参数和wx.appsecret,用来调用微信开发平台接口使用.

wx.appsecret

微信公众号,微信小程序,均须配置该参数和wx.appid,用来调用微信开发平台接口使用.

wx.getopenid

公众号项目getopenidgetuserinfo必须配置其一值为true,通常建议设置getopenidtrue.二者的区别为:

  • getopenid

    用户打开页面无感知,体验好.

  • getuserinfo

    当该公众号页面无须关注但仍须获取用户信息时请设置 getuserinfo.

这二种方式均会在每个服务请求的消息体添加wxuserinfo参数.参数值有不同:

  • getopenid

     {
     	wxuserinfo: {
     		openid: string; // 用户的唯一标识
     	}
     }
  • getuserinfo

     {
     	openid: string;		// 用户的唯一标识
     	nickname: string;	// 用户昵称
     	sex: '1' | '2';		// 用户的性别,值为1时是男性,值为2时是女性,值为0时是未知
     	province: string;		// 用户个人资料填写的省份
     	city: string;			// 普通用户个人资料填写的城市
     	country: string;		// 国家,如中国为CN
     	headimgurl: string;	// 用户头像,最后一个数值代表正方形头像大小(有0、46、64、96、132数值可选,0代表640*640正方形头像),用户没有头像时该项为空。若用户更换头像,原有头像URL将失效。
     	privilege: string[];	// 用户特权信息,json 数组,如微信沃卡用户为(chinaunicom)
     	unionid: string;		// 只有在用户将公众号绑定到微信开放平台帐号后,才会出现该字段。
     }

wx.getuserinfo

参见wx.getopenid说明.

wx.token

登录公众号平台,在开发->基本配置->服务器配置->Token中配置

secure.redirect

该项目如果为安全级别较高项目需配置.配置参数参数之后,所有到服务器所有(ignore配置的页面除外)资源(包括服务调用,css,js等)的请求均会验证sessionid,如果未登录或登录失效,所有请求将会被拒绝,返回403错误.

secure.ignore

对于某些请求(比如登录页面,开放给第三方的服务地址)不能验证sessionid,请在这里配置.

favicon

请固定使用"./favicon.ico"作为该配置值.

spaceid

当前项目的spaceid

type

项目的类型,同一个产品下的不同端点的项目请务必配置为不同的值.通常使用的有web,h5,mobile.

routers

当前项目提供的web服务

routers.url

服务的url,支持通配符,请务必使用/开头.以下为保留url,项目上禁止使用.

  • /sendmessage
  • /wx-validate
  • /*.html
  • /*.docx
  • /*.pdf
  • /*.xlsx
  • /getip
  • /invoke-atom

routers.method

目前支持三种参数配置post,get,all(一般情况下请不要使用)

routers.service

messagetype,如js服务为dataservice.nodejs,也可以是其它服务端(如java服务)提供的其它服务.

routers.data

附加参数,这里设置的参数将会添加到消息体中.比如js服务需要添加固定参数"modelid": "xxx"(xxx为js服务路径),但不限于此,开发者可以添加更多的参数,以减少客户端调用参数及网络传输.

说明

favicon.ico

显示在浏览器地址栏以及收藏栏中的图标

log4js.json

日志配置,具体请参考官方说明:log4js

Package Sidebar

Install

npm i @dfeidao/server

Weekly Downloads

53

Version

5.0.1

License

MIT

Unpacked Size

54.1 kB

Total Files

34

Last publish

Collaborators

  • taoqf