const afClassService = {
provide: 'afClass',
useClass: IndexService,
}
const afValueService = {
provide: 'afValue',
useValue: ['a', 'b', 'c'],
}
const afFactoryService = {
provide: 'afFactory',
inject: [ConfigService],
useFactory: (configService: ConfigService) => {
const env = configService.get('NODE_ENV')
return env === 'development' ? new IndexService() : new AdminService()
},
}
import { ConfigModule, ConfigService } from '@nestjs/config'
const afFactoryS = {
provide: 'afFactory',
inject: [ConfigService],
useFactory: (configService: ConfigService) => {
const env = configService.get('NODE_ENV')
return env === 'development' ? new IndexService() : new AdminService()
},
}
const configM = ConfigModule.forRoot()
process.env.PORT