| 1 | import { |
| 2 | Controller, |
| 3 | Param, |
| 4 | ParseIntPipe, |
| 5 | Post, |
| 6 | Query, |
| 7 | Req, |
| 8 | UseFilters, |
| 9 | UseInterceptors, |
| 10 | } from '@nestjs/common'; |
| 11 | import { ApiBody, ApiConsumes |
| 12 | import { AllowAnonymous } |
| 13 | import type { Request |
| 14 | |
| 15 | import type { GithubViewer |
| 16 | import { Viewer } |
| 17 | import { GithubRestFilter } |
| 18 | import { GithubRestInterceptor } |
| 19 | import { GithubUploadReleaseAssetQueryDTO } |
| 20 | import { GithubReleasesService } |
| 21 | |
| 22 | /** The `upload_url` every release carries, under `/api/uploads` as on GitHub Enterprise. No body parser runs here, so a file of any type streams through untouched. */ |
| 23 | @Controller('uploads/repos/:owner/:repo/releases') |
| 24 | @ApiTags('GitHub compatibility') |
| 25 | @AllowAnonymous() |
| 26 | @UseFilters(GithubRestFilter) |
| 27 | @UseInterceptors(GithubRestInterceptor) |
| 28 | export class GithubUploadsController |
| 29 | constructor(private readonly |
| 30 | |
| 31 | @Post(':release_id/assets' |
| 32 | @ApiOperation({ |
| 33 | summary: |
| 34 | "Upload a release asset: the raw bytes, served afterwards with the request's Content-Type", |
| 35 | }) |
| 36 | @ApiConsumes('application/octet-stream' |
| 37 | @ApiBody({ schema |
| 38 | upload( |
| 39 | @Param('owner' |
| 40 | @Param('repo' |
| 41 | @Param('release_id' |
| 42 | releaseId: number, |
| 43 | @Query() query |
| 44 | @Viewer() viewer |
| 45 | @Req() request |
| 46 | ) { |
| 47 | return this.releases |
| 48 | type: request.headers |
| 49 | length: request.headers |
| 50 | body: request, |
| 51 | }); |
| 52 | } |
| 53 | } |