Im following the nestJs authentication tutorial
In auth/auth.module.ts:
import { JwtModule } from '@nestjs/jwt'
...
@Module({
imports: [
UsersModule,
PassportModule,
JwtModule.register({
secret: jwtConstants.secret,
signOptions: { expiresIn: '60s' },
}),
],
providers: [AuthService, LocalStrategy, JwtStrategy],
exports: [AuthService],
})
So JwtModule is imported under 'imports' .
In the auth/auth.service.ts the JwtService is being injected
...
import { JwtService } from '@nestjs/jwt';
@Injectable()
export class AuthService {
constructor(
private usersService: UsersService,
private jwtService: JwtService
) {}
...
From the nestJs docs:
Under Module: providers - the providers that will be instantiated by the Nest injector and that may be shared at least across this module
imports - the list of imported modules that export the providers which are required in this module
Under Providers:
Providers are a fundamental concept in Nest.
Many of the basic Nest classes may be treated as a provider – services, repositories,
factories, helpers, and so on.
The main idea of a provider is that it can be injected as a dependency;
this means objects can create various relationships with each other, and the function
of "wiring up" instances of objects can largely be delegated to the Nest runtime system
I don't really understand . Whats the difference between providers and imports if both are used for dependency injection ?