@paralect/hive 0.1.5 → 0.1.6
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/package.json +1 -1
- package/starter/src/app-config/index.js +4 -0
- package/starter/src/db.js +1 -1
- package/starter/src/scheduler.js +23 -12
package/package.json
CHANGED
|
@@ -8,6 +8,10 @@ dotenv.config({ path: `${__dirname}/.env.app` });
|
|
|
8
8
|
console.log('process.env.HIVE_SRC', process.env.HIVE_SRC)
|
|
9
9
|
|
|
10
10
|
if (process.env.HIVE_SRC) {
|
|
11
|
+
dotenv.config({
|
|
12
|
+
path: `${process.env.HIVE_SRC}/app-config/.env`,
|
|
13
|
+
});
|
|
14
|
+
|
|
11
15
|
dotenv.config({
|
|
12
16
|
path: `${process.env.HIVE_SRC}/app-config/.env.app`,
|
|
13
17
|
});
|
package/starter/src/db.js
CHANGED
|
@@ -29,7 +29,7 @@ db.init = async () => {
|
|
|
29
29
|
db.schemas[schemaName] = schema;
|
|
30
30
|
db.services[schemaName] = db.createService(`${resourceName}`, {
|
|
31
31
|
validate: (obj) => {
|
|
32
|
-
return schema.passthrough().
|
|
32
|
+
return { value: schema.passthrough().parse(obj) };
|
|
33
33
|
},
|
|
34
34
|
});
|
|
35
35
|
|
package/starter/src/scheduler.js
CHANGED
|
@@ -1,21 +1,32 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fs from 'fs';
|
|
1
3
|
import moment from 'moment';
|
|
2
4
|
import schedule from 'node-schedule';
|
|
3
5
|
import requireDir from 'require-dir';
|
|
4
6
|
|
|
5
7
|
export default () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
);
|
|
8
|
+
const paths = [path.resolve(__dirname, './scheduler/handlers')];
|
|
9
|
+
if (process.env.HIVE_SRC) {
|
|
10
|
+
paths.push(path.resolve(process.env.HIVE_SRC, './scheduler/handlers'))
|
|
11
|
+
}
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
paths.forEach((pathName) => {
|
|
14
|
+
if (fs.existsSync(pathName)) {
|
|
15
|
+
requireDir(pathName, {
|
|
16
|
+
mapValue: (handler, handlerName) => {
|
|
17
|
+
console.log(
|
|
18
|
+
`[scheduler] Registering handler ${handlerName} with cron ${handler.cron}`
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
schedule.scheduleJob(handler.cron, () => {
|
|
22
|
+
console.log(
|
|
23
|
+
`[scheduler] ${moment().format()} executing ${handlerName} with cron ${handler.cron
|
|
24
|
+
}`
|
|
25
|
+
);
|
|
26
|
+
handler.handler();
|
|
27
|
+
});
|
|
28
|
+
},
|
|
18
29
|
});
|
|
19
|
-
}
|
|
30
|
+
}
|
|
20
31
|
});
|
|
21
32
|
}
|