| 1 | import { GenericErrorEntity } from 'src/common/entites/generic-error.entity'; |
| 2 | |
| 3 | import { Body, Controller |
| 4 | import { |
| 5 | ApiBearerAuth, |
| 6 | ApiNotFoundResponse, |
| 7 | ApiOkResponse, |
| 8 | ApiOperation, |
| 9 | ApiTags, |
| 10 | ApiUnauthorizedResponse, |
| 11 | } from '@nestjs/swagger'; |
| 12 | |
| 13 | import { AirlineEntity } |
| 14 | import { GetAirlineDTO } |
| 15 | import { GetFlightsBoundsDTO } |
| 16 | import { GetFlightsDTO } |
| 17 | import { |
| 18 | FlightsResponseEntity, |
| 19 | TrackedFlightsResponseEntity, |
| 20 | } from './entities/flight.entity'; |
| 21 | import { FlightsService } |
| 22 | |
| 23 | @Controller('flights') |
| 24 | @ApiBearerAuth('JWT-auth') |
| 25 | @ApiTags('Flights') |
| 26 | export class FlightsController |
| 27 | constructor(private readonly |
| 28 | |
| 29 | @Post('airline' |
| 30 | @ApiOperation({ |
| 31 | summary: 'Get airline', |
| 32 | description: |
| 33 | "Get airline with search query. This doesn't check if the number is correct", |
| 34 | }) |
| 35 | @ApiOkResponse({ |
| 36 | type: AirlineEntity, |
| 37 | }) |
| 38 | @ApiNotFoundResponse({ type |
| 39 | getAirline(@Body() |
| 40 | return this.flightsService |
| 41 | } |
| 42 | |
| 43 | @Get() |
| 44 | @ApiOperation({ |
| 45 | summary: 'Get flights between two airports', |
| 46 | description: 'Get all flights between two airports for a specific date', |
| 47 | }) |
| 48 | @ApiOkResponse({ type |
| 49 | @ApiUnauthorizedResponse({ type |
| 50 | getFlights(@Query() |
| 51 | return this.flightsService |
| 52 | } |
| 53 | |
| 54 | @Get('bounds' |
| 55 | @ApiOperation({ |
| 56 | summary: |
| 57 | 'Get flights within geographic bounds(deprecated - will return nothing)', |
| 58 | description: |
| 59 | 'Get all aircraft currently flying within a specified geographic bounding box using FlightAware data with comprehensive aircraft details', |
| 60 | deprecated: true, |
| 61 | }) |
| 62 | @ApiOkResponse({ |
| 63 | description: |
| 64 | 'List of flights within the specified bounds with detailed aircraft information', |
| 65 | schema: { |
| 66 | type: 'object', |
| 67 | properties: { |
| 68 | success: { type: ' |
| 69 | timestamp: { type: ' |
| 70 | bounds: { |
| 71 | type: 'object', |
| 72 | properties: { |
| 73 | minLat: { type: ' |
| 74 | maxLat: { type: ' |
| 75 | minLng: { type: ' |
| 76 | maxLng: { type: ' |
| 77 | }, |
| 78 | }, |
| 79 | totalAircraft: { type: ' |
| 80 | airborneAircraft: { type: ' |
| 81 | flights: { |
| 82 | type: 'array', |
| 83 | items: { |
| 84 | type: 'object', |
| 85 | properties: { |
| 86 | ident_icao: { type: ' |
| 87 | ident_iata: { type: ' |
| 88 | callsign: { type: ' |
| 89 | |
| 90 | // Position and movement data |
| 91 | latitude: { type: ' |
| 92 | longitude: { type: ' |
| 93 | altitude: { type: ' |
| 94 | velocity: { type: ' |
| 95 | heading: { type: ' |
| 96 | verticalRate: { type: ' |
| 97 | lastContact: { type: ' |
| 98 | isOnGround: { type: ' |
| 99 | |
| 100 | // Aircraft details |
| 101 | aircraftType: { type: ' |
| 102 | aircraftTypeFaa: { type: ' |
| 103 | aircraftFamily: { type: ' |
| 104 | manufacturer: { type: ' |
| 105 | model: { type: ' |
| 106 | engineType: { type: ' |
| 107 | engineCount: { type: ' |
| 108 | wakeTurbulenceCategory: { type: ' |
| 109 | |
| 110 | // Flight plan and registration |
| 111 | aircraftId: { type: ' |
| 112 | aircraftRegistration: { type: ' |
| 113 | ownerIcao: { type: ' |
| 114 | ownerIata: { type: ' |
| 115 | ownerName: { type: ' |
| 116 | |
| 117 | // Operator information |
| 118 | operator: { type: ' |
| 119 | operatorIcao: { type: ' |
| 120 | operatorIata: { type: ' |
| 121 | operatorCountry: { type: ' |
| 122 | |
| 123 | // Route information |
| 124 | origin: { |
| 125 | type: 'object', |
| 126 | nullable: true, |
| 127 | properties: { |
| 128 | code: { type: ' |
| 129 | codeIcao: { type: ' |
| 130 | codeIata: { type: ' |
| 131 | name: { type: ' |
| 132 | city: { type: ' |
| 133 | timezone: { type: ' |
| 134 | }, |
| 135 | }, |
| 136 | destination: { |
| 137 | type: 'object', |
| 138 | nullable: true, |
| 139 | properties: { |
| 140 | code: { type: ' |
| 141 | codeIcao: { type: ' |
| 142 | codeIata: { type: ' |
| 143 | name: { type: ' |
| 144 | city: { type: ' |
| 145 | timezone: { type: ' |
| 146 | }, |
| 147 | }, |
| 148 | |
| 149 | // Flight status and timing |
| 150 | status: { type: ' |
| 151 | progressPercent: { type: ' |
| 152 | routeDistance: { type: ' |
| 153 | filedAirspeedKts: { type: ' |
| 154 | filedAltitude: { type: ' |
| 155 | |
| 156 | // Schedule information |
| 157 | scheduledOff: { type: ' |
| 158 | scheduledOn: { type: ' |
| 159 | estimatedOff: { type: ' |
| 160 | estimatedOn: { type: ' |
| 161 | actualOff: { type: ' |
| 162 | actualOn: { type: ' |
| 163 | |
| 164 | // Delays |
| 165 | departureDelay: { type: ' |
| 166 | arrivalDelay: { type: ' |
| 167 | |
| 168 | // Airport details |
| 169 | gateOrigin: { type: ' |
| 170 | gateDestination: { type: ' |
| 171 | terminalOrigin: { type: ' |
| 172 | terminalDestination: { type: ' |
| 173 | |
| 174 | // Additional metadata |
| 175 | route: { type: ' |
| 176 | type: { type: ' |
| 177 | }, |
| 178 | }, |
| 179 | }, |
| 180 | }, |
| 181 | }, |
| 182 | }) |
| 183 | @ApiUnauthorizedResponse({ type |
| 184 | getFlightsInBounds(@Query() |
| 185 | return this.flightsService |
| 186 | } |
| 187 | |
| 188 | @Get('tracked' |
| 189 | @ApiOperation({ |
| 190 | summary: 'Get all tracked flights', |
| 191 | description: |
| 192 | 'Returns a list of all flights that have been tracked in the system, sorted by most recently created. Limited to 50 most recent flights.', |
| 193 | }) |
| 194 | @ApiOkResponse({ |
| 195 | type: TrackedFlightsResponseEntity, |
| 196 | description: 'List of tracked flights with complete flight information', |
| 197 | }) |
| 198 | @ApiUnauthorizedResponse({ type |
| 199 | getTrackedFlights() { |
| 200 | return this.flightsService |
| 201 | } |
| 202 | } |