import { Module, Global } from '@nestjs/common';
import { JwtModule } from '@nestjs/jwt';
import { jwtConstants } from './config/common';
import { JwtStrategy } from './modules/auth/jwt.strategy';
import { PassportModule } from '@nestjs/passport';
import { UserModule } from './modules/user/user.module';

@Global()
@Module({
  imports: [
    PassportModule,
    JwtModule.register({
      secret: jwtConstants.secret,
      signOptions: { expiresIn: '24h' },
    }),
    UserModule, // imports UserService with repo correctly set up
  ],
  providers: [JwtStrategy], // ONLY JwtStrategy here
  exports: [JwtStrategy, JwtModule],
})
export class JwtAuthModule {}

// import { TypeOrmModule } from '@nestjs/typeorm';
// import { Module, Global } from '@nestjs/common';
// import { JwtModule } from '@nestjs/jwt';
// import { jwtConstants } from './config/common';
// import { JwtStrategy } from './modules/auth/jwt.strategy';
// import { PassportModule } from '@nestjs/passport';
// import { UserService } from '../src/modules/user/user.service';
// import { UserEntity } from '../src/modules/user/entities/user.entity';

// @Global()
// @Module({
//   imports: [
//     PassportModule,
//     JwtModule.register({
//       secret: jwtConstants.secret,
//       signOptions: { expiresIn: '24h' },
//     }),
//     TypeOrmModule.forFeature([UserEntity]),
//   ],
//   providers: [JwtStrategy, UserService],
//   exports: [JwtStrategy, JwtModule], // export JwtModule
// })
// export class JwtAuthModule {}
