| 1 | import { existsSync, mkdirSync, writeFileSync } from 'fs'; |
| 2 | import { join } |
| 3 | |
| 4 | import { Body, Controller |
| 5 | import { ApiExcludeController } |
| 6 | |
| 7 | import { AlertsService } |
| 8 | |
| 9 | @Controller('alerts') |
| 10 | @ApiExcludeController() |
| 11 | export class AlertsController |
| 12 | constructor(private readonly |
| 13 | |
| 14 | @Post(':id' |
| 15 | async handleFlightawareALerts( |
| 16 | @Body() body |
| 17 | @Headers() headers |
| 18 | @Param(':id' |
| 19 | ) { |
| 20 | const folderPath = |
| 21 | if (!existsSync(folderPath |
| 22 | mkdirSync(folderPath, { |
| 23 | } |
| 24 | writeFileSync( |
| 25 | join(folderPath, ` |
| 26 | JSON.stringify( |
| 27 | { |
| 28 | headers, |
| 29 | body, |
| 30 | }, |
| 31 | null, |
| 32 | 2, |
| 33 | ), |
| 34 | ); |
| 35 | |
| 36 | return { |
| 37 | ok: true, |
| 38 | }; |
| 39 | } |
| 40 | } |