Using a subscriber (db based on TypeORM) I could not find how to get access to the request (to get auth user creating the booking over Rest api)
I tried using Injectable as described in doc but doesn't seem to work here.
Thanks for help
booking.subscriber.ts
import { Inject, Injectable, Scope } from '@nestjs/common';
import { throwError } from 'rxjs';
import { Account } from 'src/accounts';
import { Room } from 'src/rooms';
import { TransactionEntity, TransactionsModule } from 'src/transactions';
import {
EventSubscriber,
EntitySubscriberInterface,
InsertEvent,
getRepository,
LessThan,
MoreThan,
} from 'typeorm';
import { Booking } from './booking.entity';
import { REQUEST } from '@nestjs/core';
import { Request } from 'express';
@EventSubscriber()
@Injectable({ scope: Scope.REQUEST })
export class BookingsSubscriber implements EntitySubscriberInterface<Booking> {
constructor(@Inject(REQUEST) private request: Request) {
console.log('request', this.request) // return undefined
}
listenTo() {
return Booking;
}
}