# strapi-plugin-bull

> [![Build Status](https://travis.ibm.com/ETX/strapi-plugin-bull.svg?token=GMH4xFrA9iezVJKqw2zH&branch=master)](https://travis.ibm.com/ETX/strapi-plugin-bull)

Latest version **0.1.0** (published 2020-01-31) · UNLICENSED license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install strapi-plugin-bull
pnpm add strapi-plugin-bull
yarn add strapi-plugin-bull
bun add strapi-plugin-bull
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2020-01-31 |
| First published | 2020-01-31 |
| Weekly downloads | 0 |
| License | UNLICENSED |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10.0.0 |
| Dependencies | 5 |
| Unpacked size | 24.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jesus Rubio |
| Maintainers | tanzaku |

## Links

- npm: https://www.npmjs.com/package/strapi-plugin-bull
- npm.io page: https://npm.io/package/strapi-plugin-bull

## Dependencies (5)

- [bull](https://npm.io/package/bull.md) ^3.12.1
- [pino](https://npm.io/package/pino.md) ^5.16.0
- [mongodb](https://npm.io/package/mongodb.md) ^3.5.2
- [slack-notify](https://npm.io/package/slack-notify.md) ^0.1.7
- [redis-url-parse](https://npm.io/package/redis-url-parse.md) ^2.0.0

## Recent versions

- 0.1.0 (latest) — 2020-01-31

## README

# strapi-plugin-bull

[![Build Status](https://travis.ibm.com/ETX/strapi-plugin-bull.svg?token=GMH4xFrA9iezVJKqw2zH&branch=master)](https://travis.ibm.com/ETX/strapi-plugin-bull)

:construction_worker: [Strapi](http://strapi.io) plugin to support background jobs thanks to the [bull](https://optimalbits.github.io/bull) the queue engine.

- Simpe, thought for prototyping.
- Generic enough to support different kind of applications.
- GraphQL.
- Job inputs, results and metadata storage in MongoDB.
- Jobs info download in JSON format.
- Worker implementation helper.
  - Databases and query connections management.
  - Job status update.
  - Bug reporting to Slack.

Once the plugin is added to your application a new collection `Jobs` (`jobs_Job` in the database) will appear and a new plugin with the same name.

![Strapi panel](https://i.ibb.co/Ny1PbJr/strapi-jobs.png)

Collection fields

![job fields](https://i.ibb.co/b76JFQx/fields.png)

To learn about Strapi plugins you can visit [the official documentation](https://strapi.io/documentation/concepts/plugins.html).

**Note**: This component is in `beta` (v0.x.x), so please check the [CHANGELOG](CHANGELOG.md) to learn about any change in your code.

## Install & use

:pizza: Inside a project folder.

```sh
npm i --save strapi-plugin-bull
npm i --save-dev axios # temporal workaround
npm run build
```

### Environment

The plugin rely on external services, so it expects to find the next environment variables.

- `DATABASE_URI`: MongoDB URI, as the main database engine. For now we don't support the Strapi in-memory provider (useful to develop).
- `QUEUE_URI`: The queue (Redis) connection string for the queue.

#### DB setup

A new model `Job` is included, so you need to add the next entry in your `User.settings.json`.

```json
"jobs": {
  "collection": "job",
  "via": "owner",
  "plugin": "users-permissions"
}
```

#### Input checks

Any object is supported as `input`.

Optionally, you can define a global policy to check the `input` field of the jobs. The file needs to be called `isValid.js`. In example:

```js
module.exports = async (ctx, next) => {
  const { input } = ctx.request.body; // marked as required

  // TODO: Add to the doc.
  if (!input.myField1 || !input.myField2) {
    return ctx.throw(400);
  }

  if (typeof input.myField1 !== 'string' || typeof input.myField2 !== 'string') {
    return ctx.throw(400);
  }

  return next();
};
```

### Worker

The use of this plugin implies the need of a worker to resolve the jobs put in the queue by this HTTP API. It should also write the result directly into the database.

It uses to be very attached to each project, so we provide [this helper](worker) to make the things easier.

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