| 1 | import { |
| 2 | Controller, |
| 3 | Delete, |
| 4 | Get, |
| 5 | HttpCode, |
| 6 | HttpStatus, |
| 7 | Param, |
| 8 | Post, |
| 9 | Session, |
| 10 | } from '@nestjs/common'; |
| 11 | import { |
| 12 | ApiConflictResponse, |
| 13 | ApiNoContentResponse, |
| 14 | ApiNotFoundResponse, |
| 15 | ApiOkResponse, |
| 16 | ApiOperation, |
| 17 | ApiTags, |
| 18 | } from '@nestjs/swagger'; |
| 19 | import type { UserSession |
| 20 | |
| 21 | import { ErrorResponseDTO } |
| 22 | import { |
| 23 | ForkRepositoryResponseDTO, |
| 24 | ListIncomingTransfersResponseDTO, |
| 25 | } from './dto/fork-repository.dto.js'; |
| 26 | import { RepositoriesService } |
| 27 | |
| 28 | @ApiTags('Repositories') |
| 29 | @Controller('transfers') |
| 30 | export class TransfersController |
| 31 | constructor(private readonly |
| 32 | |
| 33 | @Get() |
| 34 | @ApiOperation({ |
| 35 | summary: 'List transfers waiting for me', |
| 36 | description: |
| 37 | 'Repositories offered to the signed-in user or to an organization they administer.', |
| 38 | }) |
| 39 | @ApiOkResponse({ type |
| 40 | list( |
| 41 | @Session() session |
| 42 | ): Promise<ListIncomingTransfersResponseDTO |
| 43 | return this.repositories |
| 44 | } |
| 45 | |
| 46 | @Post(':repositoryId/accept' |
| 47 | @ApiOperation({ summary |
| 48 | @ApiOkResponse({ type |
| 49 | @ApiConflictResponse({ type |
| 50 | @ApiNotFoundResponse({ type |
| 51 | accept( |
| 52 | @Param('repositoryId' |
| 53 | @Session() session |
| 54 | ): Promise<ForkRepositoryResponseDTO |
| 55 | return this.repositories |
| 56 | } |
| 57 | |
| 58 | @Delete(':repositoryId' |
| 59 | @HttpCode(HttpStatus. |
| 60 | @ApiOperation({ |
| 61 | summary: 'Decline or withdraw a transfer', |
| 62 | description: |
| 63 | 'The recipient declines it, or whoever requested it withdraws it.', |
| 64 | }) |
| 65 | @ApiNoContentResponse() |
| 66 | @ApiNotFoundResponse({ type |
| 67 | cancel( |
| 68 | @Param('repositoryId' |
| 69 | @Session() session |
| 70 | ): Promise<void |
| 71 | return this.repositories |
| 72 | } |
| 73 | } |