@resolveio/server-lib 1.0.18 → 1.0.19
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.
|
@@ -6,9 +6,10 @@ export declare class SupportManager {
|
|
|
6
6
|
private _mailer;
|
|
7
7
|
private _aws;
|
|
8
8
|
private serverConfig;
|
|
9
|
+
private clientDir;
|
|
9
10
|
private _sendQueue;
|
|
10
11
|
private _runningQueue;
|
|
11
|
-
constructor(mainServer: any, serverConfig: any);
|
|
12
|
+
constructor(mainServer: any, serverConfig: any, clientDir: any);
|
|
12
13
|
getMainServer(): ResolveIOMainServer;
|
|
13
14
|
supportMethods(supportMethod: SupportMethodModel): void;
|
|
14
15
|
callSupportMethod(ws: WebSocket, messageId: any, supportMethod: any, ...methodData: any[]): void;
|
|
@@ -16,4 +17,6 @@ export declare class SupportManager {
|
|
|
16
17
|
callMethodInternal(method: any, ...methodData: any[]): Promise<any>;
|
|
17
18
|
private sendWS;
|
|
18
19
|
sendEmail(sendTo: string, subject: string, text?: string, html?: string, attachments?: any[]): void;
|
|
20
|
+
readFile(fileName: any): Promise<{}>;
|
|
21
|
+
readImage(fileName: any): Promise<{}>;
|
|
19
22
|
}
|
|
@@ -9,14 +9,17 @@ var mongoose_1 = require("mongoose");
|
|
|
9
9
|
var common_1 = require("../util/common");
|
|
10
10
|
var log_collection_1 = require("../collections/log.collection");
|
|
11
11
|
var method_manager_1 = require("./method.manager");
|
|
12
|
+
var path = require("path");
|
|
13
|
+
var fs = require("fs");
|
|
12
14
|
var SupportManager = /** @class */ (function () {
|
|
13
|
-
function SupportManager(mainServer, serverConfig) {
|
|
15
|
+
function SupportManager(mainServer, serverConfig, clientDir) {
|
|
14
16
|
var _this = this;
|
|
15
17
|
this._supportMethods = {};
|
|
16
18
|
this._sendQueue = [];
|
|
17
19
|
this._runningQueue = false;
|
|
18
20
|
this._mainServer = mainServer;
|
|
19
21
|
this.serverConfig = serverConfig;
|
|
22
|
+
this.clientDir = clientDir;
|
|
20
23
|
collections_1.loadSupportCollectionMethods(this);
|
|
21
24
|
support_1.loadSupportMethods(this);
|
|
22
25
|
counters_1.loadCounterMethods(this);
|
|
@@ -258,6 +261,60 @@ var SupportManager = /** @class */ (function () {
|
|
|
258
261
|
}
|
|
259
262
|
});
|
|
260
263
|
};
|
|
264
|
+
SupportManager.prototype.readFile = function (fileName) {
|
|
265
|
+
var _this = this;
|
|
266
|
+
return new Promise(function (resolve, reject) {
|
|
267
|
+
if (fs.existsSync(path.join(__dirname, ('../private/' + fileName)))) {
|
|
268
|
+
fs.readFile(path.join(__dirname, ('../private/' + fileName)), 'utf-8', function (err, res) {
|
|
269
|
+
if (err) {
|
|
270
|
+
reject(err);
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
resolve(res);
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
if (fs.existsSync(path.join(_this.clientDir, ('./private/' + fileName)))) {
|
|
279
|
+
fs.readFile(path.join(_this.clientDir, ('./private/' + fileName)), 'utf-8', function (err, res) {
|
|
280
|
+
if (err) {
|
|
281
|
+
reject(err);
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
resolve(res);
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
};
|
|
291
|
+
SupportManager.prototype.readImage = function (fileName) {
|
|
292
|
+
var _this = this;
|
|
293
|
+
return new Promise(function (resolve, reject) {
|
|
294
|
+
if (fs.existsSync(path.join(__dirname, ('../private/' + fileName)))) {
|
|
295
|
+
fs.readFile(path.join(__dirname, ('../private/' + fileName)), 'base64', function (err, res) {
|
|
296
|
+
if (err) {
|
|
297
|
+
reject(err);
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
resolve(res);
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
if (fs.existsSync(path.join(_this.clientDir, ('./private/' + fileName)))) {
|
|
306
|
+
fs.readFile(path.join(_this.clientDir, ('./private/' + fileName)), 'base64', function (err, res) {
|
|
307
|
+
if (err) {
|
|
308
|
+
reject(err);
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
resolve(res);
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
};
|
|
261
318
|
return SupportManager;
|
|
262
319
|
}());
|
|
263
320
|
exports.SupportManager = SupportManager;
|
package/package.json
CHANGED
package/server-app.js
CHANGED
|
@@ -206,7 +206,7 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
206
206
|
// Start Managers
|
|
207
207
|
this._subscriptionManager = new subscription_manager_1.SubscriptionManager(this, this._wss, this._serverConfig);
|
|
208
208
|
this._methodManager = new method_manager_1.MethodManager(this, this._serverConfig, this._clientDir);
|
|
209
|
-
this._supportManager = new support_manager_1.SupportManager(this, this._serverConfig);
|
|
209
|
+
this._supportManager = new support_manager_1.SupportManager(this, this._serverConfig, this._clientDir);
|
|
210
210
|
this._cronManager = new cron_manager_1.CronManager(this);
|
|
211
211
|
this._queueManager = new queue_method_manager_1.QueueMethodManager(this);
|
|
212
212
|
this.listen();
|