import type pg from 'pg';
import { ClubService } from './application/club-service.js';
import { PgClubRepository } from './infrastructure/pg-club-repository.js';

export { registerClubRoutes, type ClubRoutesDeps, CLUB_DEVICE_COOKIE_NAME } from './api/club.routes.js';
export { ClubService } from './application/club-service.js';
export type {
  ClubMember,
  ClubMemberStatus,
  ClubSettings,
  ClubTransaction,
  ClubTransactionType,
  JoinClubResult,
  RecordClubTransactionCommand,
  RecordClubTransactionResult,
  UpdateClubSettingsCommand,
} from './domain/club.js';
export {
  ClubDisabledError,
  ClubAnonymousJoinDisabledError,
  ClubDeviceTokenRequiredError,
  ClubMemberNotFoundError,
  ClubInsufficientBalanceError,
  InvalidClubTransactionError,
} from './domain/errors.js';
export type { ClubRepository } from './domain/ports.js';
export { generateDeviceToken, hashDeviceToken } from './infrastructure/device-token.js';
export { generateMemberCode } from './infrastructure/member-code.js';

export function createClubService(pool: pg.Pool): ClubService {
  return new ClubService(new PgClubRepository(pool));
}
