node-cron-management
Version:
Improvement of node-cron package
19 lines (18 loc) • 759 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.cronGroup = exports.GROUP_SYMBOL = void 0;
require("reflect-metadata");
exports.GROUP_SYMBOL = Symbol("group");
/**
* Decorator for the Cron Job class
* @param groupTag 'tag of the group. It is used to uniquely identify this class so that all jobs in the class can be started or stopped using this key
* @returns A class Decorator
*/
function cronGroup(groupTag) {
return function (constructor) {
const groups = Reflect.getMetadata(exports.GROUP_SYMBOL, Reflect) || [];
groups.push({ groupTag, constructor, className: constructor.name });
Reflect.defineMetadata(exports.GROUP_SYMBOL, groups, Reflect);
};
}
exports.cronGroup = cronGroup;