cgserver 7.10.2113 → 7.11.2113

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/package.json +1 -1
  2. package/src/Framework/AI/AiObject.ts +0 -12
  3. package/src/Framework/AI/Astar.ts +0 -157
  4. package/src/Framework/AI/BehaviorAI.ts +0 -382
  5. package/src/Framework/AI/Entity.ts +0 -37
  6. package/src/Framework/AI/Point.ts +0 -84
  7. package/src/Framework/AI/TriggerMgr.ts +0 -280
  8. package/src/Framework/Config/Config.ts +0 -61
  9. package/src/Framework/Config/FrameworkConfig.ts +0 -286
  10. package/src/Framework/Config/IServerConfig.ts +0 -28
  11. package/src/Framework/Config/_error_.ts +0 -32
  12. package/src/Framework/Core/Core.ts +0 -810
  13. package/src/Framework/Core/Timer.ts +0 -147
  14. package/src/Framework/Database/Decorator/AutoIncrement.ts +0 -9
  15. package/src/Framework/Database/Decorator/DBCache.ts +0 -74
  16. package/src/Framework/Database/Decorator/NotNull.ts +0 -9
  17. package/src/Framework/Database/Decorator/PrimaryKey.ts +0 -9
  18. package/src/Framework/Database/Decorator/Property.ts +0 -64
  19. package/src/Framework/Database/Decorator/Table.ts +0 -13
  20. package/src/Framework/Database/Decorator/Type.ts +0 -21
  21. package/src/Framework/Database/MSSqlManager.ts +0 -52
  22. package/src/Framework/Database/MongoBaseService.ts +0 -136
  23. package/src/Framework/Database/MongoManager.ts +0 -501
  24. package/src/Framework/Database/MysqlBaseService.ts +0 -345
  25. package/src/Framework/Database/MysqlManager.ts +0 -212
  26. package/src/Framework/Database/RedisManager.ts +0 -544
  27. package/src/Framework/Logic/CacheTool.ts +0 -85
  28. package/src/Framework/Logic/EventTool.ts +0 -31
  29. package/src/Framework/Logic/HttpTool.ts +0 -82
  30. package/src/Framework/Logic/Log.ts +0 -171
  31. package/src/Framework/Logic/SyncQueueTool.ts +0 -51
  32. package/src/Framework/Service/AccountService.ts +0 -508
  33. package/src/Framework/Service/MongoAccountService.ts +0 -456
  34. package/src/Framework/Service/MongoCacheService.ts +0 -48
  35. package/src/Framework/Service/MongoUserService.ts +0 -103
  36. package/src/Framework/Service/UserService.ts +0 -168
  37. package/src/Framework/Service/ini.ts +0 -33
  38. package/src/Framework/SocketServer/IClientWebSocket.ts +0 -50
  39. package/src/Framework/SocketServer/IRpc.ts +0 -12
  40. package/src/Framework/SocketServer/IRpcClientWebSocket.ts +0 -75
  41. package/src/Framework/SocketServer/IRpcServerWebSocket.ts +0 -76
  42. package/src/Framework/SocketServer/IServerWebSocket.ts +0 -88
  43. package/src/Framework/SocketServer/ISocketServer.ts +0 -243
  44. package/src/Framework/SocketServer/IWebSocket.ts +0 -243
  45. package/src/Framework/SocketServer/ProtoFilter/GoogleProtoFilter.ts +0 -68
  46. package/src/Framework/SocketServer/ProtoFilter/IProtoFilter.ts +0 -11
  47. package/src/Framework/SocketServer/ProtoFilter/JsonProtoFilter.ts +0 -34
  48. package/src/Framework/SocketServer/ProtoFilter/ProtoFactory.ts +0 -34
  49. package/src/Framework/ThirdParty/AlipayTool.ts +0 -224
  50. package/src/Framework/ThirdParty/Alisms.ts +0 -53
  51. package/src/Framework/ThirdParty/AppleTool.ts +0 -252
  52. package/src/Framework/ThirdParty/CgMq.ts +0 -153
  53. package/src/Framework/ThirdParty/EmailTool.ts +0 -37
  54. package/src/Framework/ThirdParty/OpenSocial.ts +0 -36
  55. package/src/Framework/ThirdParty/QQTool.ts +0 -124
  56. package/src/Framework/ThirdParty/QiniuTool.ts +0 -23
  57. package/src/Framework/ThirdParty/Rpc.ts +0 -75
  58. package/src/Framework/ThirdParty/WechatOATool.ts +0 -61
  59. package/src/Framework/ThirdParty/WechatTool.ts +0 -80
  60. package/src/Framework/WebServer/Controller/BaseController.ts +0 -140
  61. package/src/Framework/WebServer/Controller/BaseUserController.ts +0 -209
  62. package/src/Framework/WebServer/Controller/MongoBaseUserController.ts +0 -209
  63. package/src/Framework/WebServer/Decorator/AdminValidate.ts +0 -19
  64. package/src/Framework/WebServer/Decorator/AuthorityValidate.ts +0 -25
  65. package/src/Framework/WebServer/Decorator/CreatorValidate.ts +0 -19
  66. package/src/Framework/WebServer/Decorator/JsonAdminValidate.ts +0 -16
  67. package/src/Framework/WebServer/Decorator/JsonAuthorityValidate.d.ts +0 -2
  68. package/src/Framework/WebServer/Decorator/JsonAuthorityValidate.ts +0 -23
  69. package/src/Framework/WebServer/Decorator/JsonCreatorValidate.ts +0 -19
  70. package/src/Framework/WebServer/Decorator/SyncCall.ts +0 -20
  71. package/src/Framework/WebServer/Decorator/SyncCallServer.ts +0 -45
  72. package/src/Framework/WebServer/Engine/ControllerManager.ts +0 -134
  73. package/src/Framework/WebServer/Engine/Engine.ts +0 -186
  74. package/src/Framework/WebServer/Engine/RazorJs.ts +0 -720
  75. package/src/Framework/WebServer/Engine/Request.ts +0 -267
  76. package/src/Framework/WebServer/Engine/Response.ts +0 -123
  77. package/src/Framework/WebServer/IWebServer.ts +0 -61
  78. package/src/Framework/cgserver.ts +0 -112
  79. package/src/Framework/index.ts +0 -92
  80. package/src/test/test.ts +0 -12
