/**
 * Webhooks Module
 *
 * Provides webhook functionality for external integrations
 */

import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { HttpModule } from '@nestjs/axios';
import { WebhooksController } from '../controllers/webhooks.controller';
import { WebhookService } from '../services/webhook.service';
import { WebhookOrmEntity } from '../../infrastructure/persistence/typeorm/entities/webhook.orm-entity';
import { TypeOrmWebhookRepository } from '../../infrastructure/persistence/typeorm/repositories/typeorm-webhook.repository';
import { WEBHOOK_REPOSITORY } from '@domain/ports/out/webhook.repository';

@Module({
  imports: [
    TypeOrmModule.forFeature([WebhookOrmEntity]),
    HttpModule.register({
      timeout: 10000,
      maxRedirects: 5,
    }),
  ],
  controllers: [WebhooksController],
  providers: [
    WebhookService,
    {
      provide: WEBHOOK_REPOSITORY,
      useClass: TypeOrmWebhookRepository,
    },
  ],
  exports: [WebhookService],
})
export class WebhooksModule {}
