mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-20 10:15:17 -04:00
fix: add CompleteRequest type to have better type checks for HTTP-Request attribute injection.
Signed-off-by: Yannick Bungers <git@innay.de> Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
0263c09ce1
commit
d369132519
10 changed files with 34 additions and 38 deletions
|
@ -9,11 +9,10 @@ import {
|
|||
Injectable,
|
||||
NestInterceptor,
|
||||
} from '@nestjs/common';
|
||||
import { Request } from 'express';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { Note } from '../../notes/note.entity';
|
||||
import { NotesService } from '../../notes/notes.service';
|
||||
import { CompleteRequest } from './request.type';
|
||||
|
||||
/**
|
||||
* Saves the note identified by the `HedgeDoc-Note` header
|
||||
|
@ -27,9 +26,7 @@ export class NoteHeaderInterceptor implements NestInterceptor {
|
|||
context: ExecutionContext,
|
||||
next: CallHandler,
|
||||
): Promise<Observable<T>> {
|
||||
const request: Request & {
|
||||
note: Note;
|
||||
} = context.switchToHttp().getRequest();
|
||||
const request: CompleteRequest = context.switchToHttp().getRequest();
|
||||
const noteId: string = request.headers['hedgedoc-note'] as string;
|
||||
request.note = await this.noteService.getNoteByIdOrAlias(noteId);
|
||||
return next.handle();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue