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