| 1 | import { Controller, Get, Param, Query } from '@nestjs/common'; |
| 2 | import { |
| 3 | ApiBearerAuth, |
| 4 | ApiOkResponse, |
| 5 | ApiOperation, |
| 6 | ApiParam, |
| 7 | ApiQuery, |
| 8 | ApiTags, |
| 9 | } from '@nestjs/swagger'; |
| 10 | |
| 11 | import { GetAirportsBoundsDTO } |
| 12 | import { AirportsService } |
| 13 | import { AirportDetailsEntity } |
| 14 | import { AirportEntity } |
| 15 | |
| 16 | @Controller('airports') |
| 17 | @ApiTags('Airports') |
| 18 | @ApiBearerAuth() |
| 19 | export class AirportsController |
| 20 | constructor(private readonly |
| 21 | |
| 22 | @Get() |
| 23 | @ApiOperation({ |
| 24 | description: |
| 25 | 'Get all airports. We do not recommend using this route without any search query. This route has over 20k records', |
| 26 | summary: 'Get all airports', |
| 27 | }) |
| 28 | @ApiOkResponse({ |
| 29 | type: [AirportEntity], |
| 30 | }) |
| 31 | @ApiQuery({ |
| 32 | name: 'search', |
| 33 | required: false, |
| 34 | type: String, |
| 35 | example: 'VIDP', |
| 36 | description: |
| 37 | 'Search query for airport. Can be iata, ident(icao), name or a part of any these. Searching is case insensitive', |
| 38 | }) |
| 39 | getAirports(@Query( |
| 40 | return this.airportsService |
| 41 | } |
| 42 | |
| 43 | @Get('bounds' |
| 44 | @ApiOperation({ |
| 45 | summary: 'Get airports within geographic bounds', |
| 46 | description: |
| 47 | 'Returns airports whose coordinates fall inside the given bounding box. ' + |
| 48 | 'Restricted to non-closed airports with an IATA code, prioritized by size ' + |
| 49 | 'and capped at 200 results. Intended for plotting airports on a map as the ' + |
| 50 | 'user pans at a sufficient zoom level.', |
| 51 | }) |
| 52 | @ApiOkResponse({ type |
| 53 | getAirportsInBounds(@Query() |
| 54 | return this.airportsService |
| 55 | } |
| 56 | |
| 57 | @Get(':ident/details' |
| 58 | @ApiOperation({ |
| 59 | summary: 'Get detailed live information for an airport', |
| 60 | description: |
| 61 | 'Aggregates current delays plus the latest METAR observation and TAF ' + |
| 62 | 'forecast (raw + decoded) for the given airport identifier (ICAO/IATA). ' + |
| 63 | 'Each source is best-effort; missing data is returned as null.', |
| 64 | }) |
| 65 | @ApiParam({ |
| 66 | name: 'ident', |
| 67 | example: 'VIDP', |
| 68 | description: 'Airport identifier (ICAO preferred, IATA accepted)', |
| 69 | }) |
| 70 | @ApiOkResponse({ type |
| 71 | getAirportDetails(@Param( |
| 72 | return this.airportsService |
| 73 | } |
| 74 | } |