title: Handling third party dependencies in nest.js
body: <p>What is the best practice on how to handle third-party dependencies (i.e. dependencies that don't come in the form of a nest-module) in nest?</p>
  
  <p>For example, I'm using <a href="https://www.npmjs.com/package/morgan" rel="noreferrer"><code>morgan</code></a> in my own logging module directly by importing it in the respective file:</p>
  
  <pre><code>import { Injectable, MiddlewareFunction, NestMiddleware } from '@nestjs/common';
  import * as morgan from 'morgan';
  
  @Injectable()
  export class NestLoggingMiddleware implements NestMiddleware {
  
      resolve(...args: any[]): MiddlewareFunction {
          /** use morgan here, e.g. wrap it in a custom middleware ... */
      }
  }
  </code></pre>
  
  <p>Now I know nest's architecture is heavily influenced by Angular, and I found <a href="https://hackernoon.com/angular-providers-how-to-inject-3rd-party-library-af4a78722864" rel="noreferrer">this article explaining how to deal with 3rd party dependencies in angular</a>. Does the same idea apply to nest? Should I create a custom provider for <code>morgan</code> and inject that? And do I inject just the <code>morgan</code> import, or an already configured <code>morgan</code> instance?</p>