From e75d87217334d46bd879c38b4b9b4371a82c1ea7 Mon Sep 17 00:00:00 2001 From: Sven Czarnian Date: Thu, 3 Nov 2022 23:33:55 +0100 Subject: [PATCH] introduce the push notification for the airport --- src/airport/airport.controller.ts | 13 ++++++++++++- src/airport/airport.module.ts | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/airport/airport.controller.ts b/src/airport/airport.controller.ts index b058394..d9a66f7 100644 --- a/src/airport/airport.controller.ts +++ b/src/airport/airport.controller.ts @@ -8,6 +8,7 @@ import { Query, HttpException, HttpStatus, + Sse, UseGuards, } from '@nestjs/common'; import { ApiBody, ApiQuery, ApiResponse } from '@nestjs/swagger'; @@ -33,11 +34,16 @@ import { ActiveRunwaysDto } from './dto/activerunways.dto'; import { Runway } from './models/runway.model'; import { RunwayDto } from './dto/runway.dto'; import { AirportOverviewDto } from './dto/airportoverview.dto'; +import { Observable } from 'rxjs'; +import { EventsService } from '../events/events.service'; import { JwtGuard } from 'src/auth/guards/jwt.guard'; @Controller('airport') export class AirportController { - constructor(private readonly airportService: AirportService) {} + constructor( + private readonly airportService: AirportService, + private readonly eventService: EventsService, + ) {} private static convertConstraint( constraint: Constraint | ConstraintDto, @@ -248,6 +254,11 @@ export class AirportController { }); } + @Sse('/renew') + renew(): Observable { + return this.eventService.subscribeAirportRenew(); + } + @UseGuards(JwtGuard) @Get('/all') @ApiResponse({ diff --git a/src/airport/airport.module.ts b/src/airport/airport.module.ts index 977248c..d1fe26e 100644 --- a/src/airport/airport.module.ts +++ b/src/airport/airport.module.ts @@ -3,10 +3,12 @@ import { MongooseModule } from '@nestjs/mongoose'; import { AirportSchema } from './models/airport.model'; import { AirportService } from './airport.service'; import { AirportController } from './airport.controller'; +import { EventsModule } from 'src/events/events.module'; @Module({ imports: [ MongooseModule.forFeature([{ name: 'airport', schema: AirportSchema }]), + EventsModule, ], providers: [AirportService], controllers: [AirportController],