feat(api): add queue notifications module
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { Controller, Get, Param, Post, Res, UseGuards } from "@nestjs/common";
|
||||
import type { Response } from "express";
|
||||
import { ApiKeyGuard } from "../common/guards/api-key.guard";
|
||||
import {
|
||||
QueueNotificationsService,
|
||||
type QueueNotification,
|
||||
type QueueTask,
|
||||
} from "./queue-notifications.service";
|
||||
|
||||
@Controller("queue")
|
||||
@UseGuards(ApiKeyGuard)
|
||||
export class QueueNotificationsController {
|
||||
constructor(private readonly queueNotificationsService: QueueNotificationsService) {}
|
||||
|
||||
@Get("notifications")
|
||||
async getNotifications(): Promise<QueueNotification[]> {
|
||||
return this.queueNotificationsService.listNotifications();
|
||||
}
|
||||
|
||||
@Get("notifications/stream")
|
||||
async streamNotifications(@Res() res: Response): Promise<void> {
|
||||
await this.queueNotificationsService.streamNotifications(res);
|
||||
}
|
||||
|
||||
@Post("notifications/:id/ack")
|
||||
async ackNotification(@Param("id") id: string): Promise<{ success: true; id: string }> {
|
||||
return this.queueNotificationsService.ackNotification(id);
|
||||
}
|
||||
|
||||
@Get("tasks")
|
||||
async getTasks(): Promise<QueueTask[]> {
|
||||
return this.queueNotificationsService.listTasks();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user