title: How to pass reflector to Nest.js global guard?
body: <p>I am new to nest.js and I have a question.
  I have a Roles Guard like this</p>
  
  <pre><code>import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common';
  import { Observable } from 'rxjs';
  import { Reflector } from '@nestjs/core';
  
  @Injectable()
  export class RolesGuard implements CanActivate {
    constructor(private readonly reflector: Reflector) {
    }
  
    canActivate(context: ExecutionContext): boolean | Promise&lt;boolean&gt; | Observable&lt;boolean&gt; {
      const roles = this.reflector.get&lt;string[]&gt;('roles', context.getHandler());
      if (!roles) {
        return true;
      }
      const request = context.switchToHttp().getRequest();
      const user = request.user;
      return user.role.some(role =&gt; !!roles.find(item =&gt; item === role));
    }
  
  }
  </code></pre>
  
  <p>Now I want to use this guard as a global guard  like this</p>
  
  <pre><code>app.useGlobalGuards(new RolesGuard())
  </code></pre>
  
  <p>But it says that I need to pass argument(the reflector) to the guard as I mentioned in the constructor, now will it be okay to initialize the reflector like this?</p>
  
  <pre><code>const reflector:Reflector = new Reflector();
  app.useGlobalGuards(new RolesGuard(reflector))
  </code></pre>
  
  <p>Or is there a better way to do this? </p>