| 1 | import { |
| 2 | Body, |
| 3 | Controller, |
| 4 | HttpCode, |
| 5 | HttpStatus, |
| 6 | Param, |
| 7 | Post, |
| 8 | UseGuards, |
| 9 | } from '@nestjs/common'; |
| 10 | import { ApiExcludeController } |
| 11 | import { Public } |
| 12 | |
| 13 | import { |
| 14 | FinishImportRequestDTO, |
| 15 | ImportAttemptDTO, |
| 16 | ImportCommentsRequestDTO, |
| 17 | ImportIssuesRequestDTO, |
| 18 | ImportReleasesRequestDTO, |
| 19 | } from './dto/importer-callback.dto.js'; |
| 20 | import { ImporterCallbacksService } |
| 21 | import { ImporterSecretGuard } |
| 22 | |
| 23 | /** Called by `apps/importer` only. Each call renews the attempt's lease, so a working importer never looks silent. */ |
| 24 | @Controller('internal/imports/:importId') |
| 25 | @ApiExcludeController() |
| 26 | @Public() |
| 27 | @UseGuards(ImporterSecretGuard) |
| 28 | export class ImporterCallbacksController |
| 29 | constructor(private readonly |
| 30 | |
| 31 | @Post('heartbeat' |
| 32 | @HttpCode(HttpStatus. |
| 33 | heartbeat( |
| 34 | @Param('importId' |
| 35 | @Body() { |
| 36 | ) { |
| 37 | return this.callbacks |
| 38 | } |
| 39 | |
| 40 | @Post('releases' |
| 41 | @HttpCode(HttpStatus. |
| 42 | releases( |
| 43 | @Param('importId' |
| 44 | @Body() body |
| 45 | ) { |
| 46 | return this.callbacks |
| 47 | } |
| 48 | |
| 49 | @Post('issues' |
| 50 | @HttpCode(HttpStatus. |
| 51 | issues( |
| 52 | @Param('importId' |
| 53 | @Body() body |
| 54 | ) { |
| 55 | return this.callbacks |
| 56 | } |
| 57 | |
| 58 | @Post('comments' |
| 59 | @HttpCode(HttpStatus. |
| 60 | comments( |
| 61 | @Param('importId' |
| 62 | @Body() body |
| 63 | ) { |
| 64 | return this.callbacks |
| 65 | } |
| 66 | |
| 67 | @Post('finish' |
| 68 | @HttpCode(HttpStatus. |
| 69 | async finish( |
| 70 | @Param('importId' |
| 71 | @Body() body |
| 72 | ) { |
| 73 | await this.callbacks |
| 74 | } |
| 75 | } |