oak-backend-base 2.2.1 → 2.3.1
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/lib/AppLoader.js +15 -10
- package/package.json +4 -4
package/lib/AppLoader.js
CHANGED
|
@@ -9,7 +9,7 @@ const triggers_1 = require("oak-domain/lib/triggers");
|
|
|
9
9
|
const uuid_1 = require("oak-domain/lib/utils/uuid");
|
|
10
10
|
const types_1 = require("oak-domain/lib/types");
|
|
11
11
|
const DbStore_1 = require("./DbStore");
|
|
12
|
-
const index_1 = tslib_1.
|
|
12
|
+
const index_1 = tslib_1.__importStar(require("oak-common-aspect/lib/index"));
|
|
13
13
|
function initTriggers(dbStore, path) {
|
|
14
14
|
const triggers = require(`${path}/lib/triggers/index`).default;
|
|
15
15
|
const checkers = require(`${path}/lib/checkers/index`).default;
|
|
@@ -94,9 +94,12 @@ class AppLoader extends types_1.AppLoader {
|
|
|
94
94
|
if (!initialize) {
|
|
95
95
|
initTriggers(this.dbStore, path);
|
|
96
96
|
}
|
|
97
|
+
const { importations, exportations } = require(`${path}/lib/ports/index`);
|
|
98
|
+
(0, index_1.registerPorts)(importations || [], exportations || []);
|
|
97
99
|
this.dbStore.connect();
|
|
98
100
|
}
|
|
99
101
|
async unmount() {
|
|
102
|
+
(0, index_1.clearPorts)();
|
|
100
103
|
this.dbStore.disconnect();
|
|
101
104
|
}
|
|
102
105
|
async execAspect(name, context, params) {
|
|
@@ -117,14 +120,16 @@ class AppLoader extends types_1.AppLoader {
|
|
|
117
120
|
// 对area暂时处理一下
|
|
118
121
|
rows = require('./data/area.json');
|
|
119
122
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
123
|
+
if (rows.length > 0) {
|
|
124
|
+
await this.dbStore.operate(entity, {
|
|
125
|
+
data: rows,
|
|
126
|
+
action: 'create',
|
|
127
|
+
}, context, {
|
|
128
|
+
dontCollect: true,
|
|
129
|
+
dontCreateOper: true,
|
|
130
|
+
});
|
|
131
|
+
console.log(`data in ${entity} initialized!`);
|
|
132
|
+
}
|
|
128
133
|
}
|
|
129
134
|
await context.commit();
|
|
130
135
|
this.dbStore.disconnect();
|
|
@@ -136,7 +141,7 @@ class AppLoader extends types_1.AppLoader {
|
|
|
136
141
|
startWatchers(this.dbStore, this.path, this.contextBuilder);
|
|
137
142
|
}
|
|
138
143
|
startTimers() {
|
|
139
|
-
const timers = require(`${this.path}/lib/
|
|
144
|
+
const timers = require(`${this.path}/lib/timers/index`).default;
|
|
140
145
|
for (const timer of timers) {
|
|
141
146
|
const { cron, fn, name } = timer;
|
|
142
147
|
(0, node_schedule_1.scheduleJob)(name, cron, async (date) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oak-backend-base",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "oak-backend-base",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"author": {
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"mysql": "^2.18.1",
|
|
21
21
|
"mysql2": "^2.3.3",
|
|
22
22
|
"node-schedule": "^2.1.0",
|
|
23
|
-
"oak-common-aspect": "^2.1.
|
|
24
|
-
"oak-db": "^2.
|
|
25
|
-
"oak-domain": "^2.2
|
|
23
|
+
"oak-common-aspect": "^2.1.3",
|
|
24
|
+
"oak-db": "^2.2.1",
|
|
25
|
+
"oak-domain": "^2.3.2",
|
|
26
26
|
"uuid": "^8.3.2"
|
|
27
27
|
},
|
|
28
28
|
"license": "ISC",
|