@nestjs/schedule
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -21,2 +21,7 @@ /** | ||
unrefTimeout?: boolean; | ||
/** | ||
* This flag indicates whether the job will be executed at all. | ||
* @default false | ||
*/ | ||
disabled?: boolean; | ||
} | ||
@@ -23,0 +28,0 @@ /** |
@@ -56,3 +56,3 @@ export declare enum CronExpression { | ||
EVERY_6_MONTHS = "0 0 1 */6 *", | ||
EVERY_YEAR = "0 0 1 1 *", | ||
EVERY_YEAR = "0 0 1 0 *", | ||
EVERY_30_MINUTES_BETWEEN_9AM_AND_5PM = "0 */30 9-17 * * *", | ||
@@ -59,0 +59,0 @@ EVERY_30_MINUTES_BETWEEN_9AM_AND_6PM = "0 */30 9-18 * * *", |
@@ -60,3 +60,3 @@ "use strict"; | ||
CronExpression["EVERY_6_MONTHS"] = "0 0 1 */6 *"; | ||
CronExpression["EVERY_YEAR"] = "0 0 1 1 *"; | ||
CronExpression["EVERY_YEAR"] = "0 0 1 0 *"; | ||
CronExpression["EVERY_30_MINUTES_BETWEEN_9AM_AND_5PM"] = "0 */30 9-17 * * *"; | ||
@@ -63,0 +63,0 @@ CronExpression["EVERY_30_MINUTES_BETWEEN_9AM_AND_6PM"] = "0 */30 9-18 * * *"; |
@@ -56,2 +56,5 @@ "use strict"; | ||
const { options, target } = this.cronJobs[key]; | ||
if (options.disabled) { | ||
return; | ||
} | ||
const cronJob = new cron_1.CronJob(options.cronTime, target, undefined, false, options.timeZone, undefined, false, options.utcOffset, options.unrefTimeout); | ||
@@ -58,0 +61,0 @@ cronJob.start(); |
import { CronJob } from 'cron'; | ||
export declare class SchedulerRegistry { | ||
private readonly logger; | ||
private readonly cronJobs; | ||
@@ -23,2 +24,3 @@ private readonly timeouts; | ||
deleteTimeout(name: string): void; | ||
private wrapFunctionInTryCatchBlocks; | ||
} |
@@ -8,2 +8,12 @@ "use strict"; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var SchedulerRegistry_1; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -13,4 +23,5 @@ exports.SchedulerRegistry = void 0; | ||
const schedule_messages_1 = require("./schedule.messages"); | ||
let SchedulerRegistry = class SchedulerRegistry { | ||
let SchedulerRegistry = SchedulerRegistry_1 = class SchedulerRegistry { | ||
constructor() { | ||
this.logger = new common_1.Logger(SchedulerRegistry_1.name); | ||
this.cronJobs = new Map(); | ||
@@ -63,2 +74,3 @@ this.timeouts = new Map(); | ||
} | ||
job.fireOnTick = this.wrapFunctionInTryCatchBlocks(job.fireOnTick, job); | ||
this.cronJobs.set(name, job); | ||
@@ -104,6 +116,16 @@ } | ||
} | ||
wrapFunctionInTryCatchBlocks(methodRef, instance) { | ||
return (...args) => __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
yield methodRef.call(instance, ...args); | ||
} | ||
catch (error) { | ||
this.logger.error(error); | ||
} | ||
}); | ||
} | ||
}; | ||
SchedulerRegistry = __decorate([ | ||
SchedulerRegistry = SchedulerRegistry_1 = __decorate([ | ||
(0, common_1.Injectable)() | ||
], SchedulerRegistry); | ||
exports.SchedulerRegistry = SchedulerRegistry; |
{ | ||
"name": "@nestjs/schedule", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "Nest - modern, fast, powerful node.js web framework (@schedule)", | ||
@@ -21,33 +21,33 @@ "author": "Kamil Mysliwiec", | ||
"dependencies": { | ||
"cron": "2.0.0", | ||
"uuid": "8.3.2" | ||
"cron": "2.2.0", | ||
"uuid": "9.0.0" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/cli": "17.0.3", | ||
"@commitlint/config-angular": "17.0.3", | ||
"@nestjs/common": "9.0.1", | ||
"@nestjs/core": "9.0.1", | ||
"@nestjs/platform-express": "9.0.1", | ||
"@nestjs/testing": "9.0.1", | ||
"@commitlint/cli": "17.4.2", | ||
"@commitlint/config-angular": "17.4.2", | ||
"@nestjs/common": "9.3.2", | ||
"@nestjs/core": "9.3.2", | ||
"@nestjs/platform-express": "9.3.2", | ||
"@nestjs/testing": "9.3.2", | ||
"@types/cron": "2.0.0", | ||
"@types/jest": "28.1.4", | ||
"@types/node": "17.0.35", | ||
"@types/sinon": "10.0.12", | ||
"@types/uuid": "8.3.4", | ||
"@typescript-eslint/eslint-plugin": "5.30.5", | ||
"@typescript-eslint/parser": "5.30.5", | ||
"eslint": "8.19.0", | ||
"eslint-config-prettier": "8.5.0", | ||
"eslint-plugin-import": "2.26.0", | ||
"husky": "8.0.1", | ||
"jest": "28.1.2", | ||
"lint-staged": "13.0.3", | ||
"prettier": "2.7.1", | ||
"@types/jest": "29.4.0", | ||
"@types/node": "18.11.18", | ||
"@types/sinon": "10.0.13", | ||
"@types/uuid": "9.0.0", | ||
"@typescript-eslint/eslint-plugin": "5.50.0", | ||
"@typescript-eslint/parser": "5.50.0", | ||
"eslint": "8.33.0", | ||
"eslint-config-prettier": "8.6.0", | ||
"eslint-plugin-import": "2.27.5", | ||
"husky": "8.0.3", | ||
"jest": "29.4.1", | ||
"lint-staged": "13.1.0", | ||
"prettier": "2.8.3", | ||
"reflect-metadata": "0.1.13", | ||
"release-it": "15.1.1", | ||
"rimraf": "3.0.2", | ||
"rxjs": "7.5.5", | ||
"sinon": "14.0.0", | ||
"ts-jest": "28.0.5", | ||
"typescript": "4.7.4" | ||
"release-it": "15.6.0", | ||
"rimraf": "4.1.2", | ||
"rxjs": "7.8.0", | ||
"sinon": "15.0.1", | ||
"ts-jest": "29.0.5", | ||
"typescript": "4.9.5" | ||
}, | ||
@@ -54,0 +54,0 @@ "peerDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47800
876
+ Addedcron@2.2.0(transitive)
+ Addedluxon@3.5.0(transitive)
+ Addeduuid@9.0.0(transitive)
- Removedcron@2.0.0(transitive)
- Removedluxon@1.28.1(transitive)
- Removeduuid@8.3.2(transitive)
Updatedcron@2.2.0
Updateduuid@9.0.0