use response middleware in QueueController

This commit is contained in:
Alex Holliday committed 2025-01-19 12:04:47 -08:00
1 parent 378a190cd3
commit 3608eadb8c
1 file changed
+6 -9
+6 -9
View File
@@ -11,8 +11,7 @@ class JobQueueController {
getMetrics = async (req, res, next) => { getMetrics = async (req, res, next) => {
try { try {
const metrics = await this.jobQueue.getMetrics(); const metrics = await this.jobQueue.getMetrics();
res.status(200).json({ res.successs({
success: true,
msg: successMessages.QUEUE_GET_METRICS, msg: successMessages.QUEUE_GET_METRICS,
data: metrics, data: metrics,
}); });
@@ -25,8 +24,7 @@ class JobQueueController {
getJobs = async (req, res, next) => { getJobs = async (req, res, next) => {
try { try {
const jobs = await this.jobQueue.getJobStats(); const jobs = await this.jobQueue.getJobStats();
return res.status(200).json({ return res.successs({
success: true,
msg: successMessages.QUEUE_GET_METRICS, msg: successMessages.QUEUE_GET_METRICS,
data: jobs, data: jobs,
}); });
@@ -39,8 +37,7 @@ class JobQueueController {
addJob = async (req, res, next) => { addJob = async (req, res, next) => {
try { try {
await this.jobQueue.addJob(Math.random().toString(36).substring(7)); await this.jobQueue.addJob(Math.random().toString(36).substring(7));
return res.status(200).json({ return res.successs({
success: true,
msg: successMessages.QUEUE_ADD_JOB, msg: successMessages.QUEUE_ADD_JOB,
}); });
} catch (error) { } catch (error) {
@@ -52,9 +49,9 @@ class JobQueueController {
obliterateQueue = async (req, res, next) => { obliterateQueue = async (req, res, next) => {
try { try {
await this.jobQueue.obliterate(); await this.jobQueue.obliterate();
return res return res.successs({
.status(200) msg: successMessages.QUEUE_OBLITERATE,
.json({ success: true, msg: successMessages.QUEUE_OBLITERATE }); });
} catch (error) { } catch (error) {
next(handleError(error, SERVICE_NAME, "obliterateQueue")); next(handleError(error, SERVICE_NAME, "obliterateQueue"));
return; return;