oak-backend-base 4.0.1 → 4.0.2

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 (2) hide show
  1. package/lib/AppLoader.js +40 -36
  2. package/package.json +3 -3
package/lib/AppLoader.js CHANGED
@@ -65,7 +65,7 @@ class AppLoader extends types_1.AppLoader {
65
65
  const { dbConfig } = this.getConfiguration();
66
66
  const { storageSchema } = require(`${path}/lib/oak-app-domain/Storage`);
67
67
  const depGraph = (0, dependencyBuilder_1.analyzeDepedency)(process.cwd());
68
- this.externalDependencies = Object.keys(depGraph.nodeDict);
68
+ this.externalDependencies = depGraph.ascOrder;
69
69
  const { authDeduceRelationMap, selectFreeEntities, updateFreeDict } = this.requireSth('lib/configuration/relation');
70
70
  this.aspectDict = Object.assign({}, index_1.default, this.requireSth('lib/aspects/index'));
71
71
  this.dbStore = new DbStore_1.DbStore(storageSchema, () => this.contextBuilder(this.dbStore), dbConfig, authDeduceRelationMap, selectFreeEntities, updateFreeDict);
@@ -220,13 +220,15 @@ class AppLoader extends types_1.AppLoader {
220
220
  }
221
221
  }]);
222
222
  };
223
- for (const router in endpoints) {
224
- const item = endpoints[router];
225
- if (item instanceof Array) {
226
- item.forEach(ele => transformEndpointItem(router, ele));
227
- }
228
- else {
229
- transformEndpointItem(router, item);
223
+ if (endpoints) {
224
+ for (const router in endpoints) {
225
+ const item = endpoints[router];
226
+ if (item instanceof Array) {
227
+ item.forEach(ele => transformEndpointItem(router, ele));
228
+ }
229
+ else {
230
+ transformEndpointItem(router, item);
231
+ }
230
232
  }
231
233
  }
232
234
  if (this.synchronizer) {
@@ -285,7 +287,7 @@ class AppLoader extends types_1.AppLoader {
285
287
  const watchers = this.requireSth('lib/watchers/index');
286
288
  const { ActionDefDict } = require(`${this.path}/lib/oak-app-domain/ActionDefDict`);
287
289
  const { watchers: adWatchers } = (0, IntrinsicLogics_1.makeIntrinsicLogics)(this.dbStore.getSchema(), ActionDefDict);
288
- const totalWatchers = watchers.concat(adWatchers);
290
+ const totalWatchers = (watchers || []).concat(adWatchers);
289
291
  let count = 0;
290
292
  const execOne = async (watcher, start) => {
291
293
  try {
@@ -317,38 +319,40 @@ class AppLoader extends types_1.AppLoader {
317
319
  }
318
320
  startTimers() {
319
321
  const timers = this.requireSth('lib/timers/index');
320
- for (const timer of timers) {
321
- const { cron, name } = timer;
322
- (0, node_schedule_1.scheduleJob)(name, cron, async (date) => {
323
- const start = Date.now();
324
- console.log(`定时器【${name}】开始执行,时间是【${date.toLocaleTimeString()}】`);
325
- if (timer.hasOwnProperty('entity')) {
326
- try {
327
- const result = await this.execWatcher(timer);
328
- console.log(`定时器【${name}】执行成功,耗时${Date.now() - start}毫秒】,结果是`, result);
329
- }
330
- catch (err) {
331
- console.log(`定时器【${name}】执行成功,耗时${Date.now() - start}毫秒】,错误是`, err);
322
+ if (timers) {
323
+ for (const timer of timers) {
324
+ const { cron, name } = timer;
325
+ (0, node_schedule_1.scheduleJob)(name, cron, async (date) => {
326
+ const start = Date.now();
327
+ console.log(`定时器【${name}】开始执行,时间是【${date.toLocaleTimeString()}】`);
328
+ if (timer.hasOwnProperty('entity')) {
329
+ try {
330
+ const result = await this.execWatcher(timer);
331
+ console.log(`定时器【${name}】执行成功,耗时${Date.now() - start}毫秒】,结果是`, result);
332
+ }
333
+ catch (err) {
334
+ console.log(`定时器【${name}】执行成功,耗时${Date.now() - start}毫秒】,错误是`, err);
335
+ }
332
336
  }
333
- }
334
- else {
335
- const context = await this.makeContext();
336
- try {
337
- const { timer: timerFn } = timer;
338
- const result = await timerFn(context);
339
- console.log(`定时器【${name}】执行成功,耗时${Date.now() - start}毫秒,结果是【${result}】`);
340
- await context.commit();
337
+ else {
338
+ const context = await this.makeContext();
339
+ try {
340
+ const { timer: timerFn } = timer;
341
+ const result = await timerFn(context);
342
+ console.log(`定时器【${name}】执行成功,耗时${Date.now() - start}毫秒,结果是【${result}】`);
343
+ await context.commit();
344
+ }
345
+ catch (err) {
346
+ console.warn(`定时器【${name}】执行失败,耗时${Date.now() - start}毫秒,错误是`, err);
347
+ await context.rollback();
348
+ }
341
349
  }
342
- catch (err) {
343
- console.warn(`定时器【${name}】执行失败,耗时${Date.now() - start}毫秒,错误是`, err);
344
- await context.rollback();
345
- }
346
- }
347
- });
350
+ });
351
+ }
348
352
  }
349
353
  }
350
354
  async execStartRoutines() {
351
- const routines = this.requireSth('lib/routines/start');
355
+ const routines = this.requireSth('lib/routines/start') || [];
352
356
  if (this.synchronizer) {
353
357
  const routine = this.synchronizer.getSyncRoutine();
354
358
  routines.push(routine);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oak-backend-base",
3
- "version": "4.0.1",
3
+ "version": "4.0.2",
4
4
  "description": "oak-backend-base",
5
5
  "main": "lib/index",
6
6
  "author": {
@@ -22,8 +22,8 @@
22
22
  "node-schedule": "^2.1.0",
23
23
  "oak-common-aspect": "^3.0.0",
24
24
  "oak-db": "^3.3.0",
25
- "oak-domain": "^5.0.0",
26
- "oak-frontend-base": "^5.0.0",
25
+ "oak-domain": "^5.0.3",
26
+ "oak-frontend-base": "^5.0.3",
27
27
  "socket.io": "^4.7.2",
28
28
  "socket.io-client": "^4.7.2",
29
29
  "uuid": "^8.3.2"