| 1 | import { |
| 2 | Body, |
| 3 | Controller, |
| 4 | Delete, |
| 5 | Get, |
| 6 | Param, |
| 7 | Patch, |
| 8 | Post, |
| 9 | Session, |
| 10 | } from '@nestjs/common'; |
| 11 | import { |
| 12 | ApiConflictResponse, |
| 13 | ApiCreatedResponse, |
| 14 | ApiNotFoundResponse, |
| 15 | ApiOkResponse, |
| 16 | ApiOperation, |
| 17 | ApiTags, |
| 18 | } from '@nestjs/swagger'; |
| 19 | import { OptionalAuth, type |
| 20 | |
| 21 | import { ErrorResponseDTO } |
| 22 | import { |
| 23 | CreateLabelRequestDTO, |
| 24 | GetLabelsResponseDTO, |
| 25 | LabelDTO, |
| 26 | UpdateLabelRequestDTO, |
| 27 | } from './dto/label.dto.js'; |
| 28 | import { IssuesService } |
| 29 | |
| 30 | @Controller('repositories/:username/:repo/labels') |
| 31 | @ApiTags('Labels') |
| 32 | export class LabelsController |
| 33 | constructor(private readonly |
| 34 | |
| 35 | @Get() |
| 36 | @OptionalAuth() |
| 37 | @ApiOperation({ summary |
| 38 | @ApiOkResponse({ type |
| 39 | @ApiNotFoundResponse({ type |
| 40 | listLabels( |
| 41 | @Param('username' |
| 42 | @Param('repo' |
| 43 | @Session() session |
| 44 | ) { |
| 45 | return this.issues |
| 46 | username, |
| 47 | repo, |
| 48 | requesterId: session?.user |
| 49 | }); |
| 50 | } |
| 51 | |
| 52 | @Post() |
| 53 | @ApiOperation({ summary |
| 54 | @ApiCreatedResponse({ type |
| 55 | @ApiNotFoundResponse({ type |
| 56 | @ApiConflictResponse({ type |
| 57 | createLabel( |
| 58 | @Param('username' |
| 59 | @Param('repo' |
| 60 | @Body() body |
| 61 | @Session() session |
| 62 | ) { |
| 63 | return this.issues |
| 64 | username, |
| 65 | repo, |
| 66 | requesterId: session.user |
| 67 | body, |
| 68 | }); |
| 69 | } |
| 70 | |
| 71 | @Patch(':labelId' |
| 72 | @ApiOperation({ summary |
| 73 | @ApiOkResponse({ type |
| 74 | @ApiNotFoundResponse({ type |
| 75 | @ApiConflictResponse({ type |
| 76 | updateLabel( |
| 77 | @Param('username' |
| 78 | @Param('repo' |
| 79 | @Param('labelId' |
| 80 | @Body() body |
| 81 | @Session() session |
| 82 | ) { |
| 83 | return this.issues |
| 84 | username, |
| 85 | repo, |
| 86 | requesterId: session.user |
| 87 | labelId, |
| 88 | body, |
| 89 | }); |
| 90 | } |
| 91 | |
| 92 | @Delete(':labelId' |
| 93 | @ApiOperation({ summary |
| 94 | @ApiOkResponse({ schema |
| 95 | @ApiNotFoundResponse({ type |
| 96 | deleteLabel( |
| 97 | @Param('username' |
| 98 | @Param('repo' |
| 99 | @Param('labelId' |
| 100 | @Session() session |
| 101 | ) { |
| 102 | return this.issues |
| 103 | username, |
| 104 | repo, |
| 105 | requesterId: session.user |
| 106 | labelId, |
| 107 | }); |
| 108 | } |
| 109 | } |