# firebase-cron

> Store and run cron jobs with firebase.

Latest version **1.0.1** (published 2018-05-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install firebase-cron
pnpm add firebase-cron
yarn add firebase-cron
bun add firebase-cron
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2018-05-17 |
| First published | 2016-01-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 2 |
| Unpacked size | 12 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 49 |
| Author | Brian Woodward |
| Maintainers | doowb |
| Keywords | cron, firebase, firebase-cron, firebase-queue, queue, schedule, scheduled |

## Links

- npm: https://www.npmjs.com/package/firebase-cron
- Repository: https://github.com/doowb/firebase-cron
- Issues: https://github.com/doowb/firebase-cron/issues
- npm.io page: https://npm.io/package/firebase-cron

## Dependencies (2)

- [moment](https://npm.io/package/moment.md) ^2.22.1
- [cron-parser](https://npm.io/package/cron-parser.md) ^2.5.0

## Alternatives

- [cron](https://npm.io/package/cron.md) — 4.9M weekly downloads
- [@vercel/queue](https://npm.io/package/@vercel/queue.md) — 731.6K weekly downloads
- [create-sonicjs](https://npm.io/package/create-sonicjs.md) — 1.6K weekly downloads
- [@exellix/jobs-api](https://npm.io/package/@exellix/jobs-api.md) — 941 weekly downloads
- [@forwardimpact/libskill](https://npm.io/package/@forwardimpact/libskill.md) — 575 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2018-05-17
- 1.0.0 — 2018-05-17
- 0.1.2 — 2016-01-06
- 0.1.1 — 2016-01-01
- 0.1.0 — 2016-01-01

## 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

---
_Source: https://npm.io/package/firebase-cron · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
