GithubHelp home page GithubHelp logo

umairx97 / cronify Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 159 KB

Making Cron Simple - uses node-cron under the hood

Home Page: https://www.npmjs.com/package/cronify

License: MIT License

JavaScript 100.00%

cronify's Introduction

Cronify

Making Cron Simple - uses node-cron under the hood

npm

npm install cronify

yarn

yarn add cronify

๐Ÿš€ Examples

Checkout the examples to see the Cronify API in action.

๐Ÿ’ก API

cronify(params, opts<optional>, fn, fnArgs)

const cron = require('cronify')

// simple node-cron as you like it
cron.cronify('*/1 * * * * *', console.log, 'hello') // without options

// with options 
cron.cronify(
  '*/1 * * * * *', 
  { timezone: "America/Sao_Paulo" },
  console.log, 
  'hello'
) 

everySecond(opts<optional>, fn, fnArgs)

const cron = require('cronify')

// without options
cron.everySecond(console.log, 'hello') 

// with options
cron.everySecond({ timezone: "America/Sao_Paulo" }, console.log, 'hello')

everyNthSecond(seconds, opts<optional> fn, fnArgs)

const cron = require('cronify')

// without options - this will log hello world every 2 seconds
cron.everyNthSecond(2, console.log, 'hello', 'world')

// with options - this will log hello world every 2 seconds
cron.everyNthSecond(2, { timezone: "America/Sao_Paulo" } console.log, 'hello', 'world')

everyMinute(opts<optional>, fn, fnArgs)

const cron = require('cronify')

// without options
cron.everyMinute(console.log, 'hello') 

// with options
cron.everyMinute({ timezone: "America/Sao_Paulo" }, console.log, 'hello')

everyNthMinute(minutes, opts<optional>, fn, fnArgs)

const cron = require('cronify')

// without options - this will log hello world every 2 minutes
cron.everyNthMinute(2, console.log, 'hello', 'world')

// with options - this will log hello world every 2 minutes
cron.everyNthMinute(2, { timezone: "America/Sao_Paulo" } console.log, 'hello', 'world')

everyHour(opts<optional>, fn, fnArgs)

const cron = require('cronify')

// without options
cron.everyHour(console.log, 'hello') 

// with options
cron.everyHour({ timezone: "America/Sao_Paulo" }, console.log, 'hello')

everyNthHour(hours, opts<optional>, fn, fnArgs)

const cron = require('cronify')

// without options - this will log hello world every 2 hours
cron.everyNthHour(2, console.log, 'hello', 'world')

// with options - this will log hello world every 2 hours
cron.everyNthHour(2, { timezone: "America/Sao_Paulo" } console.log, 'hello', 'world')

at(period, opts<optional>, fn, fnArgs)

const cron = require('cronify')

/*
  period = 'daily' | 'weekly' | 'monthly'
  at
  time = hh:mm
  cron.at("period" at "time", opts<optional>, function, ...functionArgs)
  without options - this will start the job daily at 5Am BUT you need to have 
  some measure to stop the job on your own schedule See examples/at.js
*/
cron.at('daily at 5:00', console.log, 'hello', 'world')

// with options 
cron.at('daily at 5:00', { timezone: "America/Sao_Paulo" }, console.log, 'hello', 'world')

cronify's People

Contributors

umairx97 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

amanymous

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.