import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { JwtModule } from '@nestjs/jwt';
import { ConfigModule, ConfigService } from 'nestjs-config';
import { AttachmentController } from './attachment.controller';
import { AttachmentService } from './attachment.service';
import { Attachment } from './attachment.entity';

@Module({
  imports: [
    TypeOrmModule.forFeature([
      Attachment,
    ]),
    JwtModule.registerAsync({
      imports: [ConfigModule],
      useFactory: async (config: ConfigService) => ({
        secret: config.get('jwtSecret'),
        signOptions: { expiresIn: process.env.JWT_TOKEN_EXPIRY }
      }),
      inject: [ConfigService]
    })
  ],
  providers: [AttachmentService],
  controllers: [AttachmentController]
})
export class AttachmentModule { }
