Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/doowb/firebase-cron
Store and run cron jobs with firebase.
https://github.com/doowb/firebase-cron
cron firebase firebase-cron firebase-queue
Last synced: 23 days ago
JSON representation
Store and run cron jobs with firebase.
- Host: GitHub
- URL: https://github.com/doowb/firebase-cron
- Owner: doowb
- License: mit
- Created: 2016-01-01T18:07:53.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-05-17T14:42:28.000Z (over 6 years ago)
- Last Synced: 2024-10-04T12:14:17.728Z (about 1 month ago)
- Topics: cron, firebase, firebase-cron, firebase-queue
- Language: JavaScript
- Size: 23.4 KB
- Stars: 50
- Watchers: 6
- Forks: 3
- Open Issues: 6
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# firebase-cron [![NPM version](https://img.shields.io/npm/v/firebase-cron.svg?style=flat)](https://www.npmjs.com/package/firebase-cron)
> Store and run cron jobs with firebase.
## Install
Install with [npm](https://www.npmjs.com/):```sh
$ npm install --save firebase-cron
```## Usage
```js
var Cron = require('firebase-cron');
```## API
### [Cron](index.js#L33)
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`).
* `options.interval` **{Number}**: Optional interval in milliseconds to use when calling `.run` (defaults to 1000).**Example**
```js
const Firebase = require('firebase');
const ref = new Firebase('https://{your-firebase}.firebaseio.com');
const queueRef = new Firebase('https://{your-firebase}.firebaseio.com/queue');
const options = {endpoint: 'jobs'};const cron = new Cron(ref, queueRef, options);
```### [.addJob](index.js#L73)
Add a new cron job.
**Params**
* `name` **{String}**: Name of the cron job.
* `pattern` **{String}**: Cron job pattern. See [cron job patterns](http://crontab.org/) for specifics.
* `data` **{Object}**: Data to be pushed onto the [firebase-queue][] when job is run.
* `returns` **{Promise}**: Returns a promise that is resolved when the job has been updated.### [.updateJob](index.js#L93)
Update a cron job.
**Params**
* `name` **{String}**: Name of the cron job.
* `pattern` **{String}**: Cron job pattern. See [cron job patterns](http://crontab.org/) for specifics.
* `data` **{Object}**: Data to be pushed onto the [firebase-queue][] when job is run.
* `returns` **{Promise}**: Returns a promise that is resolved when the job has been added.### [.deleteJob](index.js#L111)
Remove a cron job.
**Params**
* `name` **{String}**: Name of the cron job.
* `returns` **{Promise}**: Returns a promise that is resolved when the job has been removed.### [.getJob](index.js#L123)
Get a cron job.
**Params**
* `name` **{String}**: Name of the cron job.
* `returns` **{Promise}**: Returns a promise that is resolved with the job.### [.getJobs](index.js#L135)
Get all of the cron jobs.
* `returns` **{Promise}**: Returns a promise that is resolved with all of the jobs.
### [.waitingJobs](index.js#L148)
Get all of the scheduled/waiting jobs.
* `returns` **{Promise}**: Returns a promise that is resolved with the waiting jobs.
### [.run](index.js#L163)
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
- [firebase-queue](https://www.npmjs.com/package/firebase-queue): A fault-tolerant, multi-worker, multi-stage job pipeline built on Firebase | [homepage](https://github.com/firebase/firebase-queue "A fault-tolerant, multi-worker, multi-stage job pipeline built on Firebase")
- [firebase](https://www.npmjs.com/package/firebase): Firebase JavaScript library for web and Node.js | [homepage](https://firebase.google.com/ "Firebase JavaScript library for web and Node.js")## Running tests
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:```sh
$ npm install && npm test
```## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).## Author
**Brian Woodward**+ [github/doowb](https://github.com/doowb)
+ [twitter/doowb](https://twitter.com/doowb)## License
Copyright © 2018, [Brian Woodward](https://github.com/doowb).
MIT***
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on May 17, 2018._
[firebase]: https://www.firebase.com/
[firebase-queue]: https://github.com/firebase/firebase-queue