Gathering detailed insights and metrics for @stretchshop/moleculer-cron
Gathering detailed insights and metrics for @stretchshop/moleculer-cron
Gathering detailed insights and metrics for @stretchshop/moleculer-cron
Gathering detailed insights and metrics for @stretchshop/moleculer-cron
npm install @stretchshop/moleculer-cron
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
41 Stars
53 Commits
26 Forks
1 Watchers
6 Branches
6 Contributors
Updated on Jan 07, 2025
Latest Version
0.0.3
Package Id
@stretchshop/moleculer-cron@0.0.3
Unpacked Size
13.43 kB
Size
5.07 kB
File Count
8
NPM Version
7.8.0
Node Version
15.5.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Cron mixin Node-Cron.
Easy to use cron with moleculer!
1$ npm install moleculer-cron --save
Specify all of your cron task inside of the constructor of the addon.
1const Cron = require("moleculer-cron"); 2 3 4broker.createService({ 5 name: "cron-job", 6 7 mixins: [Cron], 8 9 crons: [ 10 { 11 name: "JobHelloWorld", 12 cronTime: '* * * * *', 13 onTick: function() { 14 15 console.log('JobHelloWorld ticked'); 16 17 this.getLocalService("cron-job") 18 .actions.say() 19 .then((data) => { 20 console.log("Oh!", data); 21 }); 22 }, 23 runOnInit: function() { 24 console.log("JobHelloWorld is created"); 25 }, 26 manualStart: true, 27 timeZone: 'America/Nipigon' 28 }, 29 { 30 name: "JobWhoStartAnother", 31 cronTime: '* * * * *', 32 onTick: function() { 33 34 console.log('JobWhoStartAnother ticked'); 35 36 var job = this.getJob("JobHelloWorld"); 37 38 if (!job.lastDate()) { 39 job.start(); 40 } else { 41 console.log("JobHelloWorld is already started!"); 42 } 43 44 }, 45 runOnInit: function() { 46 console.log("JobWhoStartAnother is created"); 47 }, 48 timeZone: 'America/Nipigon' 49 } 50 ], 51 52 actions: { 53 54 say: { 55 handler(ctx) { 56 return "HelloWorld!"; 57 } 58 } 59 60 } 61 62});
Asterisk. E.g. *
Ranges. E.g. 1-3,5
Steps. E.g. */2
Read up on cron patterns here. Note the examples in the link have five fields, and 1 minute as the finest granularity, but this library has six fields, with 1 second as the finest granularity.
When specifying your cron values you'll need to make sure that your values fall within the ranges. For instance, some cron's use a 0-7 range for the day of week where both 0 and 7 represent Sunday. We do not.
Parameter Based
Cron
cronTime
- [REQUIRED] - The time to fire off your job. This can be in the form of cron syntax or a JS Date object.onTick
- [REQUIRED] - The function to fire at the specified time.name
- [OPTIONAL] - Set a name to the job, will be automaticly generated if you don't set itonComplete
- [OPTIONAL] - A function that will fire when the job is complete, when it is stopped.manualStart
- [OPTIONAL] - Specifies whether to start the job just before exiting the constructor. By default this is set to false. If left at default you will need to call job.start()
in order to start the job (assuming job
is the variable you set the cronjob to). This does not immediately fire your onTick
function, it just gives you more control over the behavior of your jobs.timeZone
- [OPTIONAL] - Specify the timezone for the execution. This will modify the actual time relative to your timezone. If the timezone is invalid, an error is thrown. You can check all timezones available at Moment Timezone Website.runOnInit
- [OPTIONAL] - This will be fired on start()
function as soon as the requisit initialization has happened.CronJob
start
- Runs your job.stop
- Stops your job.setTime
- Change the time for the CronJob
. Param must be a CronTime
from getCronTime
.lastDate
- Tells you the last execution date.nextDates
- Provides an array of the next set of dates that will trigger an onTick
.addCallback
- Allows you to add onTick
callbacks.getCronTime(time)
time
- [REQUIRED] - The time to fire off your job. This can be in the form of cron syntax or a JS Date object.No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 2/10 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
36 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More