@resolveio/server-lib 12.2.16 → 12.2.18
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.
- package/index.d.ts +2 -2
- package/index.js +55 -8
- package/index.js.map +1 -1
- package/managers/mongo.manager.d.ts +2 -1
- package/managers/mongo.manager.js +16 -2
- package/managers/mongo.manager.js.map +1 -1
- package/package.json +1 -1
- package/server-app.js +1 -0
- package/server-app.js.map +1 -1
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Db, MongoClient } from 'mongodb';
|
|
2
2
|
import { MongoManager } from './managers/mongo.manager';
|
|
3
|
-
import
|
|
3
|
+
import ResolveIOMainServer from './server-app';
|
|
4
4
|
export declare class ResolveIOServer {
|
|
5
5
|
private static _serverConfig;
|
|
6
6
|
private static _clientRoutes;
|
|
@@ -15,7 +15,7 @@ export declare class ResolveIOServer {
|
|
|
15
15
|
constructor(serverConfig: any, clientRoutes: string[], client: string, clientDir: any, sesMail?: boolean, standardProgram?: boolean);
|
|
16
16
|
static connectAndRun(): Promise<unknown>;
|
|
17
17
|
static getClientName(): string;
|
|
18
|
-
static getMainServer():
|
|
18
|
+
static getMainServer(): ResolveIOMainServer;
|
|
19
19
|
static getMongoConnection(): MongoClient;
|
|
20
20
|
static getMainDB(): Db;
|
|
21
21
|
static getMongoManager(): MongoManager;
|
package/index.js
CHANGED
|
@@ -9,11 +9,46 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
9
9
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (_) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
12
48
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
49
|
exports.ResolveIOServer = void 0;
|
|
14
50
|
var mongodb_1 = require("mongodb");
|
|
15
51
|
var mongo_manager_1 = require("./managers/mongo.manager");
|
|
16
|
-
var server_app_1 = require("./server-app");
|
|
17
52
|
var ResolveIOServer = /** @class */ (function () {
|
|
18
53
|
function ResolveIOServer(serverConfig, clientRoutes, client, clientDir, sesMail, standardProgram) {
|
|
19
54
|
if (sesMail === void 0) { sesMail = true; }
|
|
@@ -29,13 +64,25 @@ var ResolveIOServer = /** @class */ (function () {
|
|
|
29
64
|
var _this = this;
|
|
30
65
|
return new Promise(function (resolve, reject) {
|
|
31
66
|
mongodb_1.MongoClient.connect(ResolveIOServer._serverConfig['MONGO_URL']).then(function (dbConnection) {
|
|
32
|
-
dbConnection.db().listCollections().toArray().then(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
67
|
+
// dbConnection.db().listCollections().toArray().then(collections => {
|
|
68
|
+
ResolveIOServer._mongoConnection = dbConnection;
|
|
69
|
+
ResolveIOServer._mainDB = dbConnection.db(ResolveIOServer._serverConfig['DATABASE']);
|
|
70
|
+
// ResolveIOServer._mongoManager = new MongoManager(collections);
|
|
71
|
+
ResolveIOServer._mongoManager = new mongo_manager_1.MongoManager();
|
|
72
|
+
setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
73
|
+
var serverApp;
|
|
74
|
+
return __generator(this, function (_a) {
|
|
75
|
+
switch (_a.label) {
|
|
76
|
+
case 0: return [4 /*yield*/, Promise.resolve().then(function () { return require('./server-app'); })];
|
|
77
|
+
case 1:
|
|
78
|
+
serverApp = (_a.sent()).default;
|
|
79
|
+
ResolveIOServer._mainServer = new serverApp(this, ResolveIOServer._serverConfig, ResolveIOServer._clientRoutes, this._clientDir, this._sesMail, this._standardProgram);
|
|
80
|
+
resolve(true);
|
|
81
|
+
return [2 /*return*/];
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}); }, 1);
|
|
85
|
+
// });
|
|
39
86
|
}, function (err) {
|
|
40
87
|
console.error(new Date(), 'MONGO CLIENT CONNECT FAILED', JSON.stringify(err, null, 2));
|
|
41
88
|
reject();
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAA0C;AAC1C,0DAAwD;AAGxD;IAYC,yBAAY,YAAY,EAAE,YAAsB,EAAE,MAAc,EAAE,SAAS,EAAE,OAAc,EAAE,eAAuB;QAAvC,wBAAA,EAAA,cAAc;QAAE,gCAAA,EAAA,uBAAuB;QACnH,eAAe,CAAC,aAAa,GAAG,YAAY,CAAC;QAC7C,eAAe,CAAC,aAAa,GAAG,YAAY,CAAC;QAC7C,eAAe,CAAC,OAAO,GAAG,MAAM,CAAC;QACjC,eAAe,CAAC,UAAU,GAAG,SAAS,CAAC;QACvC,eAAe,CAAC,QAAQ,GAAG,OAAO,CAAC;QACnC,eAAe,CAAC,gBAAgB,GAAG,eAAe,CAAC;IACpD,CAAC;IAEa,6BAAa,GAA3B;QAAA,iBAsBC;QArBA,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;YAClC,qBAAW,CAAC,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,U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,eAAe,CAAC,aAAa,CAAC;IACtC,CAAC;IA9Dc,6BAAa,GAAG,IAAI,CAAC;IACrB,6BAAa,GAAG,EAAE,CAAC;IACnB,gCAAgB,GAAgB,IAAI,CAAC;IACrC,uBAAO,GAAO,IAAI,CAAC;IACnB,2BAAW,GAAwB,IAAI,CAAC;IACxC,6BAAa,GAAiB,IAAI,CAAC;IACnC,uBAAO,GAAG,EAAE,CAAC;IACb,0BAAU,GAAG,EAAE,CAAC;IAChB,wBAAQ,GAAG,IAAI,CAAC;IAChB,gCAAgB,GAAG,KAAK,CAAC;IAsDzC,sBAAC;CAhED,AAgEC,IAAA;AAhEY,0CAAe;AAkE5B,+CAA6B","file":"index.js","sourcesContent":["import { Db, MongoClient } from 'mongodb';\nimport { MongoManager } from './managers/mongo.manager';\nimport ResolveIOMainServer from './server-app';\n\nexport class ResolveIOServer {\n\tprivate static _serverConfig = null;\n\tprivate static _clientRoutes = [];\n\tprivate static _mongoConnection: MongoClient = null;\n\tprivate static _mainDB: Db = null;\n\tprivate static _mainServer: ResolveIOMainServer = null;\n\tprivate static _mongoManager: MongoManager = null;\n\tprivate static _client = '';\n\tprivate static _clientDir = '';\n\tprivate static _sesMail = true;\n\tprivate static _standardProgram = false;\n\n\tconstructor(serverConfig, clientRoutes: string[], client: string, clientDir, sesMail = true, standardProgram = false) {\n\t\tResolveIOServer._serverConfig = serverConfig;\n\t\tResolveIOServer._clientRoutes = clientRoutes;\n\t\tResolveIOServer._client = client;\n\t\tResolveIOServer._clientDir = clientDir;\n\t\tResolveIOServer._sesMail = sesMail;\n\t\tResolveIOServer._standardProgram = standardProgram;\n\t}\n\n\tpublic static connectAndRun() {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tMongoClient.connect(ResolveIOServer._serverConfig['MONGO_URL']).then(dbConnection => {\n\t\t\t\t// dbConnection.db().listCollections().toArray().then(collections => {\n\t\t\t\t\tResolveIOServer._mongoConnection = dbConnection;\n\t\t\t\t\tResolveIOServer._mainDB = dbConnection.db(ResolveIOServer._serverConfig['DATABASE']);\n\t\t\t\t\t// ResolveIOServer._mongoManager = new MongoManager(collections);\n\t\t\t\t\tResolveIOServer._mongoManager = new MongoManager();\n\t\t\t\t\t\n\t\t\t\t\tsetTimeout(async () => {\n\t\t\t\t\t\tlet serverApp = (await import('./server-app')).default;\n\t\t\t\t\t\tResolveIOServer._mainServer = new serverApp(this, ResolveIOServer._serverConfig, ResolveIOServer._clientRoutes, this._clientDir, this._sesMail, this._standardProgram);\n\n\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t}, 1);\n\t\t\t\t// });\n\t\t\t}, err => {\n\t\t\t\tconsole.error(new Date(), 'MONGO CLIENT CONNECT FAILED', JSON.stringify(err, null, 2));\n\t\t\t\treject();\n\t\t\t\tprocess.exit(1);\n\t\t\t});\n\t\t});\n\t}\n\n\tpublic static getClientName() {\n\t\treturn this._client;\n\t}\n\n\tpublic static getMainServer() {\n\t\treturn ResolveIOServer._mainServer;\n\t}\n\n\tpublic static getMongoConnection() {\n\t\treturn ResolveIOServer._mongoConnection;\n\t}\n\n\tpublic static getMainDB() {\n\t\treturn ResolveIOServer._mainDB;\n\t}\n\n\tpublic static getMongoManager() {\n\t\treturn ResolveIOServer._mongoManager;\n\t}\n}\n\nexport * from './public_api';"]}
|
|
@@ -83,7 +83,8 @@ export declare class MongoManager {
|
|
|
83
83
|
private _debugMongoQueueHits;
|
|
84
84
|
private _debugRemoveCacheHits;
|
|
85
85
|
private _debugMongoQueueCollections;
|
|
86
|
-
constructor(
|
|
86
|
+
constructor();
|
|
87
|
+
initServerCollections(): Promise<void>;
|
|
87
88
|
getServerCollections(): (CollectionInfo | Pick<CollectionInfo, "type" | "name">)[];
|
|
88
89
|
registerCollection(collection: MongoManagerCollection<CollectionDocument>): void;
|
|
89
90
|
createCollection(collection: MongoManagerCollection<CollectionDocument>): void;
|
|
@@ -71,7 +71,7 @@ var os_1 = require("os");
|
|
|
71
71
|
var numCPUs = os_1.cpus().length;
|
|
72
72
|
var v8 = require('v8');
|
|
73
73
|
var MongoManager = /** @class */ (function () {
|
|
74
|
-
function MongoManager(
|
|
74
|
+
function MongoManager() {
|
|
75
75
|
var _this = this;
|
|
76
76
|
this._collections = [];
|
|
77
77
|
this._mongoQueue = [];
|
|
@@ -97,10 +97,24 @@ var MongoManager = /** @class */ (function () {
|
|
|
97
97
|
_this._debugMongoQueueHits = 0;
|
|
98
98
|
_this._debugRemoveCacheHits = 0;
|
|
99
99
|
_this._debugMongoQueueCollections = [];
|
|
100
|
-
_this._serverCollections = collections;
|
|
101
100
|
}, 60000);
|
|
101
|
+
this.initServerCollections();
|
|
102
102
|
this.runQueue();
|
|
103
103
|
}
|
|
104
|
+
MongoManager.prototype.initServerCollections = function () {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
106
|
+
var collections;
|
|
107
|
+
return __generator(this, function (_a) {
|
|
108
|
+
switch (_a.label) {
|
|
109
|
+
case 0: return [4 /*yield*/, index_1.ResolveIOServer.getMainDB().listCollections().toArray()];
|
|
110
|
+
case 1:
|
|
111
|
+
collections = _a.sent();
|
|
112
|
+
this._serverCollections = collections;
|
|
113
|
+
return [2 /*return*/];
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
};
|
|
104
118
|
MongoManager.prototype.getServerCollections = function () {
|
|
105
119
|
return this._serverCollections;
|
|
106
120
|
};
|