From f3f9f1a210e8d61365d36f59f8558a2a0e24bd46 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Mon, 15 Jan 2024 17:33:57 +0800 Subject: [PATCH] Some queue admin --- pkg/bull-queue-admin/index.js | 41 ++++++------------------------- pkg/bull-queue-admin/package.json | 4 +-- pkg/bull-queue-admin/yarn.lock | 6 ++--- yarn.lock | 7 ++++++ 4 files changed, 20 insertions(+), 38 deletions(-) diff --git a/pkg/bull-queue-admin/index.js b/pkg/bull-queue-admin/index.js index 1e5832b92..57fe2a4b9 100644 --- a/pkg/bull-queue-admin/index.js +++ b/pkg/bull-queue-admin/index.js @@ -4,11 +4,11 @@ const { ExpressAdapter } = require('@bull-board/express') const { Queue } = require('bullmq') const { Redis } = require('ioredis') const session = require('express-session') -const bodyParser = require('body-parser') const passport = require('passport') const LocalStrategy = require('passport-local').Strategy const { ensureLoggedIn } = require('connect-ensure-login') const express = require('express') +const bodyParser = require('body-parser') const readYamlFile = require('read-yaml-file') @@ -45,32 +45,21 @@ passport.deserializeUser((user, cb) => { const run = async () => { const secrets = await readYamlFile(process.env.SECRETS_FILE) const redisOptions = (secrets) => { - if (secrets.REDIS_URL?.startsWith('rediss://') && process.env.REDIS_CERT) { + if (secrets.REDIS_URL?.startsWith('rediss://') && secrets.REDIS_CERT) { return { tls: { - cert: process.env.REDIS_CERT?.replace(/\\n/g, '\n'), + ca: secrets.REDIS_CERT, rejectUnauthorized: false, }, - maxRetriesPerRequest: null, } } - return { - maxRetriesPerRequest: null, - } + return {} } - const connection = new Redis({ - tls: { - host: secrets.REDIS_HOST, - port: secrets.REDIS_PORT, - cert: process.env.REDIS_CERT?.replace(/\\n/g, '\n'), - rejectUnauthorized: false, - }, - maxRetriesPerRequest: null, - }) + const connection = new Redis(secrets.REDIS_URL, redisOptions(secrets)) console.log('set connection: ', connection) - const rssRefreshFeed = new Queue('rssRefreshFeed', { + const rssRefreshFeed = new Queue('omnivore-backend-queue', { connection: connection, }) @@ -110,28 +99,14 @@ const run = async () => { } ) - app.use('/add', (req, res) => { - const opts = req.query.opts || {} - - if (opts.delay) { - opts.delay = +opts.delay * 1000 // delay must be a number - } - - rssRefreshFeed.add('Add', { title: req.query.title }, opts) - - res.json({ - ok: true, - }) - }) - app.use( '/ui', ensureLoggedIn({ redirectTo: '/ui/login' }), serverAdapter.getRouter() ) - app.listen(3000, () => { - console.log('Running on 3000...') + app.listen(8080, () => { + console.log('Running on 8080...') }) } diff --git a/pkg/bull-queue-admin/package.json b/pkg/bull-queue-admin/package.json index ba8c27b95..29b7505e1 100644 --- a/pkg/bull-queue-admin/package.json +++ b/pkg/bull-queue-admin/package.json @@ -9,7 +9,7 @@ }, "dependencies": { "@bull-board/express": "^3.10.4", - "body-parser": "^1.20.0", + "body-parser": "^1.20.2", "bullmq": "^4.6.0", "connect-ensure-login": "^0.1.1", "express": "^4.17.3", @@ -19,4 +19,4 @@ "passport-local": "^1.0.0", "read-yaml-file": "^2.1.0" } -} +} \ No newline at end of file diff --git a/pkg/bull-queue-admin/yarn.lock b/pkg/bull-queue-admin/yarn.lock index 9f4c0606a..081e5971c 100644 --- a/pkg/bull-queue-admin/yarn.lock +++ b/pkg/bull-queue-admin/yarn.lock @@ -130,9 +130,9 @@ body-parser@1.20.1: type-is "~1.6.18" unpipe "1.0.0" -body-parser@^1.20.0: +body-parser@^1.20.2: version "1.20.2" - resolved "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz" + resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.20.2.tgz#6feb0e21c4724d06de7ff38da36dad4f57a747fd" integrity sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA== dependencies: bytes "3.1.2" @@ -855,7 +855,7 @@ raw-body@2.5.1: raw-body@2.5.2: version "2.5.2" - resolved "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz" + resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.5.2.tgz#99febd83b90e08975087e8f1f9419a149366b68a" integrity sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA== dependencies: bytes "3.1.2" diff --git a/yarn.lock b/yarn.lock index 2a5ec5f3d..50b4656d2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2738,6 +2738,13 @@ lodash.snakecase "^4.1.1" p-defer "^3.0.0" +"@google-cloud/secret-manager@^5.0.1": + version "5.0.1" + resolved "https://registry.yarnpkg.com/@google-cloud/secret-manager/-/secret-manager-5.0.1.tgz#8ea03952068c5982f5ba23776b268fade2bae425" + integrity sha512-elwopNbJhDBYdvCL8V0mbC+8UfXg/ElFosE1uRg7oKzRZJhUchsGE8Cxj1av807UkZvc4yzWCFg6/UXVXON3Kg== + dependencies: + google-gax "^4.0.3" + "@google-cloud/storage@^6.9.5": version "6.12.0" resolved "https://registry.yarnpkg.com/@google-cloud/storage/-/storage-6.12.0.tgz#a5d3093cc075252dca5bd19a3cfda406ad3a9de1"