import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { JwtModule } from '@nestjs/jwt';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { FamiliesService } from './families.service';
import { FamiliesController } from './families.controller';
import { FamiliesGateway } from './families.gateway';
import { Family } from '../../database/entities/family.entity';
import { FamilyMember } from '../../database/entities/family-member.entity';
import { User } from '../../database/entities/user.entity';

@Module({
  imports: [
    TypeOrmModule.forFeature([Family, FamilyMember, User]),
    JwtModule.registerAsync({
      imports: [ConfigModule],
      useFactory: (configService: ConfigService) => ({
        secret: configService.get<string>('JWT_SECRET'),
        signOptions: {
          expiresIn: configService.get<string>('JWT_EXPIRATION', '1h'),
        },
      }),
      inject: [ConfigService],
    }),
  ],
  controllers: [FamiliesController],
  providers: [FamiliesService, FamiliesGateway],
  exports: [FamiliesService, FamiliesGateway],
})
export class FamiliesModule {}
