fix slop code, by slop066543613 hours ago69 lines · 2.0 KB | 1 | import { |
| 2 | Body, |
| 3 | Controller, |
| 4 | Get, |
| 5 | HttpCode, |
| 6 | Param, |
| 7 | Post, |
| 8 | UseFilters, |
| 9 | } from '@nestjs/common'; |
| 10 | import { ApiOperation, ApiTags |
| 11 | import { AllowAnonymous } |
| 12 | |
| 13 | import type { GithubViewer |
| 14 | import { Viewer } |
| 15 | import { GithubRestFilter } |
| 16 | import { GithubCreateRepositoryDTO } |
| 17 | import { GithubReposService } |
| 18 | |
| 19 | @Controller('v3') |
| 20 | @ApiTags('GitHub compatibility') |
| 21 | @AllowAnonymous() |
| 22 | @UseFilters(GithubRestFilter) |
| 23 | export class ReposController |
| 24 | constructor(private readonly |
| 25 | |
| 26 | @Get('repos/:owner/:repo' |
| 27 | @ApiOperation({ summary |
| 28 | get( |
| 29 | @Param('owner' |
| 30 | @Param('repo' |
| 31 | @Viewer() viewer |
| 32 | ) { |
| 33 | return this.repos |
| 34 | } |
| 35 | |
| 36 | @Get('repos/:owner/:repo/readme' |
| 37 | @ApiOperation({ |
| 38 | summary: |
| 39 | "The repository's README at the default branch, base64 as GitHub returns it", |
| 40 | }) |
| 41 | readme( |
| 42 | @Param('owner' |
| 43 | @Param('repo' |
| 44 | @Viewer() viewer |
| 45 | ) { |
| 46 | return this.repos |
| 47 | } |
| 48 | |
| 49 | @Post('user/repos' |
| 50 | @HttpCode(201) |
| 51 | @ApiOperation({ summary |
| 52 | createForUser( |
| 53 | @Body() body |
| 54 | @Viewer() viewer |
| 55 | ) { |
| 56 | return this.repos |
| 57 | } |
| 58 | |
| 59 | @Post('orgs/:org/repos' |
| 60 | @HttpCode(201) |
| 61 | @ApiOperation({ summary |
| 62 | createForOrganization( |
| 63 | @Param('org' |
| 64 | @Body() body |
| 65 | @Viewer() viewer |
| 66 | ) { |
| 67 | return this.repos |
| 68 | } |
| 69 | } |
}
from
'
@nestjs/swagger
'
;
from
'
@thallesp/nestjs-better-auth
'
;
}
from
'
../../auth/github-request.js
'
;
from
'
../../auth/viewer.decorator.js
'
;
from
'
../github-rest.filter.js
'
;
from
'
./dto/create-repository.dto.js
'
;
from
'
./repos.service.js
'
;
{
repos
:
GithubReposService
)
{}
)
:
'
A repository, in GitHub REST shape
'
}
)
)
owner
:
string
,
)
repo
:
string
,
:
GithubViewer
|
null
,
.
get
(
{
owner
,
repo
,
viewer
}
)
;
)
)
owner
:
string
,
)
repo
:
string
,
:
GithubViewer
|
null
,
.
readme
(
{
owner
,
repo
,
viewer
}
)
;
)
:
'
Create a repository for the authenticated user
'
}
)
:
GithubCreateRepositoryDTO
,
:
GithubViewer
|
null
,
.
create
(
viewer
,
body
,
undefined
,
'
POST /user/repos
'
)
;
)
:
'
Create a repository in an organization
'
}
)
)
org
:
string
,
:
GithubCreateRepositoryDTO
,
:
GithubViewer
|
null
,
.
create
(
viewer
,
body
,
org
,
'
POST /orgs/:org/repos
'
)
;