# ===================================================================
# CONFIGURATION MOSCEPA BACKEND (PRODUCTION 2026)
# ===================================================================
spring.application.name=moscepa-backend

# --- Configuration du serveur ---
# Permet de changer le port (ex: 8081) sans recompiler
server.port=${SERVER_PORT:8080}
server.servlet.context-path=/

# --- Configuration de la base de données MySQL ---
# Syntaxe : ${VARIABLE:VALEUR_PAR_DEFAUT}
spring.datasource.url=jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3306}/${DB_NAME:moscepa}?createDatabaseIfNotExist=true&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
spring.datasource.username=${DB_USER:root}
spring.datasource.password=${DB_PASS:}
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

# --- Configuration JPA/Hibernate ---
# En production réelle, on passe show-sql à false pour les performances
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=${SHOW_SQL:false}
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
spring.jpa.properties.hibernate.jdbc.time_zone=UTC

# --- Configuration Hikari (Pool de connexion) ---
spring.datasource.hikari.connection-test-query=SELECT 1
spring.datasource.hikari.connection-timeout=20000
spring.datasource.hikari.maximum-pool-size=${DB_POOL_SIZE:10}

# --- Configuration de la sécurité ---
spring.security.user.name=${ADMIN_USERNAME:admin}
spring.security.user.password=${ADMIN_PASSWORD:admin123}
spring.security.user.roles=ADMIN

# --- Configuration des logs ---
logging.level.com.moscepa=INFO
logging.level.org.springframework.security=INFO
logging.level.org.hibernate.SQL=ERROR
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=INFO

# --- Configuration Swagger/OpenAPI ---
springdoc.api-docs.path=/api-docs
springdoc.swagger-ui.path=/swagger-ui.html
springdoc.swagger-ui.operationsSorter=method

# --- Configuration de validation ---
spring.jackson.serialization.fail-on-empty-beans=false
spring.jackson.default-property-inclusion=NON_NULL
spring.jackson.mapper.accept-case-insensitive-enums=true

# --- Gestion des fichiers (Uploads) ---
# Permet de définir le dossier de stockage (ex: /var/www/uploads sur Linux)
file.upload-dir=${UPLOAD_PATH:./uploads}
