Skip to content

Commit

Permalink
feat(Queue): add pw to access
Browse files Browse the repository at this point in the history
  • Loading branch information
mikewuu committed Nov 1, 2024
1 parent 5e7a332 commit af085cc
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"date-fns": "^3.6.0",
"date-fns-tz": "^3.1.3",
"eslint-plugin-jest": "^28.2.0",
"express-basic-auth": "^1.2.1",
"framer-motion": "^11.1.9",
"gray-matter": "^4.0.3",
"he": "^1.2.0",
Expand Down
11 changes: 11 additions & 0 deletions queue-dashboard.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import express from 'express'
import basicAuth from 'express-basic-auth'
import { createBullBoard } from '@bull-board/api'
import { BullMQAdapter } from '@bull-board/api/bullMQAdapter'
import { ExpressAdapter } from '@bull-board/express'
import { getQueue } from '@/queue/get-queue'
import { config } from '@/config'
import process from 'node:process'

const serverAdapter = new ExpressAdapter()
serverAdapter.setBasePath('/jobs')

// Add auth to require password for access
const auth = basicAuth({
users: { admin: process.env.QUEUE_DASHBOARD_PASSWORD ?? '' },
challenge: true, // Will show browser prompt
})

createBullBoard({
queues: Object.keys(config.queue.queues).map(
(queue) => new BullMQAdapter(getQueue(queue)),
Expand All @@ -17,6 +25,9 @@ createBullBoard({

const app = express()

// Apply auth middleware to all routes
app.use(auth)

app.use('/jobs', serverAdapter.getRouter())
app.get('/', (_req, res) => res.send('ok'))

Expand Down

0 comments on commit af085cc

Please sign in to comment.