Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | 7x 7x 7x 7x | import { Module } from '@nestjs/common'
import { AuthService } from './auth.service'
import { AuthController } from './auth.controller'
import { PassportModule } from '@nestjs/passport'
import { JwtModule } from '@nestjs/jwt'
import { ConfigModule, ConfigService } from '@nestjs/config'
import { JwtStrategy } from './jwt.strategy'
import { HttpModule } from '@nestjs/axios'
import { GoogleStrategy } from './google.strategy'
import { LocalAuthProvider } from './providers/local.provider'
import { Auth0Provider } from './providers/auth0.provider'
@Module({
imports: [
PassportModule,
JwtModule.registerAsync({
imports: [ConfigModule],
useFactory: (configService: ConfigService) => ({
secret: configService.get<string>('JWT_SECRET') || 'dev_secret',
signOptions: { expiresIn: '1d' },
}),
inject: [ConfigService],
}),
HttpModule,
],
controllers: [AuthController],
providers: [
AuthService,
JwtStrategy,
GoogleStrategy,
LocalAuthProvider,
Auth0Provider,
{
provide: 'AUTH_PROVIDER',
useFactory: (
configService: ConfigService,
localProvider: LocalAuthProvider,
auth0Provider: Auth0Provider,
) => {
const type = configService.get<string>('AUTH_PROVIDER_TYPE')
Iif (type === 'auth0') {
return auth0Provider
}
return localProvider
},
inject: [ConfigService, LocalAuthProvider, Auth0Provider],
},
],
})
export class AuthModule {}
|