Skip to content

Commit

Permalink
Move bull-board to use mono-repo structure (#281)
Browse files Browse the repository at this point in the history
* Reformat the code when semicolons enabled

* Start of mono-repo refactor

* Finish initial implementation of mono-repo mode

* Add example with-express

* Change author

* Update express examples

* fix api path

* Add fastify adapter

* Add fastify example

* Add hapi adapter

* Add hapi example

* Change readmes

* Update main README.md

* Fix blurry fonts

(cherry picked from commit f1d9b04)

* Reformat theme.css

* Remove eslint-plugin-prettier since it formats differently then prettier it self

(cherry picked from commit ce93b4c)

* Cleanup package.json

* Change prettier config

* Fix lint

* Cleanup root

* chore(deps): bump dns-packet from 1.3.1 to 1.3.4 (#279)

Bumps [dns-packet](https://github.com/mafintosh/dns-packet) from 1.3.1 to 1.3.4.
- [Release notes](https://github.com/mafintosh/dns-packet/releases)
- [Changelog](https://github.com/mafintosh/dns-packet/blob/master/CHANGELOG.md)
- [Commits](mafintosh/dns-packet@v1.3.1...v1.3.4)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Felix Mosheev <[email protected]>
(cherry picked from commit efdbd4c)

* Add release-it-yarn-workspaces

* Drop support for node 10

* feat: add addQueue and removeQueue methods (#278)

* feat: add addQueue and removeQueue methods.

Co-authored-by: Felix Mosheev <[email protected]>

(cherry picked from commit c4b6763)

* Fix tests
Move to use mock of ioredis instead of dockest

* Reformat the code

* Update lock

* Change to ci env

* Change install command

* Switch build & tests

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Eric Hayes <[email protected]>
  • Loading branch information
3 people authored May 29, 2021
1 parent efdbd4c commit 9631a12
Show file tree
Hide file tree
Showing 160 changed files with 7,783 additions and 2,152 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node: [ '10.x', '12.x', '14.x' ]
node: [ '12.x', '14.x' ]
os: [ubuntu-latest]

steps:
Expand All @@ -25,12 +25,18 @@ jobs:

- name: Install deps and build (with cache)
uses: bahmutov/npm-install@v1
with:
install-command: yarn --frozen-lockfile --silent

- name: Lint
run: yarn lint

- name: Test
run: yarn test --ci --coverage --maxWorkers=2

- name: Build
run: yarn build
env:
CI: true

- name: Test
run: yarn test
env:
CI: true
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
node_modules/
static/

dist
yarn-error.log
*.rdb
Expand Down
94 changes: 57 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ With this library you get a beautiful UI for visualizing what's happening with e
</a>
<p>

![UI](https://raw.githubusercontent.com/vcapretz/bull-board/master/shot.png)
![Fails](https://raw.githubusercontent.com/vcapretz/bull-board/master/fails.png)
![UI](https://raw.githubusercontent.com/felixmosh/bull-board/master/screenshots/shot.png)
![Fails](https://raw.githubusercontent.com/felixmosh/bull-board/master/screenshots/fails.png)

## Notes

Expand All @@ -34,13 +34,21 @@ If you want to learn more about queues and Redis: https://redis.io/.
To add it to your project start by adding the library to your dependencies list:

```sh
yarn add bull-board
yarn add @bull-board/express
# or
yarn add @bull-board/fastify
# or
yarn add @bull-board/hapi
```

Or

```sh
npm i bull-board
npm i @bull-board/express
# or
npm i @bull-board/fastify
# or
npm i @bull-board/hapi
```

## Hello World
Expand All @@ -51,23 +59,30 @@ The first step is to setup `bull-board` by calling `createBullBoard` method.
const express = require('express')
const Queue = require('bull')
const QueueMQ = require('bullmq')
const { createBullBoard } = require('bull-board')
const { BullAdapter } = require('bull-board/bullAdapter')
const { BullMQAdapter } = require('bull-board/bullMQAdapter')
const { createBullBoard } = require('@bull-board/api')
const { BullAdapter } = require('@bull-board/api/bullAdapter')
const { BullMQAdapter } = require('@bull-board/api/bullMQAdapter')
const { ExpressAdapter } = require('@bull-board/express')

const someQueue = new Queue('someQueueName')
const someOtherQueue = new Queue('someOtherQueueName')
const queueMQ = new QueueMQ('queueMQName')

const { router, setQueues, replaceQueues, addQueue, removeQueue } = createBullBoard([
new BullAdapter(someQueue),
new BullAdapter(someOtherQueue),
new BullMQAdapter(queueMQ),
])
const serverAdapter = new ExpressAdapter();

const { addQueue, removeQueue, setQueues, replaceQueues } = createBullBoard({
queues: [
new BullAdapter(someQueue),
new BullAdapter(someOtherQueue),
new BullMQAdapter(queueMQ),
],
serverAdapter:serverAdapter
})

const app = express()

app.use('/admin/queues', router)
serverAdapter.setBasePath('/admin/queues')
app.use('/admin/queues', serverAdapter.getRouter());

// other configurations of your server
```
Expand All @@ -78,26 +93,30 @@ That's it! Now you can access the `/admin/queues` route, and you will be able to
For more advanced usages check the `examples` folder, currently it contains:
1. [Basic authentication example](https://github.com/felixmosh/bull-board/tree/master/examples/with-auth)
2. [Multiple instance of the board](https://github.com/felixmosh/bull-board/tree/master/examples/with-multiple-instances)
2. [With Fastify server](https://github.com/felixmosh/bull-board/tree/master/examples/with-fastify)
2. [With Hapi.js server](https://github.com/felixmosh/bull-board/tree/master/examples/with-hapi)
### Queue options
1. `readOnlyMode` (default: `false`)
Makes the UI as read only, hides all queue & job related actions

```js
const Queue = require('bull')
const QueueMQ = require('bullmq')
const { setQueues } = require('bull-board')
const { BullMQAdapter } = require('bull-board/bullMQAdapter')
const { BullAdapter } = require('bull-board/bullAdapter')
const { createBullBoard } = require('@bull-board/api')
const { BullMQAdapter } = require('@bull-board/api/bullMQAdapter')
const { BullAdapter } = require('@bull-board/api/bullAdapter')

const someQueue = new Queue()
const someOtherQueue = new Queue()
const queueMQ = new QueueMQ()

const { router, setQueues, replaceQueues } = createBullBoard([
new BullAdapter(someQueue, { readOnlyMode: true }), // only this queue will be in read only mode
new BullAdapter(someOtherQueue),
new BullMQAdapter(queueMQ, { readOnlyMode: true }),
])
const { setQueues, replaceQueues } = createBullBoard({
queues: [
new BullAdapter(someQueue, { readOnlyMode: true }), // only this queue will be in read only mode
new BullAdapter(someOtherQueue),
new BullMQAdapter(queueMQ, { readOnlyMode: true }),
]
})
```

### Hosting router on a sub path
Expand All @@ -106,26 +125,27 @@ If you host your express service on a different path than root (/) ie. https://<

```js
const Queue = require('bull')
const { createBullBoard } = require('bull-board')
const { BullAdapter } = require('bull-board/bullAdapter')
const { createBullBoard } = require('@bull-board/api')
const { BullAdapter } = require('@bull-board/api/bullAdapter')
const { ExpressAdapter } = require('@bull-board/express')

const someQueue = new Queue('someQueueName')

const { router } = createBullBoard([
new BullAdapter(someQueue),
])
const serverAdapter = new ExpressAdapter();

const { router } = createBullBoard({
queues: [
new BullAdapter(someQueue),
],
serverAdapter
})

// ... express server configuration

let basePath = 'my-base-path';
const basePath = 'my-base-path';
serverAdapter.setBasePath(basePath)

app.use(
'/queues',
(req, res, next) => {
req.proxyUrl = basePath + '/queues';
next();
},
router);
app.use('/queues', serverAdapter.getRouter());
```

You will then find the bull-board UI at the following address `https://<server_name>/my-base-path/queues`.
Expand All @@ -134,11 +154,11 @@ You will then find the bull-board UI at the following address `https://<server_n

First, thank you for being interested in helping out, your time is always appreciated in every way. 💯

Remember to read the [Code of Conduct](https://github.com/vcapretz/bull-board/blob/master/CODE_OF_CONDUCT.md) so you also help maintaining a good Open source community around this project!
Remember to read the [Code of Conduct](https://github.com/felixmosh/bull-board/blob/master/CODE_OF_CONDUCT.md) so you also help maintaining a good Open source community around this project!

Here are some tips:

- Check the [issues page](https://github.com/vcapretz/bull-board/issues) for already opened issues (or maybe even closed ones) that might already address your question/bug/feature request.
- Check the [issues page](https://github.com/felixmosh/bull-board/issues) for already opened issues (or maybe even closed ones) that might already address your question/bug/feature request.
- When opening a bug report provide as much information as you can, some things might be useful for helping debugging and understading the problem
- Node, Redis, Bull, bull-board versions
- Sample code that reproduces the problem
Expand Down Expand Up @@ -180,4 +200,4 @@ yarn && yarn start:dev

# License

This project is licensed under the [MIT License](https://github.com/vcapretz/bull-board/blob/master/LICENSE), so it means it's completely free to use and copy, but if you do fork this project with nice additions that we could have here, remember to send a PR 👍
This project is licensed under the [MIT License](https://github.com/felixmosh/bull-board/blob/master/LICENSE), so it means it's completely free to use and copy, but if you do fork this project with nice additions that we could have here, remember to send a PR 👍
8 changes: 0 additions & 8 deletions docker-compose.yml

This file was deleted.

20 changes: 12 additions & 8 deletions example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import * as Bull from 'bull';
import Queue3 from 'bull';
import { Queue as QueueMQ, QueueScheduler, Worker } from 'bullmq';
import express from 'express';
import { createBullBoard } from './src';
import { BullAdapter } from './src/queueAdapters/bull';
import { BullMQAdapter } from './src/queueAdapters/bullMQ';
import { BullMQAdapter } from '@bull-board/api/dist/queueAdapters/bullMQ';
import { BullAdapter } from '@bull-board/api/dist/queueAdapters/bull';
import { createBullBoard } from '@bull-board/api';
import { ExpressAdapter } from '@bull-board/express';

const redisOptions = {
port: 6379,
Expand Down Expand Up @@ -76,12 +77,15 @@ const run = async () => {
});
});

const { router: bullBoardRouter } = createBullBoard([
new BullMQAdapter(exampleBullMq),
new BullAdapter(exampleBull),
]);
const serverAdapter = new ExpressAdapter();
serverAdapter.setBasePath('/ui');

app.use('/ui', bullBoardRouter);
createBullBoard({
queues: [new BullMQAdapter(exampleBullMq), new BullAdapter(exampleBull)],
serverAdapter,
});

app.use('/ui', serverAdapter.getRouter());

app.listen(3000, () => {
console.log('Running on 3000...');
Expand Down
File renamed without changes.
Loading

0 comments on commit 9631a12

Please sign in to comment.