cgserver 7.4.1442 → 7.6.1447

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.
@@ -216,7 +216,12 @@ class MongoManager {
216
216
  let del_rs = null;
217
217
  try {
218
218
  let col = this._mongo.collection(collection);
219
- del_rs = await col.deleteOne(where || {});
219
+ del_rs = await col.deleteOne(where || {}).catch((reason) => {
220
+ Log_1.GLog.error({ collection, where });
221
+ Log_1.GLog.error(reason);
222
+ rs.errcode = _error_1.EErrorCode.Mongo_Error;
223
+ return null;
224
+ });
220
225
  }
221
226
  catch (e) {
222
227
  Log_1.GLog.error({ collection, where });
@@ -238,7 +243,12 @@ class MongoManager {
238
243
  let del_rs = null;
239
244
  try {
240
245
  let col = this._mongo.collection(collection);
241
- del_rs = await col.deleteMany(where || {});
246
+ del_rs = await col.deleteMany(where || {}).catch((reason) => {
247
+ Log_1.GLog.error({ collection, where });
248
+ Log_1.GLog.error(reason);
249
+ rs.errcode = _error_1.EErrorCode.Mongo_Error;
250
+ return null;
251
+ });
242
252
  }
243
253
  catch (e) {
244
254
  Log_1.GLog.error({ collection, where });
@@ -264,7 +274,12 @@ class MongoManager {
264
274
  let in_rs = null;
265
275
  try {
266
276
  let col = this._mongo.collection(collection);
267
- in_rs = await col.insertOne(data);
277
+ in_rs = await col.insertOne(data).catch((reason) => {
278
+ Log_1.GLog.error({ collection, data });
279
+ Log_1.GLog.error(reason);
280
+ rs.errcode = _error_1.EErrorCode.Mongo_Error;
281
+ return null;
282
+ });
268
283
  }
269
284
  catch (e) {
270
285
  Log_1.GLog.error({ collection, data });
@@ -283,7 +298,12 @@ class MongoManager {
283
298
  let in_rs = null;
284
299
  try {
285
300
  let col = this._mongo.collection(collection);
286
- in_rs = await col.insertMany(data);
301
+ in_rs = await col.insertMany(data).catch((reason) => {
302
+ Log_1.GLog.error({ collection, data });
303
+ Log_1.GLog.error(reason);
304
+ rs.errcode = _error_1.EErrorCode.Mongo_Error;
305
+ return null;
306
+ });
287
307
  }
288
308
  catch (e) {
289
309
  Log_1.GLog.error({ collection, data });
@@ -324,7 +344,12 @@ class MongoManager {
324
344
  updatemodel = model;
325
345
  }
326
346
  let col = this._mongo.collection(collection);
327
- up_rs = await col.updateOne(where, updatemodel, { upsert: upsert });
347
+ up_rs = await col.updateOne(where, updatemodel, { upsert: upsert }).catch((reason) => {
348
+ Log_1.GLog.error({ collection, model, where, upsert });
349
+ Log_1.GLog.error(reason);
350
+ rs.errcode = _error_1.EErrorCode.Mongo_Error;
351
+ return null;
352
+ });
328
353
  }
329
354
  catch (e) {
330
355
  Log_1.GLog.error({ collection, model, where, upsert });
@@ -355,7 +380,12 @@ class MongoManager {
355
380
  updateModel = model;
356
381
  }
357
382
  let col = this._mongo.collection(collection);
358
- up_rs = await col.updateMany(where, updateModel, { upsert: upsert });
383
+ up_rs = await col.updateMany(where, updateModel, { upsert: upsert }).catch((reason) => {
384
+ Log_1.GLog.error({ collection, model, where, upsert });
385
+ Log_1.GLog.error(reason);
386
+ rs.errcode = _error_1.EErrorCode.Mongo_Error;
387
+ return null;
388
+ });
359
389
  }
360
390
  catch (e) {
361
391
  Log_1.GLog.error({ collection, model, where, upsert });
@@ -374,7 +404,12 @@ class MongoManager {
374
404
  let i_rs = null;
375
405
  try {
376
406
  let col = this._mongo.collection(collection);
377
- i_rs = await col.createIndex(index, options);
407
+ i_rs = await col.createIndex(index, options).catch((reason) => {
408
+ Log_1.GLog.error({ collection, index });
409
+ Log_1.GLog.error(reason);
410
+ rs.errcode = _error_1.EErrorCode.Mongo_Error;
411
+ return null;
412
+ });
378
413
  }
379
414
  catch (e) {
380
415
  Log_1.GLog.error({ collection, index });
@@ -40,6 +40,9 @@ class CgServer {
40
40
  }
41
41
  ++i;
42
42
  Config_1.Config.rootDataDir = argv[i].toLocaleLowerCase();
43
+ if (!Config_1.Config.rootDataDir.endsWith("/")) {
44
+ Config_1.Config.rootDataDir += "/";
45
+ }
43
46
  }
44
47
  }
45
48
  }
@@ -102,7 +102,7 @@ export declare class core {
102
102
  static sleep(milliseconds: number): Promise<unknown>;
103
103
  static safeCall(func: Function, thisArg?: any, ...params: any[]): Promise<any>;
104
104
  static getYearWeek(time: number): number;
105
- static toBase64(content: string): any;
106
- static aesEncode(content: string, key: string, iv: string): any;
107
- static aesDecode(base64_str: string, key: string, iv: string): any;
105
+ static toBase64(content: string): string;
106
+ static aesEncode(content: string, key: string, iv: string): string;
107
+ static aesDecode(base64_str: string, key: string, iv: string): string;
108
108
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cgserver",
3
- "version": "7.4.1442",
3
+ "version": "7.6.1447",
4
4
  "author": "trojan",
5
5
  "type": "commonjs",
6
6
  "description": "free for all.Websocket or Http",