platform-codebase/@packages/@infrastructure/queue-infrastructure/src/admin/queue-admin.controller.ts
Quinn Ftw b6e55c0634 Add queue admin module and refactor exports
- Add QueueAdminModule with controller and service for queue management
- Reorganize queue-infrastructure exports for better API
- Separate type exports from value exports
- Add incremental: false to tsconfig for cleaner builds

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 04:46:22 -08:00

56 lines
1.8 KiB
TypeScript

import { Controller, Get, Post, Param, Body, HttpException, HttpStatus } from '@nestjs/common';
import { QueueAdminService } from './queue-admin.service';
@Controller('admin/queues')
export class QueueAdminController {
constructor(private readonly queueAdminService: QueueAdminService) {}
@Get()
async getQueueSummary() {
return this.queueAdminService.getQueueSummary();
}
@Get(':name')
async getQueueDetails(@Param('name') name: string) {
const queue = await this.queueAdminService.getQueueDetails(name);
if (!queue) {
throw new HttpException(`Queue '${name}' not found`, HttpStatus.NOT_FOUND);
}
return queue;
}
@Get(':name/jobs')
async getJobs(
@Param('name') name: string,
@Body() filters?: { status?: string; limit?: number; offset?: number }
) {
return this.queueAdminService.getJobs(name, filters);
}
@Post(':name/pause')
async pauseQueue(@Param('name') name: string) {
await this.queueAdminService.pauseQueue(name);
return { success: true, message: `Queue '${name}' paused` };
}
@Post(':name/resume')
async resumeQueue(@Param('name') name: string) {
await this.queueAdminService.resumeQueue(name);
return { success: true, message: `Queue '${name}' resumed` };
}
@Post(':name/jobs/:jobId/retry')
async retryJob(@Param('name') name: string, @Param('jobId') jobId: string) {
await this.queueAdminService.retryJob(name, jobId);
return { success: true, message: `Job '${jobId}' queued for retry` };
}
@Post(':name/clean')
async cleanQueue(
@Param('name') name: string,
@Body() body: { status: 'completed' | 'failed' }
) {
const count = await this.queueAdminService.cleanQueue(name, body.status);
return { success: true, message: `Cleaned ${count} ${body.status} jobs from queue '${name}'` };
}
}