Merge pull request #3412 from bluewave-labs/fix/queueController-types
fix: QueueController Types
This commit is contained in:
2 files changed
+3
-29
No files matched your search
@@ -1,11 +1,12 @@
|
|||||||
|
import { ISuperSimpleQueue } from "@/service/index.js";
|
||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response, NextFunction } from "express";
|
||||||
|
|
||||||
const SERVICE_NAME = "JobQueueController";
|
const SERVICE_NAME = "JobQueueController";
|
||||||
|
|
||||||
class JobQueueController {
|
class JobQueueController {
|
||||||
static SERVICE_NAME = SERVICE_NAME;
|
static SERVICE_NAME = SERVICE_NAME;
|
||||||
private jobQueue: any;
|
private jobQueue: ISuperSimpleQueue;
|
||||||
constructor(jobQueue: any) {
|
constructor(jobQueue: ISuperSimpleQueue) {
|
||||||
this.jobQueue = jobQueue;
|
this.jobQueue = jobQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,18 +54,6 @@ class JobQueueController {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
addJob = async (req: Request, res: Response, next: NextFunction) => {
|
|
||||||
try {
|
|
||||||
await this.jobQueue.addJob(Math.random().toString(36).substring(7));
|
|
||||||
return res.status(200).json({
|
|
||||||
success: true,
|
|
||||||
msg: "Job added to queue successfully",
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
next(error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
flushQueue = async (req: Request, res: Response, next: NextFunction) => {
|
flushQueue = async (req: Request, res: Response, next: NextFunction) => {
|
||||||
try {
|
try {
|
||||||
const result = await this.jobQueue.flushQueues();
|
const result = await this.jobQueue.flushQueues();
|
||||||
@@ -77,18 +66,5 @@ class JobQueueController {
|
|||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
checkQueueHealth = async (req: Request, res: Response, next: NextFunction) => {
|
|
||||||
try {
|
|
||||||
const stuckQueues = await this.jobQueue.checkQueueHealth();
|
|
||||||
return res.status(200).json({
|
|
||||||
success: true,
|
|
||||||
msg: "Queue health checked successfully",
|
|
||||||
data: stuckQueues,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
next(error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
export default JobQueueController;
|
export default JobQueueController;
|
||||||
@@ -11,10 +11,8 @@ class QueueRoutes {
|
|||||||
}
|
}
|
||||||
initRoutes() {
|
initRoutes() {
|
||||||
this.router.get("/jobs", isAllowed(["admin", "superadmin"]), this.queueController.getJobs);
|
this.router.get("/jobs", isAllowed(["admin", "superadmin"]), this.queueController.getJobs);
|
||||||
this.router.post("/jobs", isAllowed(["admin", "superadmin"]), this.queueController.addJob);
|
|
||||||
|
|
||||||
this.router.get("/metrics", isAllowed(["admin", "superadmin"]), this.queueController.getMetrics);
|
this.router.get("/metrics", isAllowed(["admin", "superadmin"]), this.queueController.getMetrics);
|
||||||
this.router.get("/health", isAllowed(["admin", "superadmin"]), this.queueController.checkQueueHealth);
|
|
||||||
this.router.get("/all-metrics", isAllowed(["admin", "superadmin"]), this.queueController.getAllMetrics);
|
this.router.get("/all-metrics", isAllowed(["admin", "superadmin"]), this.queueController.getAllMetrics);
|
||||||
this.router.post("/flush", isAllowed(["admin", "superadmin"]), this.queueController.flushQueue);
|
this.router.post("/flush", isAllowed(["admin", "superadmin"]), this.queueController.flushQueue);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user