feat: throw error

This commit is contained in:
Nevo David 2025-07-21 16:00:31 +07:00
parent 9c5dbb2b4f
commit a38aa176e5
1 changed files with 19 additions and 3 deletions

View File

@ -1,4 +1,4 @@
import { Controller, Get, Param } from '@nestjs/common';
import { Controller, Get, HttpException, Param } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { BullMqClient } from '@gitroom/nestjs-libraries/bull-mq-transport-new/client';
@ -8,7 +8,23 @@ export class MonitorController {
constructor(private _workerServiceProducer: BullMqClient) {}
@Get('/queue/:name')
getMessagesGroup(@Param('name') name: string) {
return this._workerServiceProducer.checkForStuckWaitingJobs(name);
async getMessagesGroup(@Param('name') name: string) {
const { valid } =
await this._workerServiceProducer.checkForStuckWaitingJobs(name);
if (valid) {
return {
status: 'success',
message: `Queue ${name} is healthy.`,
};
}
throw new HttpException(
{
status: 'error',
message: `Queue ${name} has stuck waiting jobs.`,
},
503
);
}
}