mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-23 10:16:32 -05:00
Use Req decorator instead of Request
This avoids a clash with the Request type from express Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
2b14ad92cd
commit
b78c94c3a1
3 changed files with 20 additions and 20 deletions
|
@ -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<UserInfoDto> {
|
||||
async getMe(@Req() req): Promise<UserInfoDto> {
|
||||
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<HistoryEntryDto[]> {
|
||||
async getUserHistory(@Req() req): Promise<HistoryEntryDto[]> {
|
||||
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<HistoryEntryDto> {
|
||||
|
@ -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<NoteMetadataDto[]> {
|
||||
async getMyNotes(@Req() req): Promise<NoteMetadataDto[]> {
|
||||
const notes = this.notesService.getUserNotes(req.user);
|
||||
return await Promise.all(
|
||||
notes.map((note) => this.notesService.toNoteMetadataDto(note)),
|
||||
|
|
|
@ -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<MediaUploadUrlDto> {
|
||||
|
@ -80,7 +80,7 @@ export class MediaController {
|
|||
@UseGuards(TokenAuthGuard)
|
||||
@Delete(':filename')
|
||||
async deleteMedia(
|
||||
@Request() req,
|
||||
@Req() req,
|
||||
@Param('filename') filename: string,
|
||||
): Promise<void> {
|
||||
const username = req.user.userName;
|
||||
|
|
|
@ -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<NoteDto> {
|
||||
// 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<NoteDto> {
|
||||
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<NoteDto> {
|
||||
|
@ -120,7 +120,7 @@ export class NotesController {
|
|||
@UseGuards(TokenAuthGuard)
|
||||
@Delete(':noteIdOrAlias')
|
||||
async deleteNote(
|
||||
@Request() req,
|
||||
@Req() req,
|
||||
@Param('noteIdOrAlias') noteIdOrAlias: string,
|
||||
): Promise<void> {
|
||||
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<NoteDto> {
|
||||
|
@ -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<string> {
|
||||
try {
|
||||
|
@ -188,7 +188,7 @@ export class NotesController {
|
|||
@UseGuards(TokenAuthGuard)
|
||||
@Get(':noteIdOrAlias/metadata')
|
||||
async getNoteMetadata(
|
||||
@Request() req,
|
||||
@Req() req,
|
||||
@Param('noteIdOrAlias') noteIdOrAlias: string,
|
||||
): Promise<NoteMetadataDto> {
|
||||
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<NotePermissionsDto> {
|
||||
|
@ -234,7 +234,7 @@ export class NotesController {
|
|||
@UseGuards(TokenAuthGuard)
|
||||
@Get(':noteIdOrAlias/revisions')
|
||||
async getNoteRevisions(
|
||||
@Request() req,
|
||||
@Req() req,
|
||||
@Param('noteIdOrAlias') noteIdOrAlias: string,
|
||||
): Promise<RevisionMetadataDto[]> {
|
||||
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<RevisionDto> {
|
||||
|
|
Loading…
Reference in a new issue