From b78c94c3a15db5db565aa533190df8b0c3b8a989 Mon Sep 17 00:00:00 2001 From: David Mehren Date: Tue, 23 Feb 2021 21:20:01 +0100 Subject: [PATCH] Use Req decorator instead of Request This avoids a clash with the Request type from express Signed-off-by: David Mehren --- src/api/public/me/me.controller.ts | 12 ++++++------ src/api/public/media/media.controller.ts | 6 +++--- src/api/public/notes/notes.controller.ts | 22 +++++++++++----------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/api/public/me/me.controller.ts b/src/api/public/me/me.controller.ts index db5d48626..b445b0968 100644 --- a/src/api/public/me/me.controller.ts +++ b/src/api/public/me/me.controller.ts @@ -14,7 +14,7 @@ import { Param, Put, UseGuards, - Request, + Req, } from '@nestjs/common'; import { HistoryEntryUpdateDto } from '../../../history/history-entry-update.dto'; import { HistoryService } from '../../../history/history.service'; @@ -43,7 +43,7 @@ export class MeController { @UseGuards(TokenAuthGuard) @Get() - async getMe(@Request() req): Promise { + async getMe(@Req() req): Promise { return this.usersService.toUserDto( await this.usersService.getUserByUsername(req.user.userName), ); @@ -51,7 +51,7 @@ export class MeController { @UseGuards(TokenAuthGuard) @Get('history') - async getUserHistory(@Request() req): Promise { + async getUserHistory(@Req() req): Promise { const foundEntries = await this.historyService.getEntriesByUser(req.user); return await Promise.all( foundEntries.map( @@ -63,7 +63,7 @@ export class MeController { @UseGuards(TokenAuthGuard) @Put('history/:note') async updateHistoryEntry( - @Request() req, + @Req() req, @Param('note') note: string, @Body() entryUpdateDto: HistoryEntryUpdateDto, ): Promise { @@ -87,7 +87,7 @@ export class MeController { @UseGuards(TokenAuthGuard) @Delete('history/:note') @HttpCode(204) - deleteHistoryEntry(@Request() req, @Param('note') note: string) { + deleteHistoryEntry(@Req() req, @Param('note') note: string) { // ToDo: Check if user is allowed to delete note try { return this.historyService.deleteHistoryEntry(note, req.user); @@ -101,7 +101,7 @@ export class MeController { @UseGuards(TokenAuthGuard) @Get('notes') - async getMyNotes(@Request() req): Promise { + async getMyNotes(@Req() req): Promise { const notes = this.notesService.getUserNotes(req.user); return await Promise.all( notes.map((note) => this.notesService.toNoteMetadataDto(note)), diff --git a/src/api/public/media/media.controller.ts b/src/api/public/media/media.controller.ts index 4520e6b91..730f5c35a 100644 --- a/src/api/public/media/media.controller.ts +++ b/src/api/public/media/media.controller.ts @@ -13,7 +13,7 @@ import { NotFoundException, Param, Post, - Request, + Req, UnauthorizedException, UploadedFile, UseGuards, @@ -48,7 +48,7 @@ export class MediaController { @Post() @UseInterceptors(FileInterceptor('file')) async uploadMedia( - @Request() req, + @Req() req, @UploadedFile() file: MulterFile, @Headers('HedgeDoc-Note') noteId: string, ): Promise { @@ -80,7 +80,7 @@ export class MediaController { @UseGuards(TokenAuthGuard) @Delete(':filename') async deleteMedia( - @Request() req, + @Req() req, @Param('filename') filename: string, ): Promise { const username = req.user.userName; diff --git a/src/api/public/notes/notes.controller.ts b/src/api/public/notes/notes.controller.ts index da3baab93..dc110a288 100644 --- a/src/api/public/notes/notes.controller.ts +++ b/src/api/public/notes/notes.controller.ts @@ -15,7 +15,7 @@ import { Param, Post, Put, - Request, + Req, UnauthorizedException, UseGuards, } from '@nestjs/common'; @@ -59,7 +59,7 @@ export class NotesController { @UseGuards(TokenAuthGuard) @Post() async createNote( - @Request() req, + @Req() req, @MarkdownBody() text: string, ): Promise { // ToDo: provide user for createNoteDto @@ -75,7 +75,7 @@ export class NotesController { @UseGuards(TokenAuthGuard) @Get(':noteIdOrAlias') async getNote( - @Request() req, + @Req() req, @Param('noteIdOrAlias') noteIdOrAlias: string, ): Promise { let note: Note; @@ -97,7 +97,7 @@ export class NotesController { @UseGuards(TokenAuthGuard) @Post(':noteAlias') async createNamedNote( - @Request() req, + @Req() req, @Param('noteAlias') noteAlias: string, @MarkdownBody() text: string, ): Promise { @@ -120,7 +120,7 @@ export class NotesController { @UseGuards(TokenAuthGuard) @Delete(':noteIdOrAlias') async deleteNote( - @Request() req, + @Req() req, @Param('noteIdOrAlias') noteIdOrAlias: string, ): Promise { try { @@ -143,7 +143,7 @@ export class NotesController { @UseGuards(TokenAuthGuard) @Put(':noteIdOrAlias') async updateNote( - @Request() req, + @Req() req, @Param('noteIdOrAlias') noteIdOrAlias: string, @MarkdownBody() text: string, ): Promise { @@ -168,7 +168,7 @@ export class NotesController { @Get(':noteIdOrAlias/content') @Header('content-type', 'text/markdown') async getNoteContent( - @Request() req, + @Req() req, @Param('noteIdOrAlias') noteIdOrAlias: string, ): Promise { try { @@ -188,7 +188,7 @@ export class NotesController { @UseGuards(TokenAuthGuard) @Get(':noteIdOrAlias/metadata') async getNoteMetadata( - @Request() req, + @Req() req, @Param('noteIdOrAlias') noteIdOrAlias: string, ): Promise { try { @@ -211,7 +211,7 @@ export class NotesController { @UseGuards(TokenAuthGuard) @Put(':noteIdOrAlias/metadata/permissions') async updateNotePermissions( - @Request() req, + @Req() req, @Param('noteIdOrAlias') noteIdOrAlias: string, @Body() updateDto: NotePermissionsUpdateDto, ): Promise { @@ -234,7 +234,7 @@ export class NotesController { @UseGuards(TokenAuthGuard) @Get(':noteIdOrAlias/revisions') async getNoteRevisions( - @Request() req, + @Req() req, @Param('noteIdOrAlias') noteIdOrAlias: string, ): Promise { try { @@ -259,7 +259,7 @@ export class NotesController { @UseGuards(TokenAuthGuard) @Get(':noteIdOrAlias/revisions/:revisionId') async getNoteRevision( - @Request() req, + @Req() req, @Param('noteIdOrAlias') noteIdOrAlias: string, @Param('revisionId') revisionId: number, ): Promise {