Gathering detailed insights and metrics for hapi-cron-job
Gathering detailed insights and metrics for hapi-cron-job
Gathering detailed insights and metrics for hapi-cron-job
Gathering detailed insights and metrics for hapi-cron-job
npm install hapi-cron-job
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
5 Stars
26 Commits
8 Forks
2 Watching
3 Branches
3 Contributors
Updated on 25 Apr 2023
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
0%
6
Compared to previous day
Last week
60%
16
Compared to previous week
Last month
0%
50
Compared to previous month
Last year
-23.5%
1,234
Compared to previous year
hapi-cron-job, is a plugin for hapi that will allows you to execute cron job at a specified time (eg: every 2 hour, at 8:00 pm, every monday at 11:00 am, every first day of the month).
Using npm:
npm install hapi-cron-job
var displayTime = function(){
var ymd = new Date().toISOString().slice(0,new Date().toISOString().indexOf("T"));
var hms = new Date().toISOString().substr(11, 8);
console.log(ymd+" "+hms);
};
var callback = function(enabledJobs){
//Do something with enabledJobs
}
var enabledCallback = function(job, scheduleParsed){
//Do something with job and scheduleParsed
}
Server.register({
register:require('hapi-cron-job'),
options:{
jobs:[
{
name:"diplay time",
enabled:true,
enabledCallback:enabledCallback,//Executed at end of import of the job, just before immediate Callback
immediate:true,//Will execute function on starting
schedule:"every 1 s",
execute:displayTime,
environments:['development','staging']//using env (process.env.NODE_ENV)
}
],
callback:callback//Executed at end of process and return enabledJobs
}
},function(err){
if(err){throw err;}
});
jobs
: An array of jobs
name
: (String) Name of your cron jobenabled
: (Bool) Do we want to enable our cron jobenabledCallback
: (Function, optional) Function to execute at end of import of the job, before call (if immediate is true)schedule
: (String) See allowed Schedule, example or use.execute
: (Function) Function to execute at scheduleimmediate
: (Bool, optional, default:false)environments
:(Array(String), optional) Use process.env.NODE_ENV to set your environments. If no environments set consider as active.localTime
: (default: true, optional), If false, use GMT Zone(UTC Time) instead of local server time (local Zone)callback
: (optional), A callback function that will be executed at the end of the import process, {return: enabledJobs(Array)}You can specify any schedule format that look like :
at 01:00 pm
, 01:00 am
, 1:00am
etc... (will be called daily at specified time).at 15:00
every 1 hour
, every 1 hours
, every 1 h
. (Works with seconds, minutes, hours, days)every plain hour
, every plain minutes
. (Works with min, hours)Mind that every X PERIOD, is absolute, if you started your server at 10:44 pm and set to every 1 h, it will be executed at 11:44pm, 0:44am and so on...
You can have your cron executed at the next plain hour and every next hour then.
Use every plain hour
for that. (eg:If started at 3:46, next exec will be 4:00 then 5:00...)
Same can be done with minutes with every plain minute
(eg: Started at 3:46, next exec will be 3:50,4:00,..)
s
, m
, h
, d
, seconds
, second
, ....1
, 2
, ...8:00 pm
, 08:00 pm
first
, second
, thenth
,... after NUMBER PERIOD
every DAYS at TIMES
every PERIOD on the ORDINALNUMBER PERIOD of the PERIOD
eg : every minutes on the first day of the month
every ORDINALNUMBER PERIOD of PERIOD
every first day of the month
If this can help even one person, I would be hapi enough (see what I did here ? :D).
I will work on that project till I will be confident enought that it will answer perfectly to the need to at least one person.
If you are that person, please, do not hesitate to :
You could also drop me a word on twitter : @obusco.
I would like to have any feedback that you use it, may be even for what and how I could help improving this package to fit your needs.
Releases will be numbered with the following format (semver):
<major>.<minor>.<patch>
The reason we doing that, is that, far from marketing or stuff. You will know easily if a breaking change occurs by just looking the first number. Mind that some major version (breaking changes) can be absolutely necessary (bugfix). But at least it won't break your code
I want to take time to thank :
Much love to you ! <3
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 2/23 approved changesets -- 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
Score
Last Scanned on 2024-11-25
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