#onApplicationBootstrap not firing even when i change the scope

7 messages · Page 1 of 1 (latest)

jagged shale
#

Hello,
i believe its just a small oversight but i couldnt locate the error..

@Injectable({scope: Scope.DEFAULT})
export class BlogService implements OnApplicationBootstrap{
  public blogEntry: Blog[] ;
  constructor(private readonly supabase: Supabase ) {
    console.log('BlogService')
  }
  onApplicationBootstrap() {
    console.log(`The module has been initialized.`);
  }

another Modul changes the scope to request and i whant this one do go back to default but id dont whant to what did i miss :(?

wise yacht
#

If supabase is request scoped, there's no way to make the parent module a singleton. Request scope always bubbles up to the parent.

jagged shale
#

ok then made completly wrong so i have to change the scope in the services where i use supabase and not in supabase ... thanks

jagged shale
#

by any chance do know to change this

@Inject(REQUEST) private readonly request: Request,

that i get the request without changing the scope ?

wise yacht
#

You might be interested in AsyncLocalStorage to get around the issue with request scope https://docs.nestjs.com/recipes/async-local-storage

jagged shale
#

so i got the options to pass the req from controller to service and extract the token or like async local storage without changing my scope ?