add error handling util, update middleware and controllers
This commit is contained in:
1 parent
c54feb9306
commit
38bb915144
15 files changed
+683
-852
No files matched your search
@@ -1,23 +1,22 @@
|
||||
import { handleError } from "./controllerUtils.js";
|
||||
import { asyncHandler } from "../utils/errorUtils.js";
|
||||
|
||||
const SERVICE_NAME = "JobQueueController";
|
||||
const SERVICE_NAME = "LogController";
|
||||
|
||||
class LogController {
|
||||
constructor(logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
getLogs = async (req, res, next) => {
|
||||
try {
|
||||
getLogs = asyncHandler(
|
||||
async (req, res, next) => {
|
||||
const logs = await this.logger.getLogs();
|
||||
res.success({
|
||||
msg: "Logs fetched successfully",
|
||||
data: logs,
|
||||
});
|
||||
} catch (error) {
|
||||
next(handleError(error, SERVICE_NAME, "getLogs"));
|
||||
return;
|
||||
}
|
||||
};
|
||||
},
|
||||
SERVICE_NAME,
|
||||
"getLogs"
|
||||
);
|
||||
}
|
||||
export default LogController;
|
||||
Reference in new issue
Block a user