@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paralect/hive",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -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().parseAsync(obj)
32
+ return { value: schema.passthrough().parse(obj) };
33
33
  },
34
34
  });
35
35
 
@@ -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
- requireDir(`${process.env.HIVE_SRC || "."}/scheduler/handlers`, {
7
- mapValue: (handler, handlerName) => {
8
- console.log(
9
- `[scheduler] Registering handler ${handlerName} with cron ${handler.cron}`
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
- schedule.scheduleJob(handler.cron, () => {
13
- console.log(
14
- `[scheduler] ${moment().format()} executing ${handlerName} with cron ${handler.cron
15
- }`
16
- );
17
- handler.handler();
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
  }