| 1 | import { |
| 2 | Body, |
| 3 | Controller, |
| 4 | Delete, |
| 5 | Get, |
| 6 | HttpCode, |
| 7 | Param, |
| 8 | ParseIntPipe, |
| 9 | Patch, |
| 10 | Post, |
| 11 | Query, |
| 12 | UseFilters, |
| 13 | UseInterceptors, |
| 14 | } from '@nestjs/common'; |
| 15 | import { ApiOperation, ApiTags |
| 16 | import { AllowAnonymous } |
| 17 | |
| 18 | import type { GithubViewer |
| 19 | import { Viewer } |
| 20 | import { GithubRestFilter } |
| 21 | import { GithubRestInterceptor } |
| 22 | import { GithubCommentsService } |
| 23 | import { |
| 24 | GithubCommentDTO, |
| 25 | GithubListCommentsQueryDTO, |
| 26 | } from './dto/issue.dto.js'; |
| 27 | |
| 28 | const ID = new |
| 29 | |
| 30 | /** Registered before IssuesController, so `issues/comments` is not read as issue number "comments". */ |
| 31 | @Controller('v3/repos/:owner/:repo/issues') |
| 32 | @ApiTags('GitHub compatibility') |
| 33 | @AllowAnonymous() |
| 34 | @UseFilters(GithubRestFilter) |
| 35 | @UseInterceptors(GithubRestInterceptor) |
| 36 | export class CommentsController |
| 37 | constructor(private readonly |
| 38 | |
| 39 | @Get('comments' |
| 40 | @ApiOperation({ |
| 41 | summary: "Every comment in a repository's issues and pull requests", |
| 42 | }) |
| 43 | listForRepository( |
| 44 | @Param('owner' |
| 45 | @Param('repo' |
| 46 | @Query() query |
| 47 | @Viewer() viewer |
| 48 | ) { |
| 49 | return this.comments |
| 50 | } |
| 51 | |
| 52 | @Get('comments/:comment_id' |
| 53 | @ApiOperation({ summary |
| 54 | get( |
| 55 | @Param('owner' |
| 56 | @Param('repo' |
| 57 | @Param('comment_id' |
| 58 | @Viewer() viewer |
| 59 | ) { |
| 60 | return this.comments |
| 61 | } |
| 62 | |
| 63 | @Patch('comments/:comment_id' |
| 64 | @ApiOperation({ summary |
| 65 | update( |
| 66 | @Param('owner' |
| 67 | @Param('repo' |
| 68 | @Param('comment_id' |
| 69 | @Body() body |
| 70 | @Viewer() viewer |
| 71 | ) { |
| 72 | return this.comments |
| 73 | } |
| 74 | |
| 75 | @Delete('comments/:comment_id' |
| 76 | @HttpCode(204) |
| 77 | @ApiOperation({ summary |
| 78 | delete( |
| 79 | @Param('owner' |
| 80 | @Param('repo' |
| 81 | @Param('comment_id' |
| 82 | @Viewer() viewer |
| 83 | ) { |
| 84 | return this.comments |
| 85 | } |
| 86 | |
| 87 | @Get(':number/comments' |
| 88 | @ApiOperation({ summary |
| 89 | list( |
| 90 | @Param('owner' |
| 91 | @Param('repo' |
| 92 | @Param('number' |
| 93 | @Query() query |
| 94 | @Viewer() viewer |
| 95 | ) { |
| 96 | return this.comments |
| 97 | } |
| 98 | |
| 99 | @Post(':number/comments' |
| 100 | @ApiOperation({ summary |
| 101 | create( |
| 102 | @Param('owner' |
| 103 | @Param('repo' |
| 104 | @Param('number' |
| 105 | @Body() body |
| 106 | @Viewer() viewer |
| 107 | ) { |
| 108 | return this.comments |
| 109 | } |
| 110 | } |