spring:
  application:
    name: user-service

  # Database Configuration (PostgreSQL)
  datasource:
    url: ${DB_URL:jdbc:postgresql://20.249.125.115:5432/userdb}
    username: ${DB_USERNAME:eventuser}
    password: ${DB_PASSWORD:Hi5Jessica!}
    driver-class-name: ${DB_DRIVER:org.postgresql.Driver}
    hikari:
      maximum-pool-size: ${DB_POOL_MAX:20}
      minimum-idle: ${DB_POOL_MIN:5}
      connection-timeout: ${DB_CONN_TIMEOUT:30000}
      idle-timeout: ${DB_IDLE_TIMEOUT:600000}
      max-lifetime: ${DB_MAX_LIFETIME:1800000}
      leak-detection-threshold: ${DB_LEAK_THRESHOLD:60000}

  # H2 Console (개발용 - PostgreSQL 사용 시 비활성화)
  h2:
    console:
      enabled: ${H2_CONSOLE_ENABLED:false}
      path: /h2-console

  # JPA Configuration
  jpa:
    show-sql: ${SHOW_SQL:true}
    properties:
      hibernate:
        format_sql: true
        use_sql_comments: true
        dialect: ${JPA_DIALECT:org.hibernate.dialect.PostgreSQLDialect}
    hibernate:
      ddl-auto: ${DDL_AUTO:update}

  # Auto-configuration exclusions for development without external services
  autoconfigure:
    exclude:
      - ${EXCLUDE_KAFKA:}
      - ${EXCLUDE_REDIS:}

  # Redis Configuration
  data:
    redis:
      enabled: ${REDIS_ENABLED:true}
      host: ${REDIS_HOST:20.214.210.71}
      port: ${REDIS_PORT:6379}
      password: ${REDIS_PASSWORD:Hi5Jessica!}
      timeout: ${REDIS_TIMEOUT:2000ms}
      lettuce:
        pool:
          max-active: ${REDIS_POOL_MAX:8}
          max-idle: ${REDIS_POOL_IDLE:8}
          min-idle: ${REDIS_POOL_MIN:0}
          max-wait: ${REDIS_POOL_WAIT:-1ms}
      database: ${REDIS_DATABASE:0}

  # Kafka Configuration
  kafka:
    bootstrap-servers: ${KAFKA_BOOTSTRAP_SERVERS:4.230.50.63:9092}
    consumer:
      group-id: ${KAFKA_CONSUMER_GROUP:user-service-consumers}
      auto-offset-reset: earliest
      key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
      value-deserializer: org.springframework.kafka.support.serializer.JsonDeserializer
      properties:
        spring.json.trusted.packages: "*"
    producer:
      key-serializer: org.apache.kafka.common.serialization.StringSerializer
      value-serializer: org.springframework.kafka.support.serializer.JsonSerializer

# JWT Configuration
jwt:
  secret: ${JWT_SECRET:kt-event-marketing-secret-key-for-development-only-please-change-in-production}
  access-token-validity: ${JWT_ACCESS_TOKEN_VALIDITY:604800000}  # 7 days in milliseconds

# CORS Configuration
cors:
  allowed-origins: ${CORS_ALLOWED_ORIGINS:http://localhost:8081,http://localhost:8082,http://localhost:8083,http://localhost:8084,http://kt-event-marketing.20.214.196.128.nip.io}
  allowed-methods: ${CORS_ALLOWED_METHODS:GET,POST,PUT,DELETE,OPTIONS,PATCH}
  allowed-headers: ${CORS_ALLOWED_HEADERS:*}
  allow-credentials: ${CORS_ALLOW_CREDENTIALS:true}
  max-age: ${CORS_MAX_AGE:3600}

# Actuator
management:
  endpoints:
    web:
      exposure:
        include: health,info,metrics,prometheus
      base-path: /actuator
  endpoint:
    health:
      show-details: always
      show-components: always
  health:
    livenessState:
      enabled: true
    readinessState:
      enabled: true

# OpenAPI Documentation
springdoc:
  api-docs:
    path: /v3/api-docs
  swagger-ui:
    path: /swagger-ui.html
    tags-sorter: alpha
    operations-sorter: alpha
  show-actuator: false

# Logging
logging:
  level:
    com.kt.event.user: ${LOG_LEVEL_APP:DEBUG}
    org.springframework.web: ${LOG_LEVEL_WEB:INFO}
    org.hibernate.SQL: ${LOG_LEVEL_SQL:DEBUG}
    org.hibernate.type: ${LOG_LEVEL_SQL_TYPE:TRACE}
  pattern:
    console: "%d{yyyy-MM-dd HH:mm:ss} - %msg%n"
    file: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"
  file:
    name: ${LOG_FILE_PATH:logs/user-service.log}

# Server Configuration
server:
  port: ${SERVER_PORT:8081}
  servlet:
    context-path: /api/v1/users
