Skip to content

Commit

Permalink
Merge pull request #3 from githubjakob/base-path
Browse files Browse the repository at this point in the history
Add BASE_PATH environment variable
  • Loading branch information
Deadly0 authored Jan 14, 2021
2 parents 4fe6759 + 04d2d8c commit 1ee30c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ see "Example with docker-compose" section for example with env parameters
* `REDIS_USE_TLS` - enable TLS true or false (false by default)
* `REDIS_PASSWORD` - password to connect to redis (no password by default)
* `BULL_PREFIX` - prefix to your bull queue name (bull by default)
* `BASE_PATH` - basePath for bull board, e.g. '/bull-board' ('/' by default)

### Example with docker-compose
```
Expand Down
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const {
REDIS_PASSWORD,
REDIS_USE_TLS,
BULL_PREFIX = 'bull',
PORT = 3000
PORT = 3000,
BASE_PATH = '/'
} = process.env;

const redisConfig = {
Expand All @@ -24,6 +25,7 @@ const redisConfig = {
const client = redis.createClient(redisConfig.redis);
const prefix = BULL_PREFIX;
const port = PORT;
const basePath = BASE_PATH;

client.KEYS(`${prefix}:*`, (err, keys) => {
const uniqKeys = new Set(keys.map(key => key.replace(/^.+?:(.+?):.+?$/, '$1')));
Expand All @@ -34,7 +36,7 @@ client.KEYS(`${prefix}:*`, (err, keys) => {

const app = express();

app.use('/', router);
app.use(`${basePath}`, router);
app.listen(port, () => {
console.log(`bull-board listening on port ${port}!`);
console.log(`bull-board listening on port ${port} on basePath "${basePath}"!`);
});

0 comments on commit 1ee30c0

Please sign in to comment.