thezakman / firebase-cron

Store and run cron jobs with firebase.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

firebase-cron NPM version

Store and run cron jobs with firebase.

Install

Install with npm

$ npm i firebase-cron --save

Usage

var Cron = require('firebase-cron');

API

Main Cron class for creating a new instance to manage cron jobs.

Params

  • ref {Object}: Instance of a firebase reference pointing to the root of a firebase.
  • queue {Object}: Instance of a firebase refernece pointing to a firebase-queue.
  • options {Object}: Options specifying where the cron jobs are stored.
  • options.endpoint {String}: Specific endpoint relative to the ref where the cron jobs are stored (defaults to jobs.

Example

var Firebase = require('firebase');
var ref = new Firebase('https://{your-firebase}.firebaseio.com');
var queueRef = new Firebase('https://{your-firebase}.firebaseio.com/queue');
var options = {endpoint: 'jobs'};

var cron = new Cron(ref, queueRef, options);

Add a new cron job.

Params

  • name {String}: Name of the cron job.
  • pattern {String}: Cron job pattern. See cron job patterns for specifics.
  • data {Object}: Data to be pushed onto the firebase-queue when job is run.
  • cb {Function}: Callback function that is called after the job is added to the database.

Update a cron job.

Params

  • name {String}: Name of the cron job.
  • pattern {String}: Cron job pattern. See cron job patterns for specifics.
  • data {Object}: Data to be pushed onto the firebase-queue when job is run.
  • cb {Function}: Callback function that is called after the job is updated in the database.

Remove a cron job.

Params

  • name {String}: Name of the cron job.
  • cb {Function}: Callback function that is called after the job is removed from the database.

Get a cron job.

Params

  • name {String}: Name of the cron job.
  • cb {Function}: Callback function that is called with any errors or the job.

Get all of the cron jobs.

Params

  • cb {Function}: Callback function that is called retrieving all of the jobs.

Get all of the scheduled/waiting jobs.

Params

  • cb {Function}: Callback function that is called after retrieveing all of the waiting jobs.

Start running the cron manager.

Params

  • cb {Function}: Callback function that is called each time manager checks for jobs to run.
  • error {Function}: Callback function that is called if an error occurrs.

Related projects

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Author

Brian Woodward

License

Copyright © 2016 Brian Woodward Released under the MIT license.


This file was generated by verb on January 01, 2016.

About

Store and run cron jobs with firebase.

License:MIT License


Languages

Language:JavaScript 100.0%