ESLint: Enable @typescript-eslint/return-await rule

This ensures stack traces are helpful at the cost of a slightly
lower performance (one more tick in the event loop).

Fixes #838

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2021-02-20 20:14:36 +01:00
parent 6a6dc7ea21
commit 6ffeb2e9c9
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3
8 changed files with 26 additions and 20 deletions

View file

@ -44,12 +44,16 @@ export class TokensController {
@Body('validUntil') validUntil: TimestampMillis,
): Promise<AuthTokenWithSecretDto> {
// ToDo: Get real userName
return this.authService.createTokenForUser('hardcoded', label, validUntil);
return await this.authService.createTokenForUser(
'hardcoded',
label,
validUntil,
);
}
@Delete('/:keyId')
@HttpCode(204)
async deleteToken(@Param('keyId') keyId: string) {
return this.authService.removeToken(keyId);
return await this.authService.removeToken(keyId);
}
}

View file

@ -53,7 +53,7 @@ export class MeController {
@Get('history')
async getUserHistory(@Request() req): Promise<HistoryEntryDto[]> {
const foundEntries = await this.historyService.getEntriesByUser(req.user);
return Promise.all(
return await Promise.all(
foundEntries.map(
async (entry) => await this.historyService.toHistoryEntryDto(entry),
),
@ -69,7 +69,7 @@ export class MeController {
): Promise<HistoryEntryDto> {
// ToDo: Check if user is allowed to pin this history entry
try {
return this.historyService.toHistoryEntryDto(
return await this.historyService.toHistoryEntryDto(
await this.historyService.updateHistoryEntry(
note,
req.user,
@ -103,7 +103,7 @@ export class MeController {
@Get('notes')
async getMyNotes(@Request() req): Promise<NoteMetadataDto[]> {
const notes = await this.notesService.getUserNotes(req.user);
return Promise.all(
return await Promise.all(
notes.map((note) => this.notesService.toNoteMetadataDto(note)),
);
}

View file

@ -67,7 +67,7 @@ export class NotesController {
throw new UnauthorizedException('Creating note denied!');
}
this.logger.debug('Got raw markdown:\n' + text);
return this.noteService.toNoteDto(
return await this.noteService.toNoteDto(
await this.noteService.createNote(text, undefined, req.user),
);
}
@ -91,7 +91,7 @@ export class NotesController {
throw new UnauthorizedException('Reading note denied!');
}
await this.historyService.createOrUpdateHistoryEntry(note, req.user);
return this.noteService.toNoteDto(note);
return await this.noteService.toNoteDto(note);
}
@UseGuards(TokenAuthGuard)
@ -106,7 +106,7 @@ export class NotesController {
}
this.logger.debug('Got raw markdown:\n' + text, 'createNamedNote');
try {
return this.noteService.toNoteDto(
return await this.noteService.toNoteDto(
await this.noteService.createNote(text, noteAlias, req.user),
);
} catch (e) {
@ -153,7 +153,7 @@ export class NotesController {
throw new UnauthorizedException('Updating note denied!');
}
this.logger.debug('Got raw markdown:\n' + text, 'updateNote');
return this.noteService.toNoteDto(
return await this.noteService.toNoteDto(
await this.noteService.updateNote(note, text),
);
} catch (e) {
@ -196,7 +196,7 @@ export class NotesController {
if (!this.permissionsService.mayRead(req.user, note)) {
throw new UnauthorizedException('Reading note denied!');
}
return this.noteService.toNoteMetadataDto(note);
return await this.noteService.toNoteMetadataDto(note);
} catch (e) {
if (e instanceof NotInDBError) {
throw new NotFoundException(e.message);
@ -220,7 +220,7 @@ export class NotesController {
if (!this.permissionsService.isOwner(req.user, note)) {
throw new UnauthorizedException('Updating note denied!');
}
return this.noteService.toNotePermissionsDto(
return await this.noteService.toNotePermissionsDto(
await this.noteService.updateNotePermissions(note, updateDto),
);
} catch (e) {
@ -243,7 +243,7 @@ export class NotesController {
throw new UnauthorizedException('Reading note denied!');
}
const revisions = await this.revisionsService.getAllRevisions(note);
return Promise.all(
return await Promise.all(
revisions.map((revision) =>
this.revisionsService.toRevisionMetadataDto(revision),
),