add some description entries for the UI

This commit is contained in:
Sven Czarnian
2022-11-01 02:00:49 +01:00
parent 42235e6e17
commit bb9044698d
5 changed files with 71 additions and 8 deletions

View File

@@ -31,6 +31,7 @@ import { CoordinateConverter, WaypointConverter } from '../generic/converters';
import { ActiveRunwaysDto } from './dto/activerunways.dto'; import { ActiveRunwaysDto } from './dto/activerunways.dto';
import { Runway } from './models/runway.model'; import { Runway } from './models/runway.model';
import { RunwayDto } from './dto/runway.dto'; import { RunwayDto } from './dto/runway.dto';
import { AirportOverviewDto } from './dto/airportoverview.dto';
@Controller('airport') @Controller('airport')
export class AirportController { export class AirportController {
@@ -136,6 +137,8 @@ export class AirportController {
return { return {
icao: airport.icao, icao: airport.icao,
name: airport.name,
flightInformationRegion: airport.flightInformationRegion,
location: WaypointConverter.convert<WaypointDto, CoordinateDto>( location: WaypointConverter.convert<WaypointDto, CoordinateDto>(
airport.location, airport.location,
), ),
@@ -166,6 +169,8 @@ export class AirportController {
return { return {
icao: airport.icao, icao: airport.icao,
name: airport.name,
flightInformationRegion: airport.flightInformationRegion,
location: WaypointConverter.convert<Waypoint, Coordinate>( location: WaypointConverter.convert<Waypoint, Coordinate>(
airport.location, airport.location,
), ),
@@ -241,14 +246,14 @@ export class AirportController {
}); });
} }
@Get('/allCodes') @Get('/all')
@ApiResponse({ @ApiResponse({
status: 200, status: 200,
description: 'All available airports', description: 'All available airports',
type: [String], type: [AirportOverviewDto],
}) })
async allCodes(): Promise<string[]> { async all(): Promise<AirportOverviewDto[]> {
return this.airportService.airportsList(); return this.airportService.allAirports();
} }
@Get('/get') @Get('/get')

View File

@@ -2,6 +2,7 @@ import { Injectable } from '@nestjs/common';
import { InjectModel } from '@nestjs/mongoose'; import { InjectModel } from '@nestjs/mongoose';
import { Model } from 'mongoose'; import { Model } from 'mongoose';
import { ActiveRunwaysDto } from './dto/activerunways.dto'; import { ActiveRunwaysDto } from './dto/activerunways.dto';
import { AirportOverviewDto } from './dto/airportoverview.dto';
import { Airport, AirportDocument } from './models/airport.model'; import { Airport, AirportDocument } from './models/airport.model';
@Injectable() @Injectable()
@@ -17,11 +18,17 @@ export class AirportService {
.then((response) => response && response.length !== 0); .then((response) => response && response.length !== 0);
} }
async airportsList(): Promise<string[]> { async allAirports(): Promise<AirportOverviewDto[]> {
return this.airportModel.find({}).then((response) => { return this.airportModel.find({}).then((response) => {
const icaoCodes: string[] = []; const retval: AirportOverviewDto[] = [];
response.forEach((airport) => icaoCodes.push(airport.icao)); response.forEach((airport) =>
return icaoCodes; retval.push({
icao: airport.icao,
name: airport.name,
flightInformationRegion: airport.flightInformationRegion,
}),
);
return retval;
}); });
} }

View File

@@ -15,6 +15,20 @@ export class AirportDto {
}) })
icao: string; icao: string;
@IsNotEmpty()
@ApiProperty({
description: 'The name of the airport',
example: 'Berlin Brandenburg',
})
name: string;
@IsNotEmpty()
@ApiProperty({
description: 'The flight information region (FIR)',
example: 'FIR Bremen',
})
flightInformationRegion: string;
@IsNotEmpty() @IsNotEmpty()
@ApiProperty({ @ApiProperty({
description: 'The airport location', description: 'The airport location',

View File

@@ -0,0 +1,25 @@
import { IsNotEmpty } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';
export class AirportOverviewDto {
@IsNotEmpty()
@ApiProperty({
description: 'The unique ICAO code',
example: 'EDDB',
})
icao: string;
@IsNotEmpty()
@ApiProperty({
description: 'The name of the airport',
example: 'Berlin Brandenburg',
})
name: string;
@IsNotEmpty()
@ApiProperty({
description: 'The flight information region (FIR)',
example: 'FIR Bremen',
})
flightInformationRegion: string;
}

View File

@@ -18,6 +18,18 @@ export class Airport {
}) })
icao: string; icao: string;
@Prop({
required: true,
type: String,
})
name: string;
@Prop({
required: true,
type: String,
})
flightInformationRegion: string;
@Prop({ @Prop({
required: true, required: true,
type: Waypoint, type: Waypoint,