title: How to create custom provider for third-party library in nestjs with access to request and response
body: <p>I have a controller in <code>nestjs</code> as below</p>
  
  <pre><code>import * as dialogflow from 'dialogflow-fulfillment';
  import { Request, Response } from 'express';
  
  @Controller('dialogflow-fulfillment')
  export class DialogflowFulfillmentController {
  
      @Post()
      async fulfill(@Req() request: Request, @Res() response: Response) {
  
          const agent = new dialogflow.WebhookClient({ request, response });
  
      }
  }
  </code></pre>
  
  <p>Now for being able to unit test this controller I want to use custom provider and provide an instance of WebhookClient.</p>
  
  <p>Something like below</p>
  
  <pre><code>    {
        provide: 'WebhookService',
        useFactory: async () =&gt; new dialogflow.WebhookClient({??,??})
      }
  </code></pre>
  
  <p>but problem is I need to get access to instance of <code>request</code> and <code>response</code> to create a new instance.</p>
  
  <p>How can I do that? And how to inject it in each calls of <code>fulfill</code>?</p>