event subscriptions
This commit is contained in:
@@ -1,15 +1,35 @@
|
||||
import { Controller, Post, Route, SuccessResponse } from "tsoa";
|
||||
import express from "express";
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Request,
|
||||
Route,
|
||||
Security,
|
||||
SuccessResponse,
|
||||
} from "tsoa";
|
||||
import type { FoundEventDto } from "../dtos/foundEvents.js";
|
||||
import { inject } from "../infrastructure/di/index.js";
|
||||
import { FoundEventsService } from "../services/foundEvents/foundEventsService.js";
|
||||
import { KC_SECURITY_NAME } from "../services/keycloak/user/keycloak-user.js";
|
||||
|
||||
@Route("found-events")
|
||||
export class FoundEventsController extends Controller {
|
||||
private readonly foundEventsService = inject(FoundEventsService);
|
||||
|
||||
@Post("crawl")
|
||||
@Security(KC_SECURITY_NAME)
|
||||
@SuccessResponse("200", "OK")
|
||||
//TODO add security
|
||||
public async crawl() {
|
||||
return await this.foundEventsService.crawl();
|
||||
public async crawl(): Promise<void> {
|
||||
await this.foundEventsService.crawl();
|
||||
}
|
||||
|
||||
@Get("future")
|
||||
@Security(KC_SECURITY_NAME)
|
||||
@SuccessResponse("200", "OK")
|
||||
public async getFutureEvents(
|
||||
@Request() request: express.Request,
|
||||
): Promise<FoundEventDto[]> {
|
||||
return await this.foundEventsService.getFutureEvents(request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
import express from "express";
|
||||
import { Body, Controller, Post, Query, Request, Route, Security, SuccessResponse } from "tsoa";
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Post,
|
||||
Query,
|
||||
Request,
|
||||
Route,
|
||||
Security,
|
||||
SuccessResponse,
|
||||
} from "tsoa";
|
||||
import type { PushSubscriptionCreateArgs as PushSubscriptionCreateArgsDto } from "../dtos/pushSubscription.js";
|
||||
import { inject } from "../infrastructure/di/injector.js";
|
||||
import { KC_SECURITY_NAME } from "../services/keycloak/user/keycloak-user.js";
|
||||
@@ -16,35 +25,46 @@ export class PushContoller extends Controller {
|
||||
@Body() subscription: PushSubscriptionCreateArgsDto,
|
||||
@Request() request: express.Request,
|
||||
): Promise<void> {
|
||||
return await this.pushService.storeSubscription(subscription, request, request.res);
|
||||
return await this.pushService.storeSubscription(
|
||||
subscription,
|
||||
request,
|
||||
request.res,
|
||||
);
|
||||
}
|
||||
|
||||
@Post('reset')
|
||||
@Post("reset")
|
||||
@Security(KC_SECURITY_NAME)
|
||||
@SuccessResponse('200', 'OK')
|
||||
@SuccessResponse("200", "OK")
|
||||
public async resetSubscriptions(
|
||||
@Request() request: express.Request
|
||||
): Promise<void>{
|
||||
@Request() request: express.Request,
|
||||
): Promise<void> {
|
||||
return await this.pushService.reset(request);
|
||||
}
|
||||
|
||||
@Post('clearSingle')
|
||||
@Post("clearSingle")
|
||||
@Security(KC_SECURITY_NAME)
|
||||
@SuccessResponse("200", 'OK')
|
||||
@SuccessResponse("200", "OK")
|
||||
public async clearSubscription(
|
||||
@Request() request: express.Request,
|
||||
@Query() clientId: string
|
||||
):Promise<void>{
|
||||
@Query() clientId: string,
|
||||
): Promise<void> {
|
||||
await this.pushService.clearSubscription(clientId, request);
|
||||
}
|
||||
|
||||
@Post('test-publish')
|
||||
//TODO remove
|
||||
@Post("test-publish")
|
||||
@Security(KC_SECURITY_NAME)
|
||||
@SuccessResponse("200", "OK")
|
||||
public async publishTestMessage(
|
||||
@Request() request: express.Request
|
||||
): Promise<void>{
|
||||
@Request() request: express.Request,
|
||||
): Promise<void> {
|
||||
this.pushService.sendtestNotification(request);
|
||||
}
|
||||
|
||||
//TODO remove
|
||||
@Post("notify")
|
||||
@SuccessResponse("200", "OK")
|
||||
public async notifyEvents(): Promise<void> {
|
||||
await this.pushService.sendEventNotifications();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user