badmfck-api-server 2.4.7 → 2.5.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/apiServer/APIService.js +8 -4
- package/dist/apiServer/APIService.js.map +1 -0
- package/dist/apiServer/BaseEndpoint.js +1 -0
- package/dist/apiServer/BaseEndpoint.js.map +1 -0
- package/dist/apiServer/BaseService.js +1 -0
- package/dist/apiServer/BaseService.js.map +1 -0
- package/dist/apiServer/ClusterService.d.ts +18 -5
- package/dist/apiServer/ClusterService.js +45 -14
- package/dist/apiServer/ClusterService.js.map +1 -0
- package/dist/apiServer/DocumentService.js +1 -0
- package/dist/apiServer/DocumentService.js.map +1 -0
- package/dist/apiServer/HUBService.d.ts +11 -4
- package/dist/apiServer/HUBService.js +79 -18
- package/dist/apiServer/HUBService.js.map +1 -0
- package/dist/apiServer/LocalRequest.js +1 -0
- package/dist/apiServer/LocalRequest.js.map +1 -0
- package/dist/apiServer/LogService.js +1 -0
- package/dist/apiServer/LogService.js.map +1 -0
- package/dist/apiServer/MysqlService.js +4 -3
- package/dist/apiServer/MysqlService.js.map +1 -0
- package/dist/apiServer/WSAPITransport.js +1 -0
- package/dist/apiServer/WSAPITransport.js.map +1 -0
- package/dist/apiServer/WebSocketHandler.d.ts +0 -0
- package/dist/apiServer/WebSocketHandler.js +2 -0
- package/dist/apiServer/WebSocketHandler.js.map +1 -0
- package/dist/apiServer/WebsocketService.js +1 -0
- package/dist/apiServer/WebsocketService.js.map +1 -0
- package/dist/apiServer/cluster/HUBConnection.d.ts +25 -25
- package/dist/apiServer/cluster/HUBConnection.js +107 -88
- package/dist/apiServer/cluster/HUBConnection.js.map +1 -0
- package/dist/apiServer/cluster/HUBHandlres.d.ts +0 -0
- package/dist/apiServer/cluster/HUBHandlres.js +2 -0
- package/dist/apiServer/cluster/HUBHandlres.js.map +1 -0
- package/dist/apiServer/deployment/Deployment.js +1 -0
- package/dist/apiServer/deployment/Deployment.js.map +1 -0
- package/dist/apiServer/helper/DataProvider.js +1 -0
- package/dist/apiServer/helper/DataProvider.js.map +1 -0
- package/dist/apiServer/helper/Sleep.d.ts +1 -0
- package/dist/apiServer/helper/Sleep.js +6 -0
- package/dist/apiServer/helper/Sleep.js.map +1 -0
- package/dist/apiServer/helper/UID.js +1 -0
- package/dist/apiServer/helper/UID.js.map +1 -0
- package/dist/apiServer/helper/Validator.js +1 -0
- package/dist/apiServer/helper/Validator.js.map +1 -0
- package/dist/apiServer/monitor/Monitor.js +1 -0
- package/dist/apiServer/monitor/Monitor.js.map +1 -0
- package/dist/apiServer/routes/Liveness.js +1 -0
- package/dist/apiServer/routes/Liveness.js.map +1 -0
- package/dist/apiServer/routes/Readiness.js +1 -0
- package/dist/apiServer/routes/Readiness.js.map +1 -0
- package/dist/apiServer/structures/DefaultErrors.js +1 -0
- package/dist/apiServer/structures/DefaultErrors.js.map +1 -0
- package/dist/apiServer/structures/HTTPStatus.js +1 -0
- package/dist/apiServer/structures/HTTPStatus.js.map +1 -0
- package/dist/apiServer/structures/Interfaces.js +1 -0
- package/dist/apiServer/structures/Interfaces.js.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/package.json +2 -2
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"HUBConnection.js","sourceRoot":"","sources":["../../../src/apiServer/cluster/HUBConnection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2BAAwC;AACxC,8CAAkD;AAClD,6EAAwE;AAgCxE,MAAa,aAAa;IACtB,MAAM,CAAC,UAAU,GAAQ,CAAC,CAAC;IACnB,SAAS,GAA8D,IAAI,GAAG,EAAE,CAAC;IACzF,UAAU,GAAW,KAAK,CAAC;IACnB,EAAE,CAAW;IACb,YAAY,CAAU;IAC9B,OAAO,CAAuB;IAE9B,YAAY,OAA6B;QAErC,IAAA,oBAAO,EAAC,+BAA+B,EAAC,OAAO,CAAC,MAAM,EAAC,OAAO,CAAC,QAAQ,EAAC,OAAO,CAAC,SAAS,KAAG,UAAU,CAAA,CAAC,CAAA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,CAAC;QAEH,IAAG,MAAM,CAAC,UAAU,KAAG,CAAC;YACpB,OAAO,IAAI,CAAC;QAEhB,OAAO,OAAO,CAAC;IACnB,CAAC;IAGD,KAAK;QACD,IAAA,oBAAO,EAAC,iCAAiC,CAAC,CAAA;QAC1C,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,UAAU,GAAC,KAAK,CAAC;QAEtB,IAAG,IAAI,CAAC,EAAE,EAAC;YACP,IAAG;gBACC,IAAI,CAAC,EAAE,CAAC,kBAAkB,EAAE,CAAC;gBAC7B,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;gBAChB,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC;aACvB;YAAA,OAAM,CAAC,EAAC,GAAE;SACd;IACL,CAAC;;AA7SL,sCA+SC","sourcesContent":["import { RawData, WebSocket } from \"ws\";\nimport { logError, logInfo } from \"../LogService\";\nimport DefaultErrors, { ErrorUtils } from \"../structures/DefaultErrors\";\nimport { IError } from \"../structures/Interfaces\";\nimport { privateDecrypt } from \"crypto\";\nimport Signal, { Req } from \"badmfck-signal\";\nimport { IWebsocketPacket } from \"../HUBService\";\n\nexport interface IClusterPacket{\n method:string,\n data?:any|null,\n error?:IError,\n callbackID:number\n}\n\nexport interface IHUBConnectionOptions{\n direction:\"incoming\"|\"outgoing\",\n ws:WebSocket,\n\n hostID:string,\n hostPrivateKey:string,\n hostPublicKey:string,\n hostURL:string,\n\n targetID:string|null,\n targetPublicKey:string|null,\n targetURL:string|null,\n\n onAuthorized:()=>void,\n onClose:()=>void,\n handlers:(Req<any,any>|Signal<any>)[],\n maxTimeout?:number\n}\n\nexport class HUBConnection{\n static callbackID:number=1;\n private callbacks:Map<number,{time:number,callback:(result:any|IError)=>void}>=new Map();\n authorized:boolean = false;\n private ws:WebSocket;\n private onAuthorized:()=>void;\n options:IHUBConnectionOptions;\n \n constructor(options:IHUBConnectionOptions){\n \n logInfo(\"HUBConnection: new connection\",options.hostID,options.targetID,options.direction===\"outgoing\"?options.ws.url+\" -->\":\" <--\");\n\n this.options = options;\n this.ws = options.ws;\n this.onAuthorized = options.onAuthorized\n \n\n this.ws.on(\"close\",()=>{\n if(!this.authorized)\n return;\n logInfo(\"HUBConnection: connection closed\")\n if(options.onClose)\n options.onClose();\n })\n\n this.ws.on(\"error\",(e)=>{\n logError(\"HUBConnection: connection error\",e);\n });\n\n this.ws.on(\"open\",()=>{\n logInfo(\"HUBConnection: connection opened\",options.direction)\n if(options.direction===\"outgoing\"){\n logInfo(\"HUBConnection: send authroization\")\n this.sendAuth();\n }\n })\n\n this.ws.on(\"message\",async (msg:RawData,isBinary)=>{\n \n if(isBinary){\n logError(\"HUBConnection: invalid packet type, must be a string\");\n return;\n }\n\n let data = null;\n try{\n data = JSON.parse(msg.toString(\"utf8\"))\n }catch(e){}\n\n //logInfo(\"HUBConnection: message received\",this.options.direction,data);\n\n // check packet structure\n if(!data || !data.method || !data.callbackID){\n logError(\"HUBConnection: invalid packet structure\",data);\n return;\n }\n\n // handle packets\n if(typeof data.method !== \"string\" || typeof data.callbackID !== \"number\"){\n logError(\"HUBConnection: invalid packet structure\",data);\n return;\n }\n\n // callbackID\n const callbackID = parseInt(data.callbackID);\n \n // handle callbacks\n if(data.method===\"callback\"){\n this.handleCallback(data);\n return;\n };\n\n \n if(!this.authorized && data.method===\"auth\"){\n // do authorization \n const result = await this.authorize(data.data);\n if(ErrorUtils.isError(result)){\n logError(\"HUBConnection: authorization failed\",result);\n this.sendCallback(callbackID,result);\n return;\n }\n this.authorized = true;\n if(this.onAuthorized)\n this.onAuthorized();\n this.sendCallback(callbackID,result);\n return;\n }\n\n \n \n if(!this.authorized){\n logError(\"HUBConnection: not authorized\");\n this.sendCallback(callbackID,DefaultErrors.UNAUTHORIZED);\n return;\n }\n\n // handle methods\n for(let i of options.handlers){\n if(i.name === data.method){\n\n const requestPacket:IWebsocketPacket={\n data:data.data,\n authorized:this.authorized,\n connection:this\n }\n\n if(i.type === \"signal\"){\n (i as Signal<IWebsocketPacket>).invoke(requestPacket);\n if(data.callbackID>0)\n this.sendCallback(callbackID,{});\n return;\n }else if(i.type === \"request\"){\n const result = await (i as Req<IWebsocketPacket,any>).request(requestPacket);\n this.sendCallback(callbackID,result);\n return;\n }\n }\n }\n\n this.sendCallback(callbackID,{...DefaultErrors.NOT_IMPLEMENTED,details:\"method not found: \"+data.method});\n \n })\n\n \n setTimeout(()=>{\n if(!this.authorized){\n logError(\"HUBConnection: authorization timeout\",this.authorized)\n this.close();\n }\n },15000); // 15sec for authorization\n \n\n setInterval(()=>{\n const now = +new Date();\n for(let [key,value] of this.callbacks){\n if(now-value.time>(options.maxTimeout ?? 1000*60*15)){\n value.callback({method:\"callback\",data:null,callbackID:key,error:{...DefaultErrors.TIMEOUT}});\n this.callbacks.delete(key);\n }\n }\n },options.maxTimeout || 1000*60*15);\n\n }\n\n\n async sendAuth(){\n // logInfo(\"HUBConnection: send auth packet\")\n const response = await this.send({\n method:\"auth\",\n data:{\n hostID:this.options.targetID, // REMOTE HOST ID\n targetPublicKey:this.options.hostPublicKey, // LOCAL PUBLIC KEY\n targetURL:this.options.hostURL, // LOCAL URL\n targetID:this.options.hostID // LOCAL HOST ID\n },\n callbackID:1\n })\n\n if(ErrorUtils.isError(response)){\n logError(\"HUBConnection: auth failed\",response);\n this.close();\n return;\n }\n\n this.authorized=true;\n \n if(!response || !response.hostID || !response.hostPublicKey || !response.hostURL){\n logError(\"HUBConnection: invalid auth response\",response);\n this.close();\n return;\n }\n\n\n // store targetID, targetPublicKey, targetURL\n this.options.targetID = response.hostID;\n this.options.targetPublicKey = response.hostPublicKey;\n this.options.targetURL = response.hostURL;\n \n // logInfo(\"HUBConnection: auth success\",response);\n\n if(this.onAuthorized)\n this.onAuthorized();\n \n }\n\n /**\n * \n * @param data -> {signature:encrypted hub key,publicKey:encrypted public key, clientID:clientID}\n * @returns \n */\n async authorize(data:any):Promise<any|IError>{\n\n //logInfo(\"HUBConnection: try to authorize connection\",data);\n\n if(typeof data !== \"object\" || !data || !data.hostID || !data.targetPublicKey || !data.targetID || !data.targetURL)\n return {...DefaultErrors.BAD_REQUEST,stack:[data],details:\"expecting {hostID:string,targetPublicKey:string,targetID:string,targetURL:string}\"};\n\n if(data.hostID !== this.options.hostID)\n return {...DefaultErrors.UNAUTHORIZED,details:\"invalid targetID\"};\n\n //logInfo(\"HUBConnection: authorize success\",this.options.direction,data);\n\n //1. store target info\n this.options.targetID = data.targetID;\n this.options.targetPublicKey = data.targetPublicKey;\n this.options.targetURL = data.targetURL;\n\n //2. send local info\n return {\n hostID:this.options.hostID,\n hostPublicKey:this.options.hostPublicKey,\n hostURL:this.options.hostURL\n }\n\n }\n\n\n handleCallback(data:IClusterPacket){\n \n if(!this.callbacks.has(data.callbackID)){\n logError(\"HUBConnection: callback not found\",data);\n return;\n }\n //logInfo(\"HUBConnection: execute callback\",data);\n\n \n const cb = this.callbacks.get(data.callbackID);\n if(cb){\n cb.callback(data.data ?? data.error);\n this.callbacks.delete(data.callbackID);\n }\n }\n\n \n sendCallback(callbackID:number,data:IError|any){\n\n if(isNaN(callbackID) || callbackID<=0){\n logError(\"HUBConnection: invalid callbackID\",callbackID,data);\n return;\n }\n\n // logInfo(\"HUBConnection: send callback\",data);\n\n if(this.ws && this.ws.readyState===WebSocket.OPEN){\n this.ws.send(JSON.stringify({\n method:\"callback\",\n error:ErrorUtils.isError(data)?data:null,\n data:ErrorUtils.isError(data)?null:data,\n callbackID:callbackID\n }))\n }else{\n logError(\"HUBConnection: ws not connected, cant send callback\",this.options.direction,data)\n }\n }\n\n async send(packet:IClusterPacket):Promise<any|IError|null>{\n // logInfo(\"HUBConnection: send packet\",this.options.direction,packet);\n if(!this.ws || this.ws.readyState !== WebSocket.OPEN){\n logError(\"HUBConnection: ws not connected, cant send packet\",packet)\n return {...DefaultErrors.SERVICE_NOT_WORKING,details:\"ws not connected\"};\n }\n \n let cb=null;\n const promise = new Promise<IClusterPacket|null>((resolve)=>cb=resolve);\n\n if(packet.callbackID>0){\n const callbackID = HUBConnection.callbackID++;\n this.callbacks.set(callbackID,{time:+new Date(),callback:cb!});\n packet.callbackID = callbackID;\n }\n\n //todo - encrypt data\n\n this.ws.send(JSON.stringify(packet),err=>{\n if(err){\n logError(\"HUBConnection: cant send packet\",err);\n if(packet.callbackID>0)\n this.callbacks.delete(packet.callbackID);\n cb!(DefaultErrors.SERVICE_NOT_WORKING);\n }\n });\n\n if(packet.callbackID===0)\n return null;\n\n return promise;\n }\n\n\n close(){\n logInfo(\"HUBConnection: close connection\")\n this.callbacks.clear();\n this.authorized=false;\n\n if(this.ws){\n try{\n this.ws.removeAllListeners();\n this.ws.close();\n this.ws.terminate();\n }catch(e){}\n }\n }\n\n}\n\n"]}
|
File without changes
|
@@ -0,0 +1,2 @@
|
|
1
|
+
"use strict";
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSFVCSGFuZGxyZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvYXBpU2VydmVyL2NsdXN0ZXIvSFVCSGFuZGxyZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsInNvdXJjZXNDb250ZW50IjpbIiJdfQ==
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"HUBHandlres.js","sourceRoot":"","sources":["../../../src/apiServer/cluster/HUBHandlres.ts"],"names":[],"mappings":"","sourcesContent":[""]}
|
@@ -22,3 +22,4 @@ class Deployment extends BaseEndpoint_1.BaseEndpoint {
|
|
22
22
|
}
|
23
23
|
}
|
24
24
|
exports.Deployment = Deployment;
|
25
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRGVwbG95bWVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9hcGlTZXJ2ZXIvZGVwbG95bW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0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Deployment.js","sourceRoot":"","sources":["../../../src/apiServer/deployment/Deployment.ts"],"names":[],"mappings":";;;;;;AACA,kDAA+C;AAC/C,oDAA4B;AAE5B,8CAAwC;AAGxC,MAAa,UAAW,SAAQ,2BAAY;IAExC,IAAI,CAAO;IACX,YAAY,EAAC,KAAK,EAAC,QAAQ,EAAgC;QACvD,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,gBAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,GAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACxF,IAAA,oBAAO,EAAC,4CAA4C,GAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC/D,IAAI,CAAC,iBAAiB,CAAC;YACnB,EAAC,iBAAiB,EAAC,IAAI,EAAC,QAAQ,EAAC,IAAI,CAAC,IAAI,EAAC,OAAO,EAAC,IAAI,CAAC,iBAAiB,EAAC;SAC7E,CAAC,CAAA;IACN,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,GAAkB;QAGtC,OAAO,EAAE,CAAA;IACb,CAAC;CACJ;AAjBD,gCAiBC","sourcesContent":["import { Req } from \"badmfck-signal\";\nimport { BaseEndpoint } from \"../BaseEndpoint\";\nimport crypto from \"crypto\";\nimport { HTTPRequestVO, TransferPacketVO } from \"../structures/Interfaces\";\nimport { logWarn } from \"../LogService\";\n\n\nexport class Deployment extends BaseEndpoint{\n\n hash:string\n constructor({login,password}:{login:string,password:string}){\n super(\"sys-deployment\");\n this.hash = crypto.createHash(\"sha256\").update(login+password).digest().toString(\"hex\");\n logWarn(\"Deployment initialized at: sys-deployment/\"+this.hash)\n this.registerEndpoints([\n {ignoreInterceptor:true,endpoint:this.hash,handler:this.deploymentHistory},\n ])\n }\n\n async deploymentHistory(req: HTTPRequestVO): Promise<TransferPacketVO<any>> {\n //const encryptedPasswordAndLoging = \n // todo - get project root directory\n return {}\n }\n}"]}
|
@@ -59,3 +59,4 @@ class DataProvider {
|
|
59
59
|
}
|
60
60
|
}
|
61
61
|
exports.DataProvider = DataProvider;
|
62
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRGF0YVByb3ZpZGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2FwaVNlcnZlci9oZWxwZXIvRGF0YVByb3ZpZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQUFBLG9FQUFvQztBQU1wQyxNQUFhLFlBQVk7SUFDYixNQUFNLENBQUMsTUFBTSxHQUFDLENBQUMsQ0FBQztJQUNoQixJQUFJLENBQVM7SUFDYixJQUFJLEdBQUMsS0FBSyxDQUFDO0lBQ1gsZUFBZSxHQUFDLENBQUMsQ0FBQztJQUNsQixTQUFTLEdBQUMsSUFBSSxHQUFDLEVBQUUsR0FBQyxDQUFDLENBQUE7SUFDbkIsSUFBSSxDQUFrQjtJQUN0QixTQUFTLEdBQUMsSUFBSSx3QkFBTSxFQUFPLENBQUE7SUFDM0IsUUFBUSxHQUFTLEtBQUssQ0FBQztJQUV2QixRQUFRLENBQW9EO0lBUXBFLFlBQVksUUFBNEQsRUFBQyxTQUFpQixFQUFDLElBQVk7UUFDbkcsSUFBSSxDQUFDLFFBQVEsR0FBQyxRQUFRLENBQUM7UUFDdkIsSUFBRyxTQUFTLEtBQUcsU0FBUztZQUNwQixJQUFJLENBQUMsU0FBUyxHQUFDLENBQUMsU0FBUyxDQUFDO1FBQzlCLElBQUcsS0FBSyxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUM7WUFDcEIsSUFBSSxDQUFDLFNBQVMsR0FBQyxDQUFDLENBQUM7UUFDckIsSUFBRyxDQUFDLElBQUksQ0FBQyxJQUFJO1lBQ1QsSUFBSSxDQUFDLElBQUks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c0Vycm9yPWZhbHNlO1xuICAgICAgICBjb25zdCByZXMgPSBhd2FpdCB0aGlzLmV4ZWN1dG9yKCk7XG4gICAgICAgIHRoaXMuYnVzeT1mYWxzZTtcbiAgICAgICAgdGhpcy53YXNFcnJvcj1yZXMuZXJyb3IgPz8gZmFsc2U7XG4gICAgICAgIHRoaXMuZGF0YT1yZXMuZGF0YVxuICAgICAgICB0aGlzLmxhc3RSZXF1ZXN0VGltZT0rbmV3IERhdGUoKTtcbiAgICAgICAgdGhpcy5jYWxsYmFja3MuaW52b2tlKHRoaXMuZGF0YSk7XG4gICAgICAgIHRoaXMuY2FsbGJhY2tzLnJlbW92ZUFsbCgpO1xuICAgICAgICByZXR1cm4gdGhpcy5kYXRhO1xuICAgIH1cbiAgICBcbn0iXX0=
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"DataProvider.js","sourceRoot":"","sources":["../../../src/apiServer/helper/DataProvider.ts"],"names":[],"mappings":";;;;;;AAAA,oEAAoC;AAMpC,MAAa,YAAY;IACb,MAAM,CAAC,MAAM,GAAC,CAAC,CAAC;IAChB,IAAI,CAAS;IACb,IAAI,GAAC,KAAK,CAAC;IACX,eAAe,GAAC,CAAC,CAAC;IAClB,SAAS,GAAC,IAAI,GAAC,EAAE,GAAC,CAAC,CAAA;IACnB,IAAI,CAAkB;IACtB,SAAS,GAAC,IAAI,wBAAM,EAAO,CAAA;IAC3B,QAAQ,GAAS,KAAK,CAAC;IAEvB,QAAQ,CAAoD;IAQpE,YAAY,QAA4D,EAAC,SAAiB,EAAC,IAAY;QACnG,IAAI,CAAC,QAAQ,GAAC,QAAQ,CAAC;QACvB,IAAG,SAAS,KAAG,SAAS;YACpB,IAAI,CAAC,SAAS,GAAC,CAAC,SAAS,CAAC;QAC9B,IAAG,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC;YACpB,IAAI,CAAC,SAAS,GAAC,CAAC,CAAC;QACrB,IAAG,CAAC,IAAI,CAAC,IAAI;YACT,IAAI,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,KAAK,CAAC;QACjC,IAAI,CAAC,IAAI,GAAC,GAAG,CAAC,IAAI,CAAA;QAClB,IAAI,CAAC,eAAe,GAAC,CAAC,IAAI,IAAI,EAAE,CAAC;QACjC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;;AAlEL,oCAoEC","sourcesContent":["import Signal from \"badmfck-signal\";\n\n/**\n * DataProvider \n * gathering data throught executor and handle duplicate requests\n */\nexport class DataProvider<T>{\n private static nextID=1;\n private name?:string;\n private busy=false;\n private lastRequestTime=0;\n private cacheTime=1000*60*5\n private data:T|undefined|null;\n private callbacks=new Signal<any>()\n private wasError:boolean=false;\n\n private executor:()=>Promise<{data:T|null|undefined,error?:boolean}>\n\n /**\n * \n * @param executor Execute procedure stored in executor, when need to get data\n * @param cacheTime cache interval\n * @param name DataProvider name (debugging)\n */\n constructor(executor:()=>Promise<{data:T|null|undefined,error?:boolean}>,cacheTime?:number,name?:string){\n this.executor=executor;\n if(cacheTime!==undefined)\n this.cacheTime=+cacheTime;\n if(isNaN(this.cacheTime))\n this.cacheTime=0;\n if(!this.name)\n this.name=\"DataProvider \"+(DataProvider.nextID++)\n }\n\n async forceUpdate(){\n if(this.busy)\n return;\n this.wasError=false;\n this.lastRequestTime=0;\n await this.getData()\n }\n\n localUpdate(data:T){\n if(this.busy)\n return;\n this.wasError=false;\n this.lastRequestTime=+new Date();\n this.data = data\n }\n\n async getData():Promise<T|null|undefined>{\n\n if(this.busy)\n return new Promise((resolve,reject)=>this.callbacks.subscribe((d)=>resolve(d)))\n \n if(this.lastRequestTime>0 && !this.wasError){\n // check cachetime\n const diff = (+new Date()) - this.lastRequestTime;\n if(diff<this.cacheTime)\n return this.data; // return cached value\n }\n\n this.busy=true;\n this.wasError=false;\n const res = await this.executor();\n this.busy=false;\n this.wasError=res.error ?? false;\n this.data=res.data\n this.lastRequestTime=+new Date();\n this.callbacks.invoke(this.data);\n this.callbacks.removeAll();\n return this.data;\n }\n \n}"]}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const Sleep: (ms: number) => Promise<unknown>;
|
@@ -0,0 +1,6 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Sleep = void 0;
|
4
|
+
const Sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
5
|
+
exports.Sleep = Sleep;
|
6
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU2xlZXAuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvYXBpU2VydmVyL2hlbHBlci9TbGVlcC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBTyxNQUFNLEtBQUssR0FBRyxDQUFDLEVBQVUsRUFBRSxFQUFFLENBQUMsSUFBSSxPQUFPLENBQUMsT0FBTyxDQUFDLEVBQUUsQ0FBQyxVQUFVLENBQUMsT0FBTyxFQUFFLEVBQUUsQ0FBQyxDQUFDLENBQUM7QUFBeEUsUUFBQSxLQUFLLFNBQW1FIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGNvbnN0IFNsZWVwID0gKG1zOiBudW1iZXIpID0+IG5ldyBQcm9taXNlKHJlc29sdmUgPT4gc2V0VGltZW91dChyZXNvbHZlLCBtcykpOyJdfQ==
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Sleep.js","sourceRoot":"","sources":["../../../src/apiServer/helper/Sleep.ts"],"names":[],"mappings":";;;AAAO,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAAxE,QAAA,KAAK,SAAmE","sourcesContent":["export const Sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));"]}
|
@@ -71,3 +71,4 @@ class UID {
|
|
71
71
|
}
|
72
72
|
}
|
73
73
|
exports.UID = UID;
|
74
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiVUlELmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2FwaVNlcnZlci9oZWxwZXIvVUlELnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQUFBLG9EQUEyQjtBQUMzQixNQUFhLEdBQUc7SUFDSixNQUFNLENBQVUsS0FBSyxHQUFHLGFBQWEsQ0FBQztJQUN0QyxNQUFNLENBQUMsWUFBWSxHQUFDLENBQUMsQ0FBQztJQUN0QixNQUFNLENBQUMsZUFBZSxHQUFDLENBQUMsQ0FBQztJQUNqQyxNQUFNLENBQUMsUUFBUTtRQUNYLElBQUksR0FBRyxHQUFHLE1BQU0sQ0FBQyxJQUFJLENBQ3BCLFFBQVEsQ0FDTCxDQUFDLENBQUMsQ0FBQyxJQUFJLElBQUksRUFBRSxDQUFDLEdBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQztjQUN6QixFQUFFO2NBQ0YsSUFBSSxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsTUFBTSxFQUFFLEdBQUMsSUFBSSxDQUFDLENBQ2xDLENBQUMsUUFBUSxDQUFDLEVBQUUsQ0FBQyxFQUFDLEtBQUssQ0FBQyxDQUFDLFFBQVEsQ0FBQyxRQUFRLENBQUMsQ0FBQztRQUV6QyxHQUFHLEdBQUMsR0FBRyxDQUFDLFVBQVUsQ0FBQyxHQUFHLEVBQUMsRUFBRSxDQUFDLENBQUE7UUFDMUIsR0FBRyxHQUFDLEdBQUcsQ0FBQyxVQUFVLENBQUMsR0FBRyxFQUFDLEdBQUcsQ0FBQyxDQUFBO1FBQzNCLEdBQUc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CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QACxD,MAAM,OAAO,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,GAAC,EAAE,CAAC;QAEzF,MAAM,GAAG,GAAC,IAAI;cACT,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAC,CAAC,CAAC;cAChC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;cAC7B,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAC,GAAG,CAAC;cACvB,IAAI,CAAC,UAAU,EAAE,CAAA;QAEtB,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;IAEzB,CAAC;IAGD,MAAM,CAAC,MAAM,CAAC,GAAU;QACpB,IAAI,GAAG,GAAG,gBAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnE,GAAG,GAAC,GAAG,CAAC,UAAU,CAAC,GAAG,EAAC,EAAE,CAAC,CAAA;QAC1B,GAAG,GAAC,GAAG,CAAC,UAAU,CAAC,GAAG,EAAC,GAAG,CAAC,CAAA;QAC3B,GAAG,GAAC,GAAG,CAAC,UAAU,CAAC,GAAG,EAAC,GAAG,CAAC,CAAA;QAC3B,OAAO,GAAG,CAAC;IACf,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,CAAQ;QACpB,OAAO,CAAC,CAAC,GAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAC,GAAG,CAAC,CAAA;IACjC,CAAC;;AApFL,kBAqFC","sourcesContent":["import crypto from \"crypto\"\nexport class UID{\n private static readonly epoch = 1697037922668;\n private static nextUniqueID=1;\n private static nextUniqueTRXID=1;\n static generate():string{\n let uid = Buffer.from(\n parseInt(\n ((+new Date())-this.epoch)\n +\"\"\n +Math.round(Math.random()*1000)\n ).toString(16),'hex').toString('base64');\n\n uid=uid.replaceAll(\"=\",\"\")\n uid=uid.replaceAll(\"+\",\".\")\n uid=uid.replaceAll(\"/\",\"_\")\n \n return uid;\n }\n\n static generateRandomNumberBase(count:number):string{\n let base=\"\";\n for(let i=0;i<count;i++)\n base+=Math.round(Math.random()*9);\n return base;\n }\n\n static generateNumberic(year?:string):number{\n if(!year)\n year = new Date().getFullYear()+\"\";\n const nextID=UID.nextUniqueID++;\n if(UID.nextUniqueID>99)\n UID.nextUniqueID = 1\n return parseInt(year.substring(2)+\"\"+(+new Date() - this.epoch)+\"\"+(nextID+\"\").padStart(2,\"0\"));\n }\n\n static getNextDescendingIndex():number{\n return Number.MAX_SAFE_INTEGER - (+new Date());\n }\n\n static getNext():string{\n const nextID=UID.nextUniqueID++;\n if(UID.nextUniqueID>99)\n UID.nextUniqueID = 1\n return this.leadZero(nextID)\n }\n \n static getNextTRX():string{\n const nextID=UID.nextUniqueTRXID++;\n if(UID.nextUniqueTRXID>99)\n UID.nextUniqueTRXID = 1\n return this.leadZero(nextID)\n }\n\n \n\n static generateTrxUID(date?:Date){\n \n if(!date)\n date=new Date();\n\n const year = (new Date().getFullYear()+\"\").substring(2);\n const seconds = (date.getHours() * 3600 + date.getMinutes() * 60 + date.getSeconds())+\"\";\n\n const str=year\n +this.leadZero(date.getMonth()+1)\n +this.leadZero(date.getDate())\n +seconds.padStart(5,\"0\")\n +this.getNextTRX()\n\n return parseInt(str);\n \n }\n\n\n static sha256(str:string):string{\n let uid = crypto.createHash(\"sha256\").update(str).digest(\"base64\");\n uid=uid.replaceAll(\"=\",\"\")\n uid=uid.replaceAll(\"+\",\".\")\n uid=uid.replaceAll(\"/\",\"-\")\n return uid;\n }\n\n static leadZero(i:number):string{\n return (i+\"\").padStart(2,\"0\")\n }\n}"]}
|
@@ -99,3 +99,4 @@ class Validator {
|
|
99
99
|
}
|
100
100
|
}
|
101
101
|
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OmFueSk6Ym9vbGVhbntcbiAgICAgICAgaWYoIW9iamVjdCB8fCB0eXBlb2Ygb2JqZWN0IT09XCJvYmplY3RcIilcbiAgICAgICAgICAgIHJldHVybiBmYWxzZVxuICAgICAgICBmb3IobGV0IGkgb2YgZmllbGRzKXtcbiAgICAgICAgICAgIGlmKCEoaSBpbiBvYmplY3QpIHx8IG9iamVjdFtpXT09PXVuZGVmaW5lZClcbiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgfVxuXG4gICAgc3RhdGljIGNvbnZlcnRUb1R5cGU8VD4odmFsdWU6YW55LHR5cGU6XCJzdHJpbmdcInxcIm51bWJlclwifFwiYm9vbGVhblwifFwiZGF0ZVwiKTpUfG51bGx7XG4gICAgICAgIGlmKHZhbHVlPT09bnVsbCB8fCB2YWx1ZSA9PT0gdW5kZWZpbmVkKVxuICAgICAgICAgICAgcmV0dXJuIG51bGw7XG5cbiAgICAgICAgaWYodHlwZT09PVwic3RyaW5nXCIpe1xuICAgICAgICAgICAgaWYodHlwZW9mIHZhbHVlID09PVwib2JqZWN0XCIpe1xuICAgICAgICAgICAgICAgIGxldCByZXN1bHQgPSBudWxsXG4gICAgICAgICAgICAgICAgdHJ5eyByZXN1bHQgPSBKU09OLnN0cmluZ2lmeSh2YWx1ZSk7fWNhdGNoKGUpe31cbiAgICAgICAgICAgICAgICBpZihyZXN1bHQhPT1udWxsKVxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVzdWx0IGFzIFRcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiB2YWx1ZStcIlwiIGFzIFRcbiAgICAgICAgfVxuXG4gICAgICAgIGlmKHR5cGU9PT1cImJvb2xlYW5cIil7XG4gICAgICAgICAgICBpZih0eXBlb2YgdmFsdWU9PT1cImJvb2xlYW5cIilcbiAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWUgYXMgVFxuICAgICAgICAgICAgaWYodHlwZW9mIHZhbHVlPT09XCJudW1iZXJcIilcbiAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWU+MCBhcyBUXG4gICAgICAgICAgICBpZih0eXBlb2YgdmFsdWU9PT1cIm9iamVjdFwiKVxuICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZSBhcyBUXG4gICAgICAgICAgICBpZih0eXBlb2YgdmFsdWUgPT09IFwic3RyaW5nXCIpXG4gICAgICAgICAgICAgICAgcmV0dXJuICh2YWx1ZS50b0xvd2VyQ2FzZSgpPT09XCJ0cnVlXCIpIGFzIFRcbiAgICAgICAgfVxuXG4gICAgICAgIGlmKHR5cGU9PT1cImRhdGVcIil7XG4gICAgICAgICAgICBpZih0eXBlb2YgdmFsdWU9PT1cInN0cmluZ1wiIHx8IHR5cGVvZiB2YWx1ZT09PVwibnVtYmVyXCIpXG4gICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBEYXRlKHZhbHVlKSBhcyBUXG4gICAgICAgICAgICByZXR1cm4gbnVsbDtcbiAgICAgICAgfVxuXG4gICAgICAgIC8vIG51bWJlclxuICAgICAgICBpZih0eXBlb2YgdmFsdWU9PT1cIm51bWJlclwiKVxuICAgICAgICAgICAgcmV0dXJuIHZhbHVlIGFzIFRcblxuICAgICAgICBpZih0eXBlb2YgdmFsdWU9PT1cIm9iamVjdFwiKVxuICAgICAgICAgICAgcmV0dXJuIDAgYXMgVFxuXG4gICAgICAgIGNvbnN0IG51bSA9IHBhcnNlSW50KHZhbHVlK1wiXCIpO1xuICAgICAgICByZXR1cm4gbnVtIGFzIFRcbiAgICB9XG5cbiAgICBzdGF0aWMgdmFsaWRhdGVWYWx1ZSh2YWx1ZTpzdHJpbmd8bnVtYmVyfGJvb2xlYW4sb3B0PzpJVmFsaWRhdG9yT3B0aW9ucyk6VmFsaWRhdGlvblJlcG9ydHtcbiAgICAgICAgaWYodmFsdWU9PT11bmRlZmluZWQgfHwgdmFsdWUgPT09IG51bGwpXG4gICAgICAgICAgICByZXR1cm4gVmFsaWRhdGlvblJlcG9ydC5WQUxVRV9JU19OVUxMO1xuICAgICAgICBpZighb3B0KVxuICAgICAgICAgICAgcmV0dXJuIFZhbGlkYXRpb25SZXBvcnQuT0s7XG4gICAgICAgIFxuXG4gICAgICAgIGlmKCFvcHQudHlwZSlcbiAgICAgICAgICAgIG9wdC50eXBlPVwic3RyaW5nXCI7XG5cbiAgICAgICAgaWYob3B0LnR5cGU9PT1cImJvb2xlYW5cIil7XG4gICAgICAgICAgICBpZih0eXBlb2YgdmFsdWU9PT1cImJvb2xlYW5cIilcbiAgICAgICAgICAgICAgICByZXR1cm4gVmFsaWRhdGlvblJlcG9ydC5PSztcbiAgICAgICAgICAgIGlmKHR5cGVvZiB2YWx1ZSA9PT1cIm51bWJlclwiICYmICh2YWx1ZSA9PT0gMSB8fCB2YWx1ZSA9PT0gMCkpXG4gICAgICAgICAgICAgICAgcmV0dXJuIFZhbGlkYXRpb25SZXBvcnQuT0tcbiAgICAgICAgICAgIHJldHVybiBWYWxpZGF0aW9uUmVwb3J0LlRZUEVfTUlTU01BVENIXG4gICAgICAgIH1cblxuICAgICAgICBpZihvcHQudHlwZSA9PT0gXCJudW1iZXJcIil7XG4gICAgICAgICAgICBpZih0eXBlb2YgdmFsdWUgIT09IFwibnVtYmVyXCIpXG4gICAgICAgICAgICAgICAgcmV0dXJuIFZhbGlkYXRpb25SZXBvcnQuVFlQRV9NSVNTTUFUQ0hcbiAgICAgICAgICAgIGlmKG9wdC5tYXggJiYgdmFsdWU+b3B0Lm1heClcbiAgICAgICAgICAgICAgICByZXR1cm4gVmFsaWRhdGlvblJlcG9ydC5WQUxVRV9UT09fQklHXG4gICAgICAgICAgICBpZihvcHQubWluICYmIHZhbHVlPG9wdC5taW4pXG4gICAgICAgICAgICAgICAgcmV0dXJuIFZhbGlkYXRpb25SZXBvcnQuVkFMVUVfVE9PX0JJR1xuICAgICAgICAgICAgcmV0dXJuIFZhbGlkYXRpb25SZXBvcnQuT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BACb,OAAO,gBAAgB,CAAC,eAAe,CAAA;SAC9C;QAID,OAAO,gBAAgB,CAAC,EAAE,CAAC;IAC/B,CAAC;CACJ;AA1GD,8BA0GC","sourcesContent":["export type TValidatorType=\"string\"|\"number\"|\"boolean\"|\"date\"|\"array\"|\"object\"|\"email\"|\"phone\"\n\nexport interface IValidatorOptions{\n min?:number,\n max?:number,\n type?:TValidatorType,\n regex?:RegExp\n}\n\nexport interface IValidaotrType{\n name:string,\n type:TValidatorType\n optional?:boolean,\n arrayType?:IValidaotrType,\n}\n\nexport enum ValidationReport{\n OK=1,\n VALUE_IS_NULL=2,\n TYPE_MISSMATCH=3,\n VALUE_TOO_BIG=4,\n VALUE_TOO_SHORT=5,\n VALUE_INCORRECT=6\n}\n\nexport class Validator{\n\n static validateObject(fields:string[],object:any):boolean{\n if(!object || typeof object!==\"object\")\n return false\n for(let i of fields){\n if(!(i in object) || object[i]===undefined)\n return false;\n }\n return true;\n }\n\n static convertToType<T>(value:any,type:\"string\"|\"number\"|\"boolean\"|\"date\"):T|null{\n if(value===null || value === undefined)\n return null;\n\n if(type===\"string\"){\n if(typeof value ===\"object\"){\n let result = null\n try{ result = JSON.stringify(value);}catch(e){}\n if(result!==null)\n return result as T\n }\n return value+\"\" as T\n }\n\n if(type===\"boolean\"){\n if(typeof value===\"boolean\")\n return value as T\n if(typeof value===\"number\")\n return value>0 as T\n if(typeof value===\"object\")\n return false as T\n if(typeof value === \"string\")\n return (value.toLowerCase()===\"true\") as T\n }\n\n if(type===\"date\"){\n if(typeof value===\"string\" || typeof value===\"number\")\n return new Date(value) as T\n return null;\n }\n\n // number\n if(typeof value===\"number\")\n return value as T\n\n if(typeof value===\"object\")\n return 0 as T\n\n const num = parseInt(value+\"\");\n return num as T\n }\n\n static validateValue(value:string|number|boolean,opt?:IValidatorOptions):ValidationReport{\n if(value===undefined || value === null)\n return ValidationReport.VALUE_IS_NULL;\n if(!opt)\n return ValidationReport.OK;\n \n\n if(!opt.type)\n opt.type=\"string\";\n\n if(opt.type===\"boolean\"){\n if(typeof value===\"boolean\")\n return ValidationReport.OK;\n if(typeof value ===\"number\" && (value === 1 || value === 0))\n return ValidationReport.OK\n return ValidationReport.TYPE_MISSMATCH\n }\n\n if(opt.type === \"number\"){\n if(typeof value !== \"number\")\n return ValidationReport.TYPE_MISSMATCH\n if(opt.max && value>opt.max)\n return ValidationReport.VALUE_TOO_BIG\n if(opt.min && value<opt.min)\n return ValidationReport.VALUE_TOO_BIG\n return ValidationReport.OK;\n }\n\n if(typeof value !== \"string\")\n return ValidationReport.TYPE_MISSMATCH\n\n if(opt.max && value.length>opt.max)\n return ValidationReport.VALUE_TOO_BIG\n\n if(opt.min && value.length<opt.min)\n return ValidationReport.VALUE_TOO_SHORT\n\n if(opt.type===\"email\" && !opt.regex){\n opt.regex = /^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,6}$/g;\n }\n\n if(opt.regex){\n const globalRegex = new RegExp(opt.regex.source, opt.regex.flags.includes('g') ? opt.regex.flags : opt.regex.flags + 'g');\n const tmp = value.replaceAll(globalRegex,\"\");\n if(tmp.length!==0)\n return ValidationReport.VALUE_INCORRECT\n }\n\n \n \n return ValidationReport.OK;\n }\n}"]}
|
@@ -261,3 +261,4 @@ class Monitor extends BaseEndpoint_1.BaseEndpoint {
|
|
261
261
|
}
|
262
262
|
}
|
263
263
|
exports.Monitor = Monitor;
|
264
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTW9uaXRvci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9hcGlTZXJ2ZXIvbW9uaXRvci9Nb25pdG9yLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQUFBLG1EQUF3QztBQUN4Qyw4Q0FBNkM7QUFDN0Msa0RBQStDO0FBQy9DLDhDQUF3QztBQUV4QyxvREFBNEI7QUFDNUIsNENBQW1CO0F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RhdCgpO1xuICAgIH1cblxuICAgIHJlZ2lzdHJhdGVBY3Rpb24oZGF0YTpJVXNlckFjdGlvbil7XG4gICAgICAgIGlmKCFkYXRhLmFjdGlvbilcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgaWYodHlwZW9mIGRhdGEuYWN0aW9uIT09XCJzdHJpbmdcIilcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgaWYoZGF0YS5hY3Rpb24ubGVuZ3RoPjIwKVxuICAgICAgICAgICAgZGF0YS5hY3Rpb249ZGF0YS5hY3Rpb24uc3Vic3RyaW5nKDAsMjApO1xuXG4gICAgICAgIGNvbnN0IGQ9bmV3IERhdGUoKTtcbiAgICAgICAgY29uc3QgZG95PXRoaXMuZ2V0RGF0ZUluZGV4KGQpO1xuICAgICAgICBsZXQgZGF5PXRoaXMudXNlckFjdGlvbnMuZ2V0KGRveSk7XG4gICAgICAgIFxuICAgICAgICBpZighZGF5KXtcbiAgICAgICAgICAgIGRheT1uZXcgTWFwKCk7IC8vIHN0cmluZyxudW1iZXJcbiAgICAgICAgICAgIHRoaXMudXNlckFjdGlvbnMuc2V0KGRveSxkYXkpO1xuICAgICAgICAgICAgaWYodGhpcy51c2VyQWN0aW9ucy5zaXplPjcpe1xuICAgICAgICAgICAgICAgIGZvcihsZXQgaSBvZiB0aGlzLnVzZXJBY3Rpb25zKXtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy51c2VyQWN0aW9ucy5kZWxldGUoaVswXSlcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgY29uc3QgbWludXRlPXRoaXMuZ2V0SG91ck1pbnV0ZUluZGV4KGQpO1xuICAgICAgICBsZXQgbSA9IGRheS5nZXQobWludXRlKTtcbiAgICAgICAgaWYoIW0pe1xuICAgICAgICAgICAgbT1uZXcgTWFwKCk7XG4gICAgICAgICAgICBkYXkuc2V0K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gICAgIGNvbnN0IGhvdXJNaW51dGUgPSB0aGlzLmdldEhvdXJNaW51dGVJbmRleChkKTtcbiAgICAgICAgbGV0IGhtID0gZGF5LmdldChob3VyTWludXRlKTtcbiAgICAgICAgaWYoIWhtKXtcbiAgICAgICAgICAgIGhtID0ge1xuICAgICAgICAgICAgICAgIGVycm9yczpuZXcgTWFwKCksXG4gICAgICAgICAgICAgICAgcmVxdWVzdHM6bmV3IE1hcCgpLFxuICAgICAgICAgICAgICAgIGZhdGFsRXJyb3JzOm5ldyBNYXAoKSxcbiAgICAgICAgICAgICAgICBhcGlFcnJvcnM6bmV3IE1hcCgpXG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBkYXkuc2V0KGhvdXJNaW51dGUsaG0pXG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGhtO1xuICAgIH1cblxuICAgIGNyZWF0ZVN5c3RlbVN0YXRPYmooKTpJU3lzdGVtU3RhdHtcbiAgICAgICAgY29uc3QgZD1uZXcgRGF0ZSgpO1xuICAgICAgICBjb25zdCBkdG0gPSB0aGlzLmdldERhdGVJbmRleChkKTtcbiAgICAgICAgbGV0IGRheT10aGlzLnN5c3RlbVN0YXQuZ2V0KGR0bSk7XG4gICAgICAgIGlmKCFkYXkpe1xuICAgICAgICAgICAgZGF5ID0gbmV3IE1hcCgpO1xuICAgICAgICAgICAgdGhpcy5zeXN0ZW1TdGF0LnNldChkdG0sZGF5KTtcbiAgICAgICAgICAgIGlmKHRoaXMuc3lzdGVtU3RhdC5zaXplPjcpe1xuICAgICAgICAgICAgICAgIGZvcihsZXQgaSBvZiB0aGlzLnN5c3RlbVN0YXQpe1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnN5c3RlbVN0YXQuZGVsZXRlKGlbMF0pXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBjb25zdCBob3VyTWludXRlID0gdGhpcy5nZXRIb3VyTWludXRlSW5kZXgoZCk7XG4gICAgICAgIGxldCBobSA9IGRheS5nZXQoaG91ck1pbnV0ZSk7XG4gICAgICAgIGlmKCFobSl7XG4gICAgICAgICAgICBobSA9IHtcbiAgICAgICAgICAgICAgICBjcHVVc2FnZTowLFxuICAgICAgICAgICAgICAgIG1lbW9yeVRvdGFsOjAsXG4gICAgICAgICAgICAgICAgbWVtb3J5VXNhZ2U6e31cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGRheS5zZXQoaG91ck1pbnV0ZSxobSlcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gaG07XG4gICAgfVxuXG4gICAgZ2V0RGF0ZUluZGV4KGQ6RGF0ZSk6bnVtYmVye1xuICAgICAgICBjb25zdCBkdG0gPSBkO1xuICAgICAgICByZXR1cm4gcGFyc2VJbnQoZHRtLmdldEZ1bGxZZWFyKCkudG9TdHJpbmcoKS5zdWJzdHJpbmcoMikrdGhpcy5sZWFkWmVybyhkdG0uZ2V0TW9udGgoKSsxKSt0aGlzLmxlYWRaZXJvKGR0bS5nZXREYXRlKCkpKVxuICAgIH1cblxuICAgIGdldEhvdXJNaW51dGVJbmRleChkOkRhdGUpOnN0cmluZ3tcbiAgICAgICAgY29uc3QgZHRtID0gZDtcbiAgICAgICAgcmV0dXJuIHRoaXMubGVhZFplcm8oZHRtLmdldEhvdXJzKCkpK3RoaXMubGVhZFplcm8oZHRtLmdldE1pbnV0ZXMoKSlcbiAgICB9XG5cbiAgICBsZWFkWmVybyhpOm51bWJlcik6c3RyaW5ne1xuICAgICAgICBpZihpPjkpXG4gICAgICAgICAgICByZXR1cm4gaStcIlwiXG4gICAgICAgIHJldHVybiBcIjBcIitpO1xuICAgIH1cblxuICAgIC8vIFBSRUNIRUNLIEJFRk9SRSBBTlkgRVhFQ1VUSU9OXG4gICAgYXN5bmMgcHJlY2hlY2socmVxOiBIVFRQUmVxdWVzdFZPKTogUHJvbWlzZTxUcmFuc2ZlclBhY2tldFZPPGFueT4gfCBudWxsPiB7XG4gICAgICAgIFxuICAgICAgICBpZighcmVxLmhlYWRlcnMpXG4gICAgICAgICAgICByZXR1cm4ge2Vycm9yOntjb2RlOjEwMDAxLG1lc3NhZ2U6XCJObyBhdXRob3JpemF0aW9uXCIsaHR0cFN0YXR1czo0MDB9fVxuICAgICAgICBcbiAgICAgICAgaWYoIXJlcS5oZWFkZXJzWydhdXRob3JpemF0aW9uJ10pXG4gICAgICAgICAgICByZXR1cm4ge2Vycm9yOntjb2RlOjEwMDAyLG1lc3NhZ2U6XCJObyBhdXRob3JpemF0aW9uIGZvdW5kXCIsaHR0cFN0YXR1czo0MDB9fVxuXG4gICAgICAgIGNvbnN0IGF1dGggPSByZXEuaGVhZGVyc1snYXV0aG9yaXphdGlvbiddO1xuICAgICAgICBcbiAgICAgICAgaWYoIXJlcS5wcmVjaGVjayB8fCAhQXJyYXkuaXNBcnJheShyZXEucHJlY2hlY2suZGF0YSkpe1xuICAgICAgICAgICAgcmV0dXJuIHtlcnJvcjp7Y29kZToxMDAwMyxtZXNzYWdlOlwiTm8gYXV0aG9yaXphdGlvbiByZWNvcmRzIGZvdW5kXCIsaHR0cFN0YXR1czo0MDB9fVxuICAgICAgICB9XG4gICAgICAgIFxuXG4gICAgICAgIGxldCBhdXRob3JpemVkPWZhbHNlO1xuICAgICAgICBmb3IobGV0IGkgb2YgcmVxLnByZWNoZWNrLmRhdGEpe1xuICAgICAgICAgICAgbGV0IGV4cGVjdGF0aW9uU3RyID0gXCJcIlxuICAgICAgICAgICAgZXhwZWN0YXRpb25TdHIrPXJlcS5lbmRwb2ludFxuICAgICAgICAgICAgZXhwZWN0YXRpb25TdHIrPUpTT04uc3RyaW5naWZ5KGkpXG4gICAgICAgICAgICBleHBlY3RhdGlvblN0cis9SlNPTi5zdHJpbmdpZnkocmVxLm1ldGhvZClcbiAgICAgICAgICAgIGV4cGVjdGF0aW9uU3RyKz1KU09OLnN0cmluZ2lmeShyZXEuZGF0YSlcbiAgICAgIC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gICAgYXN5bmMgbWV0cmljcyhyZXE6SFRUUFJlcXVlc3RWTyk6UHJvbWlzZTxUcmFuc2ZlclBhY2tldFZPPGFueT4+e1xuICAgICAgICBcbiAgICAgICAgLy8gZ2V0IG1ldHJpYyBmb3IgY3VycmVudCBkYXRlXG4gICAgICAgIGNvbnN0IGRhdGUgPSBuZXcgRGF0ZSgpO1xuICAgICAgICBjb25zdCBkaSA9IHRoaXMuZ2V0RGF0ZUluZGV4KGRhdGUpO1xuICAgICAgICBjb25zdCBzdGF0ID0gdGhpcy5odHRwUmVxdWVzdHMuZ2V0KGRpKVxuICAgICAgICBcblxuICAgICAgICAvLyBwcmVwYXJlIHRvIHBsYWluIGFycmF5IChtYXAgd2l0aCBtaW51dGVzKVxuICAgICAgICBcbiAgICAgICAgbGV0IHJlc3VsdD1bXVxuICAgICAgICBpZihzdGF0KXtcbiAgICAgICAgICAgIGZvcihsZXQgbWludXRlcyBvZiBzdGF0KXtcbiAgICAgICAgICAgICAgICByZXN1bHQucHVzaCh7XG4gICAgICAgICAgICAgICAgICAgIG06bWludXRlc1swXSxcbiAgICAgICAgICAgICAgICAgICAgYWU6dGhpcy5tYXBUb0tleVZhbHVlKG1pbnV0ZXNbMV0uYXBpRXJyb3JzKSxcbiAgICAgICAgICAgICAgICAgICAgZTp0aGlzLm1hcFRvS2V5VmFsdWUobWludXRlc1sxXS5lcnJvcnMpLFxuICAgICAgICAgICAgICAgICAgICByOnRoaXMubWFwVG9LZXlWYWx1ZShtaW51dGVzWzFdLnJlcXVlc3RzKSxcbiAgICAgICAgICAgICAgICAgICAgZmU6dGhpcy5tYXBUb0tleVZhbHVlKG1pbnV0ZXNbMV0uZmF0YWxFcnJvcnMpLFxuICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgXG4gICAgICAgIGNvbnN0IHVhID0gdGhpcy51c2VyQWN0aW9ucy5nZXQoZGkpO1xuICAgICAgICBsZXQgdWFSZXN1bHQ6YW55W109W11cbiAgICAgICAgaWYodWEpe1xuICAgICAgICAgICAgZm9yKGxldCBpIG9mIHVhKXtcbiAgICAgICAgICAgICAgICBjb25zdCBtaW51dGVzID0gaVsxXTtcbiAgICAgICAgICAgICAgICBjb25zdCBtQXJyYXk6YW55W109W11cbiAgICAgICAgICAgICAgICBmb3IobGV0IGogb2YgaVswXSl7XG4gICAgICAgICAgICAgICAgICAgIG1BcnJheS5wdXNoKHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGFjdGlvbjpqWzBdLFxuICAgICAgICAgICAgICAgICAgICAgICAgY291bnQ6alsxXVxuICAgICAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXN1bHQucHVzaCh7XG4gICAgICAgICAgICAgICAgICAgIG06aVswXSxcbiAgICAgICAgICAgICAgICAgICAgZGF0YTptQXJyYXlcbiAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIHtkYXRhOntzdGF0OnJlc3VsdCxkYXRlOitkYXRlLHVzZXJBY3Rpb25zOnVhUmVzdWx0fX07XG4gICAgfVxuXG4gICAgYXN5bmMgc2VydmVyU3RhdChyZXE6SFRUUFJlcXVlc3RWTyk6UHJvbWlzZTxUcmFuc2ZlclBhY2tldFZPPGFueT4+e1xuXG4gICAgICAgIC8vIGdldCBtZXRyaWMgZm9yIGN1cnJlbnQgZGF0ZVxuICAgICAgICBjb25zdCBkYXRlID0gbmV3IERhdGUoKTtcbiAgICAgICAgY29uc3QgZGkgPSB0aGlzLmdldERhdGVJbmRleChkYXRlKTtcbiAgICAgICAgY29uc3Qgc3RhdCA9IHRoaXMuc3lzdGVtU3RhdC5nZXQoZGkpXG4gICAgICAgIGlmKCFzdGF0KVxuICAgICAgICAgICAgcmV0dXJuIHtkYXRhOltdfVxuXG4gICAgICAgIC8vIHByZXBhcmUgdG8gcGxhaW4gYXJyYXkgKG1hcCB3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B;QACvC,MAAM,GAAG,GAAC,EAAE,CAAA;QACZ,KAAI,IAAI,CAAC,IAAI,GAAG;YACZ,GAAG,CAAC,IAAI,CAAC,EAAC,IAAI,EAAC,CAAC,CAAC,CAAC,CAAC,EAAC,KAAK,EAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAA;QACpC,OAAO,GAAG,CAAC;IACf,CAAC;CACJ;AAjTD,0BAiTC","sourcesContent":["import { Signal } from \"badmfck-signal\";\nimport { REQ_HTTP_LOG } from \"../APIService\";\nimport { BaseEndpoint } from \"../BaseEndpoint\";\nimport { REQ_LOG } from \"../LogService\";\nimport { HTTPRequestVO, TransferPacketVO } from \"../structures/Interfaces\";\nimport crypto from \"crypto\";\nimport os from \"os\"\n\n\nexport interface IUserAction{\n action:string;\n}\n\ninterface IStatObject{\n requests:Map<string,number>, //ep, count\n errors:Map<string,number>, // ep, count\n fatalErrors:Map<string,number>, // ep, count\n apiErrors:Map<string,number> // ep,count\n}\n\ninterface ISystemStat{\n cpuUsage:any,\n memoryTotal:number,\n memoryUsage:any,\n}\n\nexport const S_MONITOR_REGISTRATE_ACTION=new Signal<IUserAction>()\n\nexport class Monitor extends BaseEndpoint{\n\n ignoreHttpLogging=true\n \n private httpRequests=new Map<number,Map<string,IStatObject>>(); // day of year,hour,minute, count\n private systemStat=new Map<number,Map<string,ISystemStat>>(); // day of year,hour,minute, count\n private userActions=new Map<number,Map<string,Map<string,number>>>(); // day of year, hour+minute, action , count\n private registeredActions=0;\n \n constructor(){\n super(\"sys-monitor\");\n\n S_MONITOR_REGISTRATE_ACTION.subscribe(data=>this.registrateAction(data))\n\n this.registerEndpoints([\n {ignoreInterceptor:true,endpoint:\"log\",handler:this.logs},\n {ignoreInterceptor:true,endpoint:\"netlog\",handler:this.netlog},\n {ignoreInterceptor:true,endpoint:\"metrics\",handler:this.metrics},\n {ignoreInterceptor:true,endpoint:\"server/stat\",handler:this.serverStat}\n ])\n\n setInterval(()=>{\n this.addSystemStat();\n },1000*60*10);\n this.addSystemStat();\n }\n\n registrateAction(data:IUserAction){\n if(!data.action)\n return;\n if(typeof data.action!==\"string\")\n return;\n if(data.action.length>20)\n data.action=data.action.substring(0,20);\n\n const d=new Date();\n const doy=this.getDateIndex(d);\n let day=this.userActions.get(doy);\n \n if(!day){\n day=new Map(); // string,number\n this.userActions.set(doy,day);\n if(this.userActions.size>7){\n for(let i of this.userActions){\n this.userActions.delete(i[0])\n break;\n }\n }\n }\n\n const minute=this.getHourMinuteIndex(d);\n let m = day.get(minute);\n if(!m){\n m=new Map();\n day.set(minute,m);\n }\n\n\n let cnt = m.get(data.action);\n if(!cnt)\n cnt=0;\n cnt++;\n m.set(data.action,cnt);\n\n }\n\n addSystemStat(){\n const so = this.createSystemStatObj();\n so.memoryUsage=process.memoryUsage()\n so.memoryTotal=os.totalmem()\n }\n \n\n // METRIC!\n registrateError(endpoint:string){\n const so = this.createStatObj();\n this.increaseStat(so.errors,endpoint)\n }\n\n registrateFatalError(endpoint:string){\n const so = this.createStatObj();\n this.increaseStat(so.fatalErrors,endpoint)\n }\n\n registrateAPIError(endpoint:string){\n const so = this.createStatObj();\n this.increaseStat(so.apiErrors,endpoint)\n }\n\n registrateResponse(endpoint:string,responseTime:number){\n const so = this.createStatObj();\n this.increaseStat(so.requests,endpoint)\n }\n\n increaseStat(statObject:Map<string,number>,endpoint:string):void{\n let reqep = statObject.get(endpoint);\n if(!reqep)\n reqep=0 \n reqep+=1;\n statObject.set(endpoint,reqep)\n this.registeredActions++\n }\n\n createStatObj():IStatObject{\n const d=new Date();\n const dtm = this.getDateIndex(d);\n let day=this.httpRequests.get(dtm);\n if(!day){\n day = new Map();\n this.httpRequests.set(dtm,day);\n if(this.httpRequests.size>7){\n for(let i of this.httpRequests){\n this.httpRequests.delete(i[0])\n break;\n }\n }\n }\n const hourMinute = this.getHourMinuteIndex(d);\n let hm = day.get(hourMinute);\n if(!hm){\n hm = {\n errors:new Map(),\n requests:new Map(),\n fatalErrors:new Map(),\n apiErrors:new Map()\n }\n day.set(hourMinute,hm)\n }\n return hm;\n }\n\n createSystemStatObj():ISystemStat{\n const d=new Date();\n const dtm = this.getDateIndex(d);\n let day=this.systemStat.get(dtm);\n if(!day){\n day = new Map();\n this.systemStat.set(dtm,day);\n if(this.systemStat.size>7){\n for(let i of this.systemStat){\n this.systemStat.delete(i[0])\n break;\n }\n }\n }\n const hourMinute = this.getHourMinuteIndex(d);\n let hm = day.get(hourMinute);\n if(!hm){\n hm = {\n cpuUsage:0,\n memoryTotal:0,\n memoryUsage:{}\n }\n day.set(hourMinute,hm)\n }\n return hm;\n }\n\n getDateIndex(d:Date):number{\n const dtm = d;\n return parseInt(dtm.getFullYear().toString().substring(2)+this.leadZero(dtm.getMonth()+1)+this.leadZero(dtm.getDate()))\n }\n\n getHourMinuteIndex(d:Date):string{\n const dtm = d;\n return this.leadZero(dtm.getHours())+this.leadZero(dtm.getMinutes())\n }\n\n leadZero(i:number):string{\n if(i>9)\n return i+\"\"\n return \"0\"+i;\n }\n\n // PRECHECK BEFORE ANY EXECUTION\n async precheck(req: HTTPRequestVO): Promise<TransferPacketVO<any> | null> {\n \n if(!req.headers)\n return {error:{code:10001,message:\"No authorization\",httpStatus:400}}\n \n if(!req.headers['authorization'])\n return {error:{code:10002,message:\"No authorization found\",httpStatus:400}}\n\n const auth = req.headers['authorization'];\n \n if(!req.precheck || !Array.isArray(req.precheck.data)){\n return {error:{code:10003,message:\"No authorization records found\",httpStatus:400}}\n }\n \n\n let authorized=false;\n for(let i of req.precheck.data){\n let expectationStr = \"\"\n expectationStr+=req.endpoint\n expectationStr+=JSON.stringify(i)\n expectationStr+=JSON.stringify(req.method)\n expectationStr+=JSON.stringify(req.data)\n expectationStr+=JSON.stringify(req.params)\n \n const expectation = \"sha256 \"+crypto.createHash(\"sha256\").update(expectationStr).digest().toString(\"hex\");\n \n if(auth === expectation){\n authorized=true;\n break\n }\n }\n\n if(!authorized){\n console.error(\"Wrong token: \"+auth)\n return {error:{code:10004,message:\"Unauthorized access\",httpStatus:401}}\n }\n\n return null;\n }\n\n async logs(req:HTTPRequestVO):Promise<TransferPacketVO<any>>{\n const log = await REQ_LOG.request(null)\n return {data:log}\n }\n\n async netlog(req:HTTPRequestVO):Promise<TransferPacketVO<any>>{\n const log = await REQ_HTTP_LOG.request()\n return {data:log}\n }\n\n async metrics(req:HTTPRequestVO):Promise<TransferPacketVO<any>>{\n \n // get metric for current date\n const date = new Date();\n const di = this.getDateIndex(date);\n const stat = this.httpRequests.get(di)\n \n\n // prepare to plain array (map with minutes)\n \n let result=[]\n if(stat){\n for(let minutes of stat){\n result.push({\n m:minutes[0],\n ae:this.mapToKeyValue(minutes[1].apiErrors),\n e:this.mapToKeyValue(minutes[1].errors),\n r:this.mapToKeyValue(minutes[1].requests),\n fe:this.mapToKeyValue(minutes[1].fatalErrors),\n })\n }\n }\n \n const ua = this.userActions.get(di);\n let uaResult:any[]=[]\n if(ua){\n for(let i of ua){\n const minutes = i[1];\n const mArray:any[]=[]\n for(let j of i[0]){\n mArray.push({\n action:j[0],\n count:j[1]\n })\n }\n result.push({\n m:i[0],\n data:mArray\n })\n }\n }\n\n return {data:{stat:result,date:+date,userActions:uaResult}};\n }\n\n async serverStat(req:HTTPRequestVO):Promise<TransferPacketVO<any>>{\n\n // get metric for current date\n const date = new Date();\n const di = this.getDateIndex(date);\n const stat = this.systemStat.get(di)\n if(!stat)\n return {data:[]}\n\n // prepare to plain array (map with minutes)\n let result=[]\n for(let minutes of stat){\n result.push({\n m:minutes[0],\n mt:minutes[1].memoryTotal,\n mu:minutes[1].memoryUsage,\n cu:minutes[1].cpuUsage,\n })\n }\n\n\n return {data:{\n registeredActions:this.registeredActions,\n uptime:process.uptime(),\n osUptime:os.uptime(),\n stat:result\n }}\n }\n\n mapToKeyValue(map:Map<string,string|number>):{name:string,value:string|number}[]{\n const res=[]\n for(let i of map)\n res.push({name:i[0],value:i[1]})\n return res;\n }\n}\n\n/*function getCPUUsage(callback, free){ \n\t\n var stats1 = getCPUInfo();\n var startIdle = stats1.idle;\n var startTotal = stats1.total;\n\t\n setTimeout(function() {\n var stats2 = getCPUInfo();\n var endIdle = stats2.idle;\n var endTotal = stats2.total;\n\t\t\n var idle \t= endIdle - startIdle;\n var total \t= endTotal - startTotal;\n var perc\t= idle / total;\n\t \t\n if(free === true)\n callback( perc );\n else\n callback( (1 - perc) );\n\t \t\t\n }, 1000 );\n}\n\nfunction getCPUInfo(callback){ \n var cpus = _os.cpus();\n\t\n var user = 0;\n var nice = 0;\n var sys = 0;\n var idle = 0;\n var irq = 0;\n var total = 0;\n\t\n for(var cpu in cpus){\n if (!cpus.hasOwnProperty(cpu)) continue;\t\n user += cpus[cpu].times.user;\n nice += cpus[cpu].times.nice;\n sys += cpus[cpu].times.sys;\n irq += cpus[cpu].times.irq;\n idle += cpus[cpu].times.idle;\n }\n\t\n var total = user + nice + sys + idle + irq;\n\t\n return {\n 'idle': idle, \n 'total': total\n };\n}*/"]}
|
@@ -23,3 +23,4 @@ class Liveness extends BaseEndpoint_1.BaseEndpoint {
|
|
23
23
|
}
|
24
24
|
}
|
25
25
|
exports.Liveness = Liveness;
|
26
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTGl2ZW5lc3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvYXBpU2VydmVyL3JvdXRlcy9MaXZlbmVzcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSw4Q0FBd0Q7QUFDeEQsa0RBQStDO0FBRy9DLE1BQWEsUUFBUyxTQUFRLDJCQUFZO0lBQ3RDLE9BQU8sQ0FBTTtJQUNiLFlBQVksTUFBVztRQUNuQixLQUFLLENBQUMsVUFBVSxDQUFDLENBQUE7UUFDakIsSUFBSSxDQUFDLE9BQU8sR0FBQyxNQUFNLENBQUM7UUFDcEIsSUFBSSxDQUFDLGlCQUFpQixDQUFDLENBQUMsR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CAAA;QACV,OAAO,CAAC,CAAC;IACb,CAAC;CACJ;AApBD,4BAoBC","sourcesContent":["import { REQ_HTTP_REQUESTS_COUNT } from \"../APIService\";\nimport { BaseEndpoint } from \"../BaseEndpoint\";\nimport { HTTPRequestVO, TransferPacketVO } from \"../structures/Interfaces\";\n\nexport class Liveness extends BaseEndpoint{\n started:Date;\n constructor(stated:Date){\n super(\"liveness\")\n this.started=stated;\n this.registerEndpoints([{endpoint:\"\",handler:this.checkLiveness,ignoreInterceptor:true}])\n }\n\n async checkLiveness (req:HTTPRequestVO){\n // liveness probe - check if server is alive (wait for 10 sec and send response)\n const request = REQ_HTTP_REQUESTS_COUNT.request()\n const data = {data:{liveness:true,wakeTime:(+new Date()) - (+this.started),request:request}}\n let cb:((data:TransferPacketVO<any>)=>void) | null = null;\n const p = new Promise<TransferPacketVO<any>>((resolve,reject)=>{cb = resolve})\n setTimeout(()=>{\n if(cb)\n cb(data);\n },1000*10)\n return p;\n }\n}"]}
|
@@ -16,3 +16,4 @@ class Readiness extends BaseEndpoint_1.BaseEndpoint {
|
|
16
16
|
}
|
17
17
|
}
|
18
18
|
exports.Readiness = Readiness;
|
19
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUmVhZGluZXNzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2FwaVNlcnZlci9yb3V0ZXMvUmVhZGluZXNzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLDhDQUF3RDtBQUN4RCxrREFBOEM7QUFHOUMsTUFBYSxTQUFVLFNBQVEsMkJBQVk7SUFDdkMsT0FBTyxDQUFNO0lBQ2IsWUFBWSxNQUFXO1FBQ25CLEtBQUssQ0FBQyxXQUFXLENBQUMsQ0FBQTtRQUNsQixJQUFJLENBQUMsT0FBTyxHQUFDLE1BQU0sQ0FBQztRQUNwQixJQUFJLENBQUMsaUJBQWlCLENB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uY2hlY2tSZWFkaW5lc3MsaWdub3JlSW50ZXJjZXB0b3I6dHJ1ZX1dKVxuICAgIH1cblxuICAgIGFzeW5jIGNoZWNrUmVhZGluZXNzIChyZXE6SFRUUFJlcXVlc3RWTyl7XG4gICAgICAgIGNvbnN0IHJlcXVlc3QgPSBSRVFfSFRUUF9SRVFVRVNUU19DT1VOVC5yZXF1ZXN0KClcbiAgICAgICAgcmV0dXJuIHtkYXRhOntsaXZlbmVzczp0cnVlLHdha2VUaW1lOigrbmV3IERhdGUoKSkgLSAoK3RoaXMuc3RhcnRlZCkscmVxdWVzdDpyZXF1ZXN0fX1cbiAgICB9XG59Il19
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Readiness.js","sourceRoot":"","sources":["../../../src/apiServer/routes/Readiness.ts"],"names":[],"mappings":";;;AAAA,8CAAwD;AACxD,kDAA8C;AAG9C,MAAa,SAAU,SAAQ,2BAAY;IACvC,OAAO,CAAM;IACb,YAAY,MAAW;QACnB,KAAK,CAAC,WAAW,CAAC,CAAA;QAClB,IAAI,CAAC,OAAO,GAAC,MAAM,CAAC;QACpB,IAAI,CAAC,iBAAiB,CAAC,CAAC,EAAC,QAAQ,EAAC,EAAE,EAAC,OAAO,EAAC,IAAI,CAAC,cAAc,EAAC,iBAAiB,EAAC,IAAI,EAAC,CAAC,CAAC,CAAA;IAC9F,CAAC;IAED,KAAK,CAAC,cAAc,CAAE,GAAiB;QACnC,MAAM,OAAO,GAAG,oCAAuB,CAAC,OAAO,EAAE,CAAA;QACjD,OAAO,EAAC,IAAI,EAAC,EAAC,QAAQ,EAAC,IAAI,EAAC,QAAQ,EAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAC,OAAO,EAAC,OAAO,EAAC,EAAC,CAAA;IAC1F,CAAC;CACJ;AAZD,8BAYC","sourcesContent":["import { REQ_HTTP_REQUESTS_COUNT } from \"../APIService\";\nimport { BaseEndpoint } from \"../BaseEndpoint\"\nimport { HTTPRequestVO } from \"../structures/Interfaces\"\n\nexport class Readiness extends BaseEndpoint{\n started:Date;\n constructor(stated:Date){\n super(\"readiness\")\n this.started=stated;\n this.registerEndpoints([{endpoint:\"\",handler:this.checkReadiness,ignoreInterceptor:true}])\n }\n\n async checkReadiness (req:HTTPRequestVO){\n const request = REQ_HTTP_REQUESTS_COUNT.request()\n return {data:{liveness:true,wakeTime:(+new Date()) - (+this.started),request:request}}\n }\n}"]}
|
@@ -32,3 +32,4 @@ class ErrorUtils {
|
|
32
32
|
}
|
33
33
|
exports.ErrorUtils = ErrorUtils;
|
34
34
|
exports.default = DefaultErrors;
|
35
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRGVmYXVsdEVycm9ycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9hcGlTZXJ2ZXIvc3RydWN0dXJlcy9EZWZhdWx0RXJyb3JzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLG1EQUFpRTtBQUdqRSxNQUFNLGFBQWE7SUFDZixNQUFNLENBQUMsZUFBZSxHQUFRLEVBQUMsSUFBSSxFQUFDLENBQUMsRUFBQyxPQUFPLEVBQUMsaUJBQWlCLEVBQUMsQ0FBQTtJQUNoRSxNQUFNLENBQUMsZUFBZSxHQUFRLEVBQUMsSUFBSSxFQUFDLENBQUMsRUFBQyxPQUFPLEVBQUMsaUJBQWlCLEVBQUMsQ0FBQTtJQUNoRSxNQUFNLENBQUMsY0FBYyxHQUFRLEVBQUMsSUFBSSxFQUFDLENBQUMsRUFBQyxPQUFPLEVBQUMsZ0JBQWdCLEVBQUMsQ0FBQTtJQUM5RCxNQUFNLENBQUMsY0FBYyxHQUFRLEVBQUMsSUFBSSxFQUFDLENBQUMsRUFBQyxPQUFPLEVBQUMsbUJBQW1CLEVBQUMsQ0FBQTtJQUNq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,CAAC,mBAAmB,GAAQ,EAAC,IAAI,EAAC,CAAC,EAAC,OAAO,EAAC,qBAAqB,EAAC,CAAA;IACxE,MAAM,CAAC,OAAO,GAAQ,EAAC,IAAI,EAAC,CAAC,EAAC,OAAO,EAAC,SAAS,EAAC,CAAA;;AAGpD,MAAa,UAAU;IAEnB,MAAM,CAAC,OAAO,CAAC,GAAO;QAClB,MAAM,cAAc,GAAG,qBAAS,CAAC,cAAc,CAAC,CAAC,MAAM,EAAC,SAAS,CAAC,EAAC,GAAG,CAAC,CAAA;QAEvE,IAAG,CAAC,cAAc;YACd,OAAO,KAAK,CAAC;QAEjB,IAAG,qBAAS,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,EAAC,EAAC,IAAI,EAAC,QAAQ,EAAC,CAAC,KAAG,4BAAgB,CAAC,EAAE;YACtE,OAAO,KAAK,CAAC;QAEjB,IAAG,qBAAS,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,EAAC,EAAC,IAAI,EAAC,QAAQ,EAAC,CAAC,KAAG,4BAAgB,CAAC,EAAE;YACzE,OAAO,KAAK,CAAC;QAEjB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,KAAY,EAAC,KAAe;QAC3C,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;QACpB,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AArBD,gCAqBC;AAED,kBAAe,aAAa,CAAA","sourcesContent":["import { ValidationReport, Validator } from \"../helper/Validator\"\nimport { IError } from \"./Interfaces\"\n\nclass DefaultErrors{\n static NOT_IMPLEMENTED:IError={code:1,message:\"Not implemented\"}\n static UNKNOWN_REQUEST:IError={code:2,message:\"Unknown request\"}\n static JSON_MALFORMED:IError={code:3,message:\"JSON malformed\"}\n static FILE_TOO_LARGE:IError={code:4,message:\"File is too large\"}\n static CANT_SEND_FILE:IError={code:5,message:\"Can't send file\"}\n static FILE_NOT_EXISTS:IError={code:5,message:\"File not exists\"}\n static UNAUTHORIZED:IError={code:6,message:\"Unauthorized\"}\n static BAD_REQUEST:IError={code:7,message:\"Bad request\",httpStatus:400}\n static SERVICE_NOT_WORKING:IError={code:8,message:\"Service not working\"}\n static TIMEOUT:IError={code:9,message:\"Timeout\"}\n}\n\nexport class ErrorUtils{\n\n static isError(obj:any):boolean{\n const isFieldsExists = Validator.validateObject(['code','message'],obj)\n \n if(!isFieldsExists)\n return false;\n \n if(Validator.validateValue(obj.code,{type:\"number\"})!==ValidationReport.OK)\n return false;\n \n if(Validator.validateValue(obj.message,{type:\"string\"})!==ValidationReport.OK)\n return false;\n \n return true;\n }\n\n static appendStack(error:IError,stack?:IError[]):IError{\n error.stack = stack;\n return error;\n }\n}\n\nexport default DefaultErrors"]}
|
@@ -9,3 +9,4 @@ var HTTP_STATUS;
|
|
9
9
|
HTTP_STATUS[HTTP_STATUS["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
10
10
|
HTTP_STATUS[HTTP_STATUS["SERVER_ERROR"] = 500] = "SERVER_ERROR";
|
11
11
|
})(HTTP_STATUS || (exports.HTTP_STATUS = HTTP_STATUS = {}));
|
12
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSFRUUFN0YXR1cy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9hcGlTZXJ2ZXIvc3RydWN0dXJlcy9IVFRQU3RhdHVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLElBQVksV0FNWDtBQU5ELFdBQVksV0FBVztJQUNuQiwyQ0FBTSxDQUFBO0lBQ04seURBQWEsQ0FBQTtJQUNiLCtEQUFnQixDQUFBO0lBQ2hCLDZEQUFlLENBQUE7SUFDZiwrREFBZ0IsQ0FBQTtBQUNwQixDQUFDLEVBTlcsV0FBVywyQkFBWCxXQUFXLFFBTXRCIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGVudW0gSFRUUF9TVEFUVVN7XG4gICAgT0s9MjAwLFxuICAgIE5PVF9GT1VORD00MDQsXG4gICAgVU5BVVRIT1JJWkVEPTQwMSxcbiAgICBCQURfUkVRVUVTVD00MDAsXG4gICAgU0VSVkVSX0VSUk9SPTUwMFxufSJdfQ==
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"HTTPStatus.js","sourceRoot":"","sources":["../../../src/apiServer/structures/HTTPStatus.ts"],"names":[],"mappings":";;;AAAA,IAAY,WAMX;AAND,WAAY,WAAW;IACnB,2CAAM,CAAA;IACN,yDAAa,CAAA;IACb,+DAAgB,CAAA;IAChB,6DAAe,CAAA;IACf,+DAAgB,CAAA;AACpB,CAAC,EANW,WAAW,2BAAX,WAAW,QAMtB","sourcesContent":["export enum HTTP_STATUS{\n OK=200,\n NOT_FOUND=404,\n UNAUTHORIZED=401,\n BAD_REQUEST=400,\n SERVER_ERROR=500\n}"]}
|
@@ -1,2 +1,3 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSW50ZXJmYWNlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9hcGlTZXJ2ZXIvc3RydWN0dXJlcy9JbnRlcmZhY2VzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBGaWxlQXJyYXksIFVwbG9hZGVkRmlsZSB9IGZyb20gXCJleHByZXNzLWZpbGV1cGxvYWRcIlxuXG5leHBvcnQgaW50ZXJmYWNlIFRyYW5zZmVyUGFja2V0Vk88VD1hbnk+e1xuICAgIGRhdGE/OlR8bnVsbCxcbiAgICBlcnJvcj86SUVycm9yfG51bGwsXG4gICAgcmVzcG9uc2VUaW1lPzpudW1iZXJcbiAgICB2ZXJzaW9uPzpzdHJpbmcsXG4gICAgY29yZT86c3RyaW5nLFxuICAgIGVuZHBvaW50PzpzdHJpbmdcbiAgICBodHRwU3RhdHVzPzpudW1iZXIsXG4gICAgcmVkaXJlY3Q/OnN0cmluZ1xuICAgIHJhd1Jlc3BvbnNlPzpib29sZWFuXG4gICAgaGVhZGVycz86e1trZXk6c3RyaW5nXTpzdHJpbmd9XG4gICAgZmlsZT86c3RyaW5nXG59XG5cbmV4cG9ydCBpbnRlcmZhY2UgSFRUUFJlcXVlc3RWTzxUPWFueT57XG4gICAgcmF3OmFueSxcbiAgICBtZXRob2Q6c3RyaW5nLFxuICAgIGRhdGE6VCxcbiAgICBwYXJhbXM6e1trZXk6c3RyaW5nXTpzdHJpbmd9LFxuICAgIGhlYWRlcnM6e1trZXk6c3RyaW5nXTpzdHJpbmd9LFxuICAgIGVuZHBvaW50OnN0cmluZ1xuICAgIGludGVyY2VwdG9yUmVzdWx0PzpUcmFuc2ZlclBhY2tldFZPPGFueT5cbiAgICBwcmVwcm9kdWNlclJlc3VsdD86YW55XG4gICAgcHJlY2hlY2s/OlRyYW5zZmVyUGFja2V0Vk88YW55PnxudWxsXG4gICAgZmlsZXM6RmlsZUFycmF5IHwgbnVsbCB8IHVuZGVmaW5lZFxuICAgIHJlZmVyZXI/OnN0cmluZ1xuICAgIHVubG9ja2VkPzpib29sZWFuXG59XG5cbmV4cG9ydCBpbnRlcmZhY2UgSUVycm9ye1xuICAgIGNvZGU6bnVtYmVyLFxuICAgIG1lc3NhZ2U6c3RyaW5nLFxuICAgIGRldGFpbHM/OnN0cmluZyxcbiAgICBodHRwU3RhdHVzPzpudW1iZXJcbiAgICBzdGFjaz86SUVycm9yW11cbn0iXX0=
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Interfaces.js","sourceRoot":"","sources":["../../../src/apiServer/structures/Interfaces.ts"],"names":[],"mappings":"","sourcesContent":["import { FileArray, UploadedFile } from \"express-fileupload\"\n\nexport interface TransferPacketVO<T=any>{\n data?:T|null,\n error?:IError|null,\n responseTime?:number\n version?:string,\n core?:string,\n endpoint?:string\n httpStatus?:number,\n redirect?:string\n rawResponse?:boolean\n headers?:{[key:string]:string}\n file?:string\n}\n\nexport interface HTTPRequestVO<T=any>{\n raw:any,\n method:string,\n data:T,\n params:{[key:string]:string},\n headers:{[key:string]:string},\n endpoint:string\n interceptorResult?:TransferPacketVO<any>\n preproducerResult?:any\n precheck?:TransferPacketVO<any>|null\n files:FileArray | null | undefined\n referer?:string\n unlocked?:boolean\n}\n\nexport interface IError{\n code:number,\n message:string,\n details?:string,\n httpStatus?:number\n stack?:IError[]\n}"]}
|
package/dist/index.js
CHANGED
@@ -26,3 +26,4 @@ const HUBConnection_1 = require("./apiServer/cluster/HUBConnection");
|
|
26
26
|
Object.defineProperty(exports, "HUBConnection", { enumerable: true, get: function () { return HUBConnection_1.HUBConnection; } });
|
27
27
|
const ClusterService_1 = require("./apiServer/ClusterService");
|
28
28
|
Object.defineProperty(exports, "ClusterService", { enumerable: true, get: function () { return ClusterService_1.ClusterService; } });
|
29
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsdURBQWdFO0FBZTVELDJGQWZLLHVCQUFVLE9BZUw7QUFDViw0RkFoQmdCLHdCQUFXLE9BZ0JoQjtBQWZmLDJEQUF3RDtBQWdCcEQsNkZBaEJLLDJCQUFZLE9BZ0JMO0FBZmhCLDJEQUFxRDtBQWdCakQsNkZBaEJJLDJCQUFZLE9BZ0JKO0FBZmhCLDREQUF5RDtBQWdCckQsMEZBaEJLLHFCQUFTLE9BZ0JMO0FBZmIsdURBQW9EO0FBZ0JoRCwyRkFoQkssdUJBQVUsT0FnQkw7QUFmZCx3RUFBa0U7QUFpQjlELDJGQWpCSyww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AG,OAML;AALP,uDAAoD;AAchD,2FAdK,uBAAU,OAcL;AAbd,qEAAkE;AAe9D,8FAfK,6BAAa,OAeL;AAdjB,+DAA4D;AAaxD,+FAbK,+BAAc,OAaL","sourcesContent":["import { APIService,Initializer } from \"./apiServer/APIService\";\nimport { LocalRequest } from \"./apiServer/LocalRequest\";\nimport {MysqlService} from \"./apiServer/MysqlService\"\nimport { Validator } from \"./apiServer/helper/Validator\";\nimport { LogService } from \"./apiServer/LogService\";\nimport { ErrorUtils } from \"./apiServer/structures/DefaultErrors\";\nimport { S_MONITOR_REGISTRATE_ACTION } from \"./apiServer/monitor/Monitor\";\nimport { DataProvider } from \"./apiServer/helper/DataProvider\";\nimport { UID } from \"./apiServer/helper/UID\";\nimport { HUBService } from \"./apiServer/HUBService\";\nimport { HUBConnection } from \"./apiServer/cluster/HUBConnection\";\nimport { ClusterService } from \"./apiServer/ClusterService\";\n\nexport {\n UID,\n APIService,\n Initializer,\n LocalRequest,\n MysqlService,\n Validator,\n LogService,\n DataProvider,\n ErrorUtils,\n HUBService,\n ClusterService,\n HUBConnection,\n S_MONITOR_REGISTRATE_ACTION\n}"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "badmfck-api-server",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.5.1",
|
4
4
|
"description": "Simple API http server based on express",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -21,7 +21,7 @@
|
|
21
21
|
"@types/mysql": "^2.15.21",
|
22
22
|
"@types/ws": "^8.5.9",
|
23
23
|
"axios": "^1.7.7",
|
24
|
-
"badmfck-signal": "^1.4.
|
24
|
+
"badmfck-signal": "^1.4.8",
|
25
25
|
"comment-parser": "^1.4.1",
|
26
26
|
"cors": "^2.8.5",
|
27
27
|
"express": "^4.21.1",
|