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?
For example, I'm using morgan in my own logging module directly by importing it in the respective file:
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 ... */
}
}
Now I know nest's architecture is heavily influenced by Angular, and I found this article explaining how to deal with 3rd party dependencies in angular. Does the same idea apply to nest? Should I create a custom provider for morgan and inject that? And do I inject just the morgan import, or an already configured morgan instance?