@@ -1,134 +0,0 @@
1
- import { BaseController } from "../Controller/BaseController";
2
-
3
- export let GCtrMgr:ControllerManager = null
4
- class ControllerManager
5
- {
6
- protected _static_ctr:{[module_name:string]:{[ctrname:string]:BaseController}}={}
7
- protected _ctr_cls:{[module_name:string]:{[ctrname:string]:any}}={}
8
- //module ctrname lower normal
9
- protected _cache_action_names:{[module:string]:{[ctrname:string]:{[lower:string]:string}}}={}
10
- registerController(module_name:string,ctr_name:string,cls:any)
11
- {
12
- module_name = module_name.toLowerCase()
13
- ctr_name = ctr_name.toLowerCase()
14
- if(module_name==ctr_name)
15
- {
16
- throw("模块名称不能和控制器名称相同:"+module_name)
17
- }
18
- this._ctr_cls[module_name] = this._ctr_cls[module_name] || {}
19
- this._ctr_cls[module_name][ctr_name] = cls
20
- this._cacheActionName(module_name,ctr_name,cls)
21
- }
22
- protected _cacheActionName(module_name:string,ctr_name:string,cls:Function)
23
- {
24
- module_name = module_name.toLowerCase()
25
- ctr_name = ctr_name.toLowerCase()
26
- //不能通过cls.name来获取ctr名称,因为混淆之后类名会变化
27
- let prototype = cls.prototype
28
- let map_names:{[actionlowername:string]:string}={}
29
- while(prototype&&prototype.constructor.name!="BaseController")
30
- {
31
- let names = Object.getOwnPropertyNames(prototype)
32
- for(let action_name of names)
33
- {
34
- if(action_name.indexOf("on")!=0
35
- &&action_name.indexOf("show")!=0)
36
- {
37
- continue
38
- }
39
- if(map_names[action_name.toLowerCase()])
40
- {
41
- continue
42
- }
43
- map_names[action_name.toLowerCase()]=action_name
44
- }
45
- prototype=Object.getPrototypeOf(prototype)
46
- }
47
- this._cache_action_names[module_name]=this._cache_action_names[module_name]||{}
48
- this._cache_action_names[module_name][ctr_name]=map_names
49
- }
50
- getActionName(module_name:string,ctr_name:string,action_name:string)
51
- {
52
- module_name = module_name.toLowerCase()
53
- ctr_name = ctr_name.toLowerCase()
54
- action_name = action_name.toLowerCase()
55
- if(!this._cache_action_names[module_name])
56
- {
57
- return null
58
- }
59
- if(!this._cache_action_names[module_name][ctr_name])
60
- {
61
- return null
62
- }
63
- return this._cache_action_names[module_name][ctr_name][action_name]
64
- }
65
- /**
66
- * 静态ctr,这样,ctr就不会被多次创建
67
- * @param module_name
68
- * @param ctr_name
69
- * @param obj
70
- */
71
- registerStaticController(module_name:string,ctr_name:string,obj:BaseController)
72
- {
73
- module_name = module_name.toLowerCase()
74
- ctr_name = ctr_name.toLowerCase()
75
- this._static_ctr[module_name] = this._static_ctr[module_name] || {}
76
- this._static_ctr[module_name][ctr_name] = obj
77
- this._cacheActionNameForStatic(module_name,ctr_name,obj)
78
- }
79
- protected _cacheActionNameForStatic(module_name:string,ctr_name:string,obj:BaseController)
80
- {
81
- module_name = module_name.toLowerCase()
82
- ctr_name = ctr_name.toLowerCase()
83
- let prototype=Object.getPrototypeOf(obj)
84
- let map_names:{[actionlowername:string]:string}={}
85
- while(prototype&&prototype.constructor.name!="BaseController")
86
- {
87
- let names = Object.getOwnPropertyNames(prototype)
88
- for(let func_name of names)
89
- {
90
- let low_name=func_name.toLowerCase()
91
- if(!map_names[low_name])//有可能遭遇重载
92
- {
93
- map_names[low_name]=func_name
94
- }
95
- }
96
- prototype=Object.getPrototypeOf(prototype)
97
- }
98
- this._cache_action_names[module_name]=this._cache_action_names[module_name]||{}
99
- this._cache_action_names[module_name][ctr_name]=map_names
100
- }
101
- getStaticCtr(module_name:string,controller_name:string)
102
- {
103
- if(module_name)
104
- {
105
- module_name = module_name.toLowerCase()
106
- }
107
- if(controller_name)
108
- {
109
- controller_name = controller_name.toLowerCase()
110
- }
111
- if(!this._static_ctr[module_name])
112
- {
113
- return
114
- }
115
- return this._static_ctr[module_name][controller_name]
116
- }
117
- getClass(module_name:string,controller_name:string)
118
- {
119
- if(module_name)
120
- {
121
- module_name = module_name.toLowerCase()
122
- }
123
- if(controller_name)
124
- {
125
- controller_name = controller_name.toLowerCase()
126
- }
127
- if(!this._ctr_cls[module_name])
128
- {
129
- return
130
- }
131
- return this._ctr_cls[module_name][controller_name]
132
- }
133
- }
134
- GCtrMgr = new ControllerManager()
@@ -1,186 +0,0 @@
1
- import { Response } from './Response';
2
- import { Request } from './Request';
3
- import { GCtrMgr } from './ControllerManager';
4
- import { RazorJs } from './RazorJs';
5
- import * as http from "http";
6
- import { GLog } from '../../Logic/Log';
7
- import { WebServerConfig } from '../../Config/FrameworkConfig';
8
- import * as cors from "cors";
9
- import * as Express from 'express';
10
- import * as bodyParser from 'body-parser';
11
- import cookieParser = require('cookie-parser');
12
- export class Engine
13
- {
14
- protected _app = Express()
15
- protected _cfg:WebServerConfig=null
16
- get cfg()
17
- {
18
- return this._cfg
19
- }
20
- protected _server:http.Server=null
21
- protected _razorJs:RazorJs=null
22
- protected _root_path=process.cwd()
23
- constructor(cfg:WebServerConfig,razorJs:RazorJs)
24
- {
25
- this._cfg=cfg
26
- this._razorJs = razorJs
27
- }
28
- start()
29
- {
30
- let port = this._cfg.port
31
- let https = require("https");
32
- let fs = require("fs");
33
-
34
- if(!port)
35
- {
36
- GLog.error(this._cfg)
37
- return
38
- }
39
- http.createServer(this._app).listen(port,()=>
40
- {
41
- GLog.info("Server("+this._cfg.web_name+") running at http://127.0.0.1:" + port + "/")
42
- });
43
-
44
- if(this._cfg.ssl)
45
- {
46
- const httpsOption = {
47
- key : fs.readFileSync(this._cfg.ssl.key),
48
- cert: fs.readFileSync(this._cfg.ssl.crt)
49
- }
50
- https.createServer(httpsOption, this._app).listen(port+1);
51
- GLog.info("Server("+this._cfg.web_name+") running at https://127.0.0.1:" + (port+1) + "/")
52
- }
53
-
54
- this._app.use(cookieParser())
55
- this._app.use(bodyParser.json({limit: '10mb'}))
56
- this._app.use(bodyParser.urlencoded({limit: '10mb', extended: true}))
57
- //处理跨域
58
- if(this._cfg.cors)
59
- {
60
- let origin:any = this._cfg.cors.origin||"*"
61
- if(this._cfg.cors.credentials==true&&origin=="*")
62
- {
63
- origin=(origin, callback)=>{
64
- callback(null, true)
65
- }
66
- }
67
- this._app.use(cors({
68
- origin:origin, //指定接收的地址,将localhost改成前端IP地址
69
- methods:this._cfg.cors.methods||'GET,HEAD,PUT,PATCH,POST,DELETE', //指定接收的请求类型
70
- allowedHeaders:this._cfg.cors.allowedHeaders||['Content-Type'], //指定header
71
- credentials:this._cfg.cors.credentials||false
72
- }))
73
- }
74
- this._app.all("/*",(_req:Express.Request,_res:Express.Response)=>
75
- {
76
- this._all(_req,_res).catch((reason)=>
77
- {
78
- GLog.error(reason)
79
- let res=new Response(_res,this._cfg)
80
- let method=_req.method.toLowerCase()
81
- if(method=="post")
82
- {
83
- res.renderJson500()
84
- }
85
- else if(method=="get")
86
- {
87
- res.render500()
88
- }
89
- })
90
- })
91
- }
92
- protected async _all(_req:Express.Request,_res:Express.Response)
93
- {
94
- let req=new Request(_req,this._cfg)
95
- let res=new Response(_res,this._cfg)
96
- if(req.fileUrl)
97
- {
98
- let fileUrl:string = req.fileUrl
99
- fileUrl=fileUrl.toLocaleLowerCase()
100
- if(fileUrl.startsWith("data")||fileUrl.startsWith("/data"))
101
- {
102
- res.render404()
103
- return
104
- }
105
- res.renderFile(this._root_path+req.fileUrl)
106
- return
107
- }
108
- let method=req.method.toLowerCase()
109
- if(method!="get"&&method!="post")
110
- {
111
- return
112
- }
113
- let pre_action = "show"
114
- let action_name=""
115
- if(method=="post")
116
- {
117
- pre_action="on"
118
- }
119
- //大小写还原
120
- action_name = GCtrMgr.getActionName(req.module,req.controller,pre_action+req.action)
121
- //尝试一次on,变态支持
122
- if(!action_name&&method=="get")
123
- {
124
- pre_action="on"
125
- action_name = GCtrMgr.getActionName(req.module,req.controller,pre_action+req.action)
126
- }
127
- if(!action_name)
128
- {
129
- if(method=="get")
130
- {
131
- res.render404()
132
- }
133
- else if(method=="post")
134
- {
135
- res.renderJson404()
136
- }
137
- return
138
- }
139
- let ctr = GCtrMgr.getStaticCtr(req.module,req.controller)
140
- let cls_ctr = null
141
- if(!ctr)
142
- {
143
- cls_ctr = GCtrMgr.getClass(req.module,req.controller)
144
- }
145
-
146
- if(!ctr)
147
- {
148
- ctr = new cls_ctr(req,res,this)
149
- await ctr.init()
150
- }
151
- else
152
- {
153
- ctr.initStatic(req,res,this)
154
- }
155
- ctr[action_name].call(ctr)
156
- }
157
- stop()
158
- {
159
-
160
- }
161
- getRenderHtml(req:Request,res:Response, datas)
162
- {
163
- let tmpl = "view/" + req.controller.toLowerCase() + "/" + req.action.toLowerCase()
164
- //if(!this._cfg.routs.onlyModule)
165
- {
166
- tmpl = "modules/"+req.module.toLowerCase()+"/"+tmpl
167
- }
168
- let html = this._getRenderHtml(req, res, tmpl, datas)
169
- return html
170
- }
171
- protected _getRenderHtml(req:Request, res:Response, tmpl, params)
172
- {
173
- let html = null
174
- try
175
- {
176
- html = this._razorJs.render(req, res, tmpl, params,{compileDebug:true})
177
- html = html.replace(/\"~/g, "\"" + req.root)
178
- html = html.replace(/\'~/g, "\'" + req.root)
179
- }
180
- catch (e)
181
- {
182
- html = "error!" + e
183
- }
184
- return html
185
- }
186
- }