|
@@ -29,6 +29,11 @@ import { Inbound } from './models/inbound.model';
|
|
|
import { Planning } from './models/planning.model';
|
|
|
import { PredictedWaypoint } from './models/predictedwaypoint.model';
|
|
|
|
|
|
+const AllowedWtcs = ['L', 'M', 'H', 'J'];
|
|
|
+const AllowedWakeRecats = ['A', 'B', 'C', 'D', 'E', 'F'];
|
|
|
+const AllowedEngineTypes = ['ELECTRIC', 'TURBOPROP', 'JET'];
|
|
|
+const AllowedReporterTypes = ['UNK', 'DEL', 'GND', 'TWR', 'APP', 'DEP', 'CTR'];
|
|
|
+
|
|
|
@Controller('inbound')
|
|
|
export class InboundController {
|
|
|
constructor(
|
|
@@ -200,7 +205,62 @@ export class InboundController {
|
|
|
status: 404,
|
|
|
description: 'The destination airport is unknown',
|
|
|
})
|
|
|
+ @ApiResponse({
|
|
|
+ status: 422,
|
|
|
+ description: 'The WTC is invalid',
|
|
|
+ })
|
|
|
+ @ApiResponse({
|
|
|
+ status: 422,
|
|
|
+ description: 'The wake recat is invalid',
|
|
|
+ })
|
|
|
+ @ApiResponse({
|
|
|
+ status: 422,
|
|
|
+ description: 'The engine type is invalid',
|
|
|
+ })
|
|
|
+ @ApiResponse({
|
|
|
+ status: 422,
|
|
|
+ description: 'The reporter is invalid',
|
|
|
+ })
|
|
|
async insert(inbound: InboundDto): Promise<boolean> {
|
|
|
+ if (
|
|
|
+ AllowedWtcs.find((element) => element === inbound.aircraft.wtc) ===
|
|
|
+ undefined
|
|
|
+ ) {
|
|
|
+ throw new HttpException(
|
|
|
+ 'The WTC is invalid',
|
|
|
+ HttpStatus.UNPROCESSABLE_ENTITY,
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ AllowedWakeRecats.find(
|
|
|
+ (element) => element === inbound.aircraft.wakeRecat,
|
|
|
+ ) === undefined
|
|
|
+ ) {
|
|
|
+ throw new HttpException(
|
|
|
+ 'The wake recat is invalid',
|
|
|
+ HttpStatus.UNPROCESSABLE_ENTITY,
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ AllowedEngineTypes.find(
|
|
|
+ (element) => element === inbound.aircraft.engineType,
|
|
|
+ ) === undefined
|
|
|
+ ) {
|
|
|
+ throw new HttpException(
|
|
|
+ 'The engine type is invalid',
|
|
|
+ HttpStatus.UNPROCESSABLE_ENTITY,
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ AllowedReporterTypes.find((element) => element === inbound.reporter) ===
|
|
|
+ undefined
|
|
|
+ ) {
|
|
|
+ throw new HttpException(
|
|
|
+ 'The reporter type is invalid',
|
|
|
+ HttpStatus.UNPROCESSABLE_ENTITY,
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
return this.airportService
|
|
|
.airport(inbound.destination)
|
|
|
.then(async (airport) => {
|