mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-06-04 00:48:51 -04:00
refactor: use new openapi decorator
Also remove fullapi decorator, because it's fully replaced by the openapi decorator. Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
a283002a34
commit
89aac9d4b6
14 changed files with 248 additions and 445 deletions
|
@ -8,20 +8,13 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
HttpCode,
|
||||
Param,
|
||||
Post,
|
||||
Put,
|
||||
UnauthorizedException,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
ApiBadRequestResponse,
|
||||
ApiNoContentResponse,
|
||||
ApiOkResponse,
|
||||
ApiSecurity,
|
||||
ApiTags,
|
||||
} from '@nestjs/swagger';
|
||||
import { ApiSecurity, ApiTags } from '@nestjs/swagger';
|
||||
|
||||
import { TokenAuthGuard } from '../../../auth/token.strategy';
|
||||
import { ConsoleLoggerService } from '../../../logger/console-logger.service';
|
||||
|
@ -32,11 +25,11 @@ import { AliasService } from '../../../notes/alias.service';
|
|||
import { NotesService } from '../../../notes/notes.service';
|
||||
import { PermissionsService } from '../../../permissions/permissions.service';
|
||||
import { User } from '../../../users/user.entity';
|
||||
import { badRequestDescription } from '../../utils/descriptions';
|
||||
import { FullApi } from '../../utils/fullapi-decorator';
|
||||
import { OpenApi } from '../../utils/openapi.decorator';
|
||||
import { RequestUser } from '../../utils/request-user.decorator';
|
||||
|
||||
@UseGuards(TokenAuthGuard)
|
||||
@OpenApi(401)
|
||||
@ApiTags('alias')
|
||||
@ApiSecurity('token')
|
||||
@Controller('alias')
|
||||
|
@ -51,11 +44,15 @@ export class AliasController {
|
|||
}
|
||||
|
||||
@Post()
|
||||
@ApiOkResponse({
|
||||
description: 'The new alias',
|
||||
type: AliasDto,
|
||||
})
|
||||
@FullApi
|
||||
@OpenApi(
|
||||
{
|
||||
code: 200,
|
||||
description: 'The new alias',
|
||||
dto: AliasDto,
|
||||
},
|
||||
403,
|
||||
404,
|
||||
)
|
||||
async addAlias(
|
||||
@RequestUser() user: User,
|
||||
@Body() newAliasDto: AliasCreateDto,
|
||||
|
@ -74,11 +71,15 @@ export class AliasController {
|
|||
}
|
||||
|
||||
@Put(':alias')
|
||||
@ApiOkResponse({
|
||||
description: 'The updated alias',
|
||||
type: AliasDto,
|
||||
})
|
||||
@FullApi
|
||||
@OpenApi(
|
||||
{
|
||||
code: 200,
|
||||
description: 'The updated alias',
|
||||
dto: AliasDto,
|
||||
},
|
||||
403,
|
||||
404,
|
||||
)
|
||||
async makeAliasPrimary(
|
||||
@RequestUser() user: User,
|
||||
@Param('alias') alias: string,
|
||||
|
@ -98,14 +99,15 @@ export class AliasController {
|
|||
}
|
||||
|
||||
@Delete(':alias')
|
||||
@HttpCode(204)
|
||||
@ApiNoContentResponse({
|
||||
description: 'The alias was deleted',
|
||||
})
|
||||
@FullApi
|
||||
@ApiBadRequestResponse({
|
||||
description: badRequestDescription,
|
||||
})
|
||||
@OpenApi(
|
||||
{
|
||||
code: 204,
|
||||
description: 'The alias was deleted',
|
||||
},
|
||||
400,
|
||||
403,
|
||||
404,
|
||||
)
|
||||
async removeAlias(
|
||||
@RequestUser() user: User,
|
||||
@Param('alias') alias: string,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
@ -8,19 +8,11 @@ import {
|
|||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
HttpCode,
|
||||
Put,
|
||||
UseGuards,
|
||||
UseInterceptors,
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
ApiNoContentResponse,
|
||||
ApiNotFoundResponse,
|
||||
ApiOkResponse,
|
||||
ApiSecurity,
|
||||
ApiTags,
|
||||
ApiUnauthorizedResponse,
|
||||
} from '@nestjs/swagger';
|
||||
import { ApiSecurity, ApiTags } from '@nestjs/swagger';
|
||||
|
||||
import { TokenAuthGuard } from '../../../auth/token.strategy';
|
||||
import { HistoryEntryUpdateDto } from '../../../history/history-entry-update.dto';
|
||||
|
@ -35,16 +27,13 @@ import { NotesService } from '../../../notes/notes.service';
|
|||
import { UserInfoDto } from '../../../users/user-info.dto';
|
||||
import { User } from '../../../users/user.entity';
|
||||
import { UsersService } from '../../../users/users.service';
|
||||
import {
|
||||
notFoundDescription,
|
||||
successfullyDeletedDescription,
|
||||
unauthorizedDescription,
|
||||
} from '../../utils/descriptions';
|
||||
import { GetNoteInterceptor } from '../../utils/get-note.interceptor';
|
||||
import { OpenApi } from '../../utils/openapi.decorator';
|
||||
import { RequestNote } from '../../utils/request-note.decorator';
|
||||
import { RequestUser } from '../../utils/request-user.decorator';
|
||||
|
||||
@UseGuards(TokenAuthGuard)
|
||||
@OpenApi(401)
|
||||
@ApiTags('me')
|
||||
@ApiSecurity('token')
|
||||
@Controller('me')
|
||||
|
@ -60,22 +49,22 @@ export class MeController {
|
|||
}
|
||||
|
||||
@Get()
|
||||
@ApiOkResponse({
|
||||
@OpenApi({
|
||||
code: 200,
|
||||
description: 'The user information',
|
||||
type: UserInfoDto,
|
||||
dto: UserInfoDto,
|
||||
})
|
||||
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
||||
getMe(@RequestUser() user: User): UserInfoDto {
|
||||
return this.usersService.toUserDto(user);
|
||||
}
|
||||
|
||||
@Get('history')
|
||||
@ApiOkResponse({
|
||||
@OpenApi({
|
||||
code: 200,
|
||||
description: 'The history entries of the user',
|
||||
isArray: true,
|
||||
type: HistoryEntryDto,
|
||||
dto: HistoryEntryDto,
|
||||
})
|
||||
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
||||
async getUserHistory(@RequestUser() user: User): Promise<HistoryEntryDto[]> {
|
||||
const foundEntries = await this.historyService.getEntriesByUser(user);
|
||||
return await Promise.all(
|
||||
|
@ -85,12 +74,14 @@ export class MeController {
|
|||
|
||||
@UseInterceptors(GetNoteInterceptor)
|
||||
@Get('history/:noteIdOrAlias')
|
||||
@ApiOkResponse({
|
||||
description: 'The history entry of the user which points to the note',
|
||||
type: HistoryEntryDto,
|
||||
})
|
||||
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
||||
@ApiNotFoundResponse({ description: notFoundDescription })
|
||||
@OpenApi(
|
||||
{
|
||||
code: 200,
|
||||
description: 'The history entry of the user which points to the note',
|
||||
dto: HistoryEntryDto,
|
||||
},
|
||||
404,
|
||||
)
|
||||
async getHistoryEntry(
|
||||
@RequestUser() user: User,
|
||||
@RequestNote() note: Note,
|
||||
|
@ -101,12 +92,14 @@ export class MeController {
|
|||
|
||||
@UseInterceptors(GetNoteInterceptor)
|
||||
@Put('history/:noteIdOrAlias')
|
||||
@ApiOkResponse({
|
||||
description: 'The updated history entry',
|
||||
type: HistoryEntryDto,
|
||||
})
|
||||
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
||||
@ApiNotFoundResponse({ description: notFoundDescription })
|
||||
@OpenApi(
|
||||
{
|
||||
code: 200,
|
||||
description: 'The updated history entry',
|
||||
dto: HistoryEntryDto,
|
||||
},
|
||||
404,
|
||||
)
|
||||
async updateHistoryEntry(
|
||||
@RequestUser() user: User,
|
||||
@RequestNote() note: Note,
|
||||
|
@ -120,10 +113,7 @@ export class MeController {
|
|||
|
||||
@UseInterceptors(GetNoteInterceptor)
|
||||
@Delete('history/:noteIdOrAlias')
|
||||
@HttpCode(204)
|
||||
@ApiNoContentResponse({ description: successfullyDeletedDescription })
|
||||
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
||||
@ApiNotFoundResponse({ description: notFoundDescription })
|
||||
@OpenApi(204, 404)
|
||||
async deleteHistoryEntry(
|
||||
@RequestUser() user: User,
|
||||
@RequestNote() note: Note,
|
||||
|
@ -133,12 +123,12 @@ export class MeController {
|
|||
}
|
||||
|
||||
@Get('notes')
|
||||
@ApiOkResponse({
|
||||
@OpenApi({
|
||||
code: 200,
|
||||
description: 'Metadata of all notes of the user',
|
||||
isArray: true,
|
||||
type: NoteMetadataDto,
|
||||
dto: NoteMetadataDto,
|
||||
})
|
||||
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
||||
async getMyNotes(@RequestUser() user: User): Promise<NoteMetadataDto[]> {
|
||||
const notes = this.notesService.getUserNotes(user);
|
||||
return await Promise.all(
|
||||
|
@ -147,12 +137,12 @@ export class MeController {
|
|||
}
|
||||
|
||||
@Get('media')
|
||||
@ApiOkResponse({
|
||||
@OpenApi({
|
||||
code: 200,
|
||||
description: 'All media uploads of the user',
|
||||
isArray: true,
|
||||
type: MediaUploadDto,
|
||||
dto: MediaUploadDto,
|
||||
})
|
||||
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
||||
async getMyMedia(@RequestUser() user: User): Promise<MediaUploadDto[]> {
|
||||
const media = await this.mediaService.listUploadsByUser(user);
|
||||
return await Promise.all(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
@ -7,7 +7,6 @@ import {
|
|||
Controller,
|
||||
Delete,
|
||||
Headers,
|
||||
HttpCode,
|
||||
Param,
|
||||
Post,
|
||||
UploadedFile,
|
||||
|
@ -16,18 +15,11 @@ import {
|
|||
} from '@nestjs/common';
|
||||
import { FileInterceptor } from '@nestjs/platform-express';
|
||||
import {
|
||||
ApiBadRequestResponse,
|
||||
ApiBody,
|
||||
ApiConsumes,
|
||||
ApiCreatedResponse,
|
||||
ApiForbiddenResponse,
|
||||
ApiHeader,
|
||||
ApiInternalServerErrorResponse,
|
||||
ApiNoContentResponse,
|
||||
ApiNotFoundResponse,
|
||||
ApiSecurity,
|
||||
ApiTags,
|
||||
ApiUnauthorizedResponse,
|
||||
} from '@nestjs/swagger';
|
||||
|
||||
import { TokenAuthGuard } from '../../../auth/token.strategy';
|
||||
|
@ -39,18 +31,11 @@ import { MulterFile } from '../../../media/multer-file.interface';
|
|||
import { Note } from '../../../notes/note.entity';
|
||||
import { NotesService } from '../../../notes/notes.service';
|
||||
import { User } from '../../../users/user.entity';
|
||||
import {
|
||||
badRequestDescription,
|
||||
forbiddenDescription,
|
||||
internalServerErrorDescription,
|
||||
notFoundDescription,
|
||||
successfullyDeletedDescription,
|
||||
unauthorizedDescription,
|
||||
} from '../../utils/descriptions';
|
||||
import { FullApi } from '../../utils/fullapi-decorator';
|
||||
import { OpenApi } from '../../utils/openapi.decorator';
|
||||
import { RequestUser } from '../../utils/request-user.decorator';
|
||||
|
||||
@UseGuards(TokenAuthGuard)
|
||||
@OpenApi(401)
|
||||
@ApiTags('media')
|
||||
@ApiSecurity('token')
|
||||
@Controller('media')
|
||||
|
@ -80,19 +65,18 @@ export class MediaController {
|
|||
name: 'HedgeDoc-Note',
|
||||
description: 'ID or alias of the parent note',
|
||||
})
|
||||
@ApiCreatedResponse({
|
||||
description: 'The file was uploaded successfully',
|
||||
type: MediaUploadUrlDto,
|
||||
})
|
||||
@ApiBadRequestResponse({ description: badRequestDescription })
|
||||
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
||||
@ApiForbiddenResponse({ description: forbiddenDescription })
|
||||
@ApiNotFoundResponse({ description: notFoundDescription })
|
||||
@ApiInternalServerErrorResponse({
|
||||
description: internalServerErrorDescription,
|
||||
})
|
||||
@OpenApi(
|
||||
{
|
||||
code: 201,
|
||||
description: 'The file was uploaded successfully',
|
||||
dto: MediaUploadUrlDto,
|
||||
},
|
||||
400,
|
||||
403,
|
||||
404,
|
||||
500,
|
||||
)
|
||||
@UseInterceptors(FileInterceptor('file'))
|
||||
@HttpCode(201)
|
||||
async uploadMedia(
|
||||
@RequestUser() user: User,
|
||||
@UploadedFile() file: MulterFile,
|
||||
|
@ -109,12 +93,7 @@ export class MediaController {
|
|||
}
|
||||
|
||||
@Delete(':filename')
|
||||
@HttpCode(204)
|
||||
@ApiNoContentResponse({ description: successfullyDeletedDescription })
|
||||
@ApiInternalServerErrorResponse({
|
||||
description: internalServerErrorDescription,
|
||||
})
|
||||
@FullApi
|
||||
@OpenApi(204, 403, 404, 500)
|
||||
async deleteMedia(
|
||||
@RequestUser() user: User,
|
||||
@Param('filename') filename: string,
|
||||
|
|
|
@ -1,27 +1,18 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { Controller, Get, UseGuards } from '@nestjs/common';
|
||||
import {
|
||||
ApiForbiddenResponse,
|
||||
ApiOkResponse,
|
||||
ApiProduces,
|
||||
ApiSecurity,
|
||||
ApiTags,
|
||||
ApiUnauthorizedResponse,
|
||||
} from '@nestjs/swagger';
|
||||
import { ApiSecurity, ApiTags } from '@nestjs/swagger';
|
||||
|
||||
import { TokenAuthGuard } from '../../../auth/token.strategy';
|
||||
import { MonitoringService } from '../../../monitoring/monitoring.service';
|
||||
import { ServerStatusDto } from '../../../monitoring/server-status.dto';
|
||||
import {
|
||||
forbiddenDescription,
|
||||
unauthorizedDescription,
|
||||
} from '../../utils/descriptions';
|
||||
import { OpenApi } from '../../utils/openapi.decorator';
|
||||
|
||||
@UseGuards(TokenAuthGuard)
|
||||
@OpenApi(401)
|
||||
@ApiTags('monitoring')
|
||||
@ApiSecurity('token')
|
||||
@Controller('monitoring')
|
||||
|
@ -29,24 +20,28 @@ export class MonitoringController {
|
|||
constructor(private monitoringService: MonitoringService) {}
|
||||
|
||||
@Get()
|
||||
@ApiOkResponse({
|
||||
description: 'The server info',
|
||||
type: ServerStatusDto,
|
||||
})
|
||||
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
||||
@ApiForbiddenResponse({ description: forbiddenDescription })
|
||||
@OpenApi(
|
||||
{
|
||||
code: 200,
|
||||
description: 'The server info',
|
||||
dto: ServerStatusDto,
|
||||
},
|
||||
403,
|
||||
)
|
||||
getStatus(): Promise<ServerStatusDto> {
|
||||
// TODO: toServerStatusDto.
|
||||
return this.monitoringService.getServerStatus();
|
||||
}
|
||||
|
||||
@Get('prometheus')
|
||||
@ApiOkResponse({
|
||||
description: 'Prometheus compatible monitoring data',
|
||||
})
|
||||
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
||||
@ApiForbiddenResponse({ description: forbiddenDescription })
|
||||
@ApiProduces('text/plain')
|
||||
@OpenApi(
|
||||
{
|
||||
code: 200,
|
||||
description: 'Prometheus compatible monitoring data',
|
||||
mimeType: 'text/plain',
|
||||
},
|
||||
403,
|
||||
)
|
||||
getPrometheusStatus(): string {
|
||||
return '';
|
||||
}
|
||||
|
|
|
@ -8,27 +8,13 @@ import {
|
|||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
Header,
|
||||
HttpCode,
|
||||
Param,
|
||||
Post,
|
||||
Put,
|
||||
UseGuards,
|
||||
UseInterceptors,
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
ApiBadRequestResponse,
|
||||
ApiConflictResponse,
|
||||
ApiCreatedResponse,
|
||||
ApiForbiddenResponse,
|
||||
ApiInternalServerErrorResponse,
|
||||
ApiNoContentResponse,
|
||||
ApiOkResponse,
|
||||
ApiProduces,
|
||||
ApiSecurity,
|
||||
ApiTags,
|
||||
ApiUnauthorizedResponse,
|
||||
} from '@nestjs/swagger';
|
||||
import { ApiSecurity, ApiTags } from '@nestjs/swagger';
|
||||
|
||||
import { TokenAuthGuard } from '../../../auth/token.strategy';
|
||||
import { HistoryService } from '../../../history/history.service';
|
||||
|
@ -49,23 +35,16 @@ import { RevisionMetadataDto } from '../../../revisions/revision-metadata.dto';
|
|||
import { RevisionDto } from '../../../revisions/revision.dto';
|
||||
import { RevisionsService } from '../../../revisions/revisions.service';
|
||||
import { User } from '../../../users/user.entity';
|
||||
import {
|
||||
badRequestDescription,
|
||||
conflictDescription,
|
||||
forbiddenDescription,
|
||||
internalServerErrorDescription,
|
||||
successfullyDeletedDescription,
|
||||
unauthorizedDescription,
|
||||
} from '../../utils/descriptions';
|
||||
import { FullApi } from '../../utils/fullapi-decorator';
|
||||
import { GetNoteInterceptor } from '../../utils/get-note.interceptor';
|
||||
import { MarkdownBody } from '../../utils/markdown-body.decorator';
|
||||
import { OpenApi } from '../../utils/openapi.decorator';
|
||||
import { Permissions } from '../../utils/permissions.decorator';
|
||||
import { PermissionsGuard } from '../../utils/permissions.guard';
|
||||
import { RequestNote } from '../../utils/request-note.decorator';
|
||||
import { RequestUser } from '../../utils/request-user.decorator';
|
||||
|
||||
@UseGuards(TokenAuthGuard)
|
||||
@UseGuards(TokenAuthGuard, PermissionsGuard)
|
||||
@OpenApi(401)
|
||||
@ApiTags('notes')
|
||||
@ApiSecurity('token')
|
||||
@Controller('notes')
|
||||
|
@ -81,11 +60,8 @@ export class NotesController {
|
|||
}
|
||||
|
||||
@Permissions(Permission.CREATE)
|
||||
@UseGuards(TokenAuthGuard, PermissionsGuard)
|
||||
@Post()
|
||||
@HttpCode(201)
|
||||
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
||||
@ApiForbiddenResponse({ description: forbiddenDescription })
|
||||
@OpenApi(201, 403, 409)
|
||||
async createNote(
|
||||
@RequestUser() user: User,
|
||||
@MarkdownBody() text: string,
|
||||
|
@ -98,13 +74,16 @@ export class NotesController {
|
|||
|
||||
@UseInterceptors(GetNoteInterceptor)
|
||||
@Permissions(Permission.READ)
|
||||
@UseGuards(PermissionsGuard)
|
||||
@Get(':noteIdOrAlias')
|
||||
@ApiOkResponse({
|
||||
description: 'Get information about the newly created note',
|
||||
type: NoteDto,
|
||||
})
|
||||
@FullApi
|
||||
@OpenApi(
|
||||
{
|
||||
code: 200,
|
||||
description: 'Get information about the newly created note',
|
||||
dto: NoteDto,
|
||||
},
|
||||
403,
|
||||
404,
|
||||
)
|
||||
async getNote(
|
||||
@RequestUser() user: User,
|
||||
@RequestNote() note: Note,
|
||||
|
@ -116,15 +95,16 @@ export class NotesController {
|
|||
@Permissions(Permission.CREATE)
|
||||
@UseGuards(PermissionsGuard)
|
||||
@Post(':noteAlias')
|
||||
@HttpCode(201)
|
||||
@ApiCreatedResponse({
|
||||
description: 'Get information about the newly created note',
|
||||
type: NoteDto,
|
||||
})
|
||||
@ApiBadRequestResponse({ description: badRequestDescription })
|
||||
@ApiConflictResponse({ description: conflictDescription })
|
||||
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
||||
@ApiForbiddenResponse({ description: forbiddenDescription })
|
||||
@OpenApi(
|
||||
{
|
||||
code: 201,
|
||||
description: 'Get information about the newly created note',
|
||||
dto: NoteDto,
|
||||
},
|
||||
400,
|
||||
403,
|
||||
409,
|
||||
)
|
||||
async createNamedNote(
|
||||
@RequestUser() user: User,
|
||||
@Param('noteAlias') noteAlias: string,
|
||||
|
@ -138,14 +118,8 @@ export class NotesController {
|
|||
|
||||
@UseInterceptors(GetNoteInterceptor)
|
||||
@Permissions(Permission.OWNER)
|
||||
@UseGuards(PermissionsGuard)
|
||||
@Delete(':noteIdOrAlias')
|
||||
@HttpCode(204)
|
||||
@ApiNoContentResponse({ description: successfullyDeletedDescription })
|
||||
@FullApi
|
||||
@ApiInternalServerErrorResponse({
|
||||
description: internalServerErrorDescription,
|
||||
})
|
||||
@OpenApi(204, 403, 404, 500)
|
||||
async deleteNote(
|
||||
@RequestUser() user: User,
|
||||
@RequestNote() note: Note,
|
||||
|
@ -167,13 +141,16 @@ export class NotesController {
|
|||
|
||||
@UseInterceptors(GetNoteInterceptor)
|
||||
@Permissions(Permission.WRITE)
|
||||
@UseGuards(PermissionsGuard)
|
||||
@Put(':noteIdOrAlias')
|
||||
@ApiOkResponse({
|
||||
description: 'The new, changed note',
|
||||
type: NoteDto,
|
||||
})
|
||||
@FullApi
|
||||
@OpenApi(
|
||||
{
|
||||
code: 200,
|
||||
description: 'The new, changed note',
|
||||
dto: NoteDto,
|
||||
},
|
||||
403,
|
||||
404,
|
||||
)
|
||||
async updateNote(
|
||||
@RequestUser() user: User,
|
||||
@RequestNote() note: Note,
|
||||
|
@ -187,14 +164,16 @@ export class NotesController {
|
|||
|
||||
@UseInterceptors(GetNoteInterceptor)
|
||||
@Permissions(Permission.READ)
|
||||
@UseGuards(PermissionsGuard)
|
||||
@Get(':noteIdOrAlias/content')
|
||||
@ApiProduces('text/markdown')
|
||||
@ApiOkResponse({
|
||||
description: 'The raw markdown content of the note',
|
||||
})
|
||||
@FullApi
|
||||
@Header('content-type', 'text/markdown')
|
||||
@OpenApi(
|
||||
{
|
||||
code: 200,
|
||||
description: 'The raw markdown content of the note',
|
||||
mimeType: 'text/markdown',
|
||||
},
|
||||
403,
|
||||
404,
|
||||
)
|
||||
async getNoteContent(
|
||||
@RequestUser() user: User,
|
||||
@RequestNote() note: Note,
|
||||
|
@ -204,13 +183,16 @@ export class NotesController {
|
|||
|
||||
@UseInterceptors(GetNoteInterceptor)
|
||||
@Permissions(Permission.READ)
|
||||
@UseGuards(PermissionsGuard)
|
||||
@Get(':noteIdOrAlias/metadata')
|
||||
@ApiOkResponse({
|
||||
description: 'The metadata of the note',
|
||||
type: NoteMetadataDto,
|
||||
})
|
||||
@FullApi
|
||||
@OpenApi(
|
||||
{
|
||||
code: 200,
|
||||
description: 'The metadata of the note',
|
||||
dto: NoteMetadataDto,
|
||||
},
|
||||
403,
|
||||
404,
|
||||
)
|
||||
async getNoteMetadata(
|
||||
@RequestUser() user: User,
|
||||
@RequestNote() note: Note,
|
||||
|
@ -220,13 +202,16 @@ export class NotesController {
|
|||
|
||||
@UseInterceptors(GetNoteInterceptor)
|
||||
@Permissions(Permission.OWNER)
|
||||
@UseGuards(PermissionsGuard)
|
||||
@Put(':noteIdOrAlias/metadata/permissions')
|
||||
@ApiOkResponse({
|
||||
description: 'The updated permissions of the note',
|
||||
type: NotePermissionsDto,
|
||||
})
|
||||
@FullApi
|
||||
@OpenApi(
|
||||
{
|
||||
code: 200,
|
||||
description: 'The updated permissions of the note',
|
||||
dto: NotePermissionsDto,
|
||||
},
|
||||
403,
|
||||
404,
|
||||
)
|
||||
async updateNotePermissions(
|
||||
@RequestUser() user: User,
|
||||
@RequestNote() note: Note,
|
||||
|
@ -239,14 +224,17 @@ export class NotesController {
|
|||
|
||||
@UseInterceptors(GetNoteInterceptor)
|
||||
@Permissions(Permission.READ)
|
||||
@UseGuards(PermissionsGuard)
|
||||
@Get(':noteIdOrAlias/revisions')
|
||||
@ApiOkResponse({
|
||||
description: 'Revisions of the note',
|
||||
isArray: true,
|
||||
type: RevisionMetadataDto,
|
||||
})
|
||||
@FullApi
|
||||
@OpenApi(
|
||||
{
|
||||
code: 200,
|
||||
description: 'Revisions of the note',
|
||||
isArray: true,
|
||||
dto: RevisionMetadataDto,
|
||||
},
|
||||
403,
|
||||
404,
|
||||
)
|
||||
async getNoteRevisions(
|
||||
@RequestUser() user: User,
|
||||
@RequestNote() note: Note,
|
||||
|
@ -261,13 +249,16 @@ export class NotesController {
|
|||
|
||||
@UseInterceptors(GetNoteInterceptor)
|
||||
@Permissions(Permission.READ)
|
||||
@UseGuards(PermissionsGuard)
|
||||
@Get(':noteIdOrAlias/revisions/:revisionId')
|
||||
@ApiOkResponse({
|
||||
description: 'Revision of the note for the given id or alias',
|
||||
type: RevisionDto,
|
||||
})
|
||||
@FullApi
|
||||
@OpenApi(
|
||||
{
|
||||
code: 200,
|
||||
description: 'Revision of the note for the given id or alias',
|
||||
dto: RevisionDto,
|
||||
},
|
||||
403,
|
||||
404,
|
||||
)
|
||||
async getNoteRevision(
|
||||
@RequestUser() user: User,
|
||||
@RequestNote() note: Note,
|
||||
|
@ -280,14 +271,13 @@ export class NotesController {
|
|||
|
||||
@UseInterceptors(GetNoteInterceptor)
|
||||
@Permissions(Permission.READ)
|
||||
@UseGuards(PermissionsGuard)
|
||||
@Get(':noteIdOrAlias/media')
|
||||
@ApiOkResponse({
|
||||
@OpenApi({
|
||||
code: 200,
|
||||
description: 'All media uploads of the note',
|
||||
isArray: true,
|
||||
type: MediaUploadDto,
|
||||
dto: MediaUploadDto,
|
||||
})
|
||||
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
||||
async getNotesMedia(
|
||||
@RequestUser() user: User,
|
||||
@RequestNote() note: Note,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue