pangea-server 3.3.0 → 3.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.
@@ -1,10 +1,10 @@
1
1
  import { Db } from '../database';
2
- type TaskFn = (db: Db) => Promise<void>;
2
+ type Task = (db: Db) => Promise<void>;
3
3
  type Timezone = 'UTC' | 'America/New_York' | 'America/Los_Angeles' | 'America/Argentina/Buenos_Aires' | 'America/Sao_Paulo' | 'Europe/London' | 'Europe/Madrid' | 'Africa/Johannesburg' | 'Asia/Tokyo' | 'Australia/Sydney';
4
4
  type ScheduleConfig = {
5
5
  expression: string;
6
- taskFn: TaskFn;
7
- timezone?: Timezone;
6
+ timezone: Timezone;
7
+ task: Task;
8
8
  runOnInit?: boolean;
9
9
  };
10
10
  export declare abstract class Job {
@@ -8,14 +8,14 @@ const node_cron_1 = __importDefault(require("node-cron"));
8
8
  const database_1 = require("../database");
9
9
  class Job {
10
10
  static Schedule(config) {
11
- const { expression, taskFn, timezone = 'UTC', runOnInit = false } = config;
12
- node_cron_1.default.schedule(expression, () => this.__Run(taskFn), { timezone, runOnInit });
11
+ const { expression, timezone, task, runOnInit = false } = config;
12
+ node_cron_1.default.schedule(expression, () => this.__Run(task), { timezone, runOnInit });
13
13
  }
14
- static async __Run(taskFn) {
14
+ static async __Run(task) {
15
15
  const tx = await (0, database_1.getDbClient)().transaction();
16
16
  const db = new database_1.Db(tx);
17
17
  try {
18
- await taskFn(db);
18
+ await task(db);
19
19
  await tx.commit();
20
20
  }
21
21
  catch (err) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pangea-server",
3
3
  "description": "",
4
- "version": "3.3.0",
4
+ "version": "3.3.1",
5
5
  "files": [
6
6
  "dist"
7
7
  ],