# Loco configuration file documentation

# Application logging configuration
logger:
  # Enable or disable logging.
  enable: false
  # Enable pretty backtrace (sets RUST_BACKTRACE=1)
  pretty_backtrace: true
  # Log level, options: trace, debug, info, warn or error.
  level: debug
  # Define the logging format. options: compact, pretty or json
  format: compact
  # By default the logger has filtering only logs that came from your code or logs that came from `loco` framework. to see all third party libraries
  # Uncomment the line below to override to see all third party libraries you can enable this config and override the logger filters.
  # override_filter: trace

# Web server configuration
server:
  # Port on which the server will listen. the server binding is 0.0.0.0:{PORT}
  port: 5150
  # The UI hostname or IP address that mailers will point to.
  host: http://localhost
  # Out of the box middleware configuration. to disable middleware you can changed the `enable` field to `false` of comment the middleware block
  middlewares: 
    static:
      enable: true
      must_exist: true
      precompressed: false
      folder:
        uri: "/static"
        path: "assets/static"
      fallback: "assets/static/404.html"

# Worker Configuration
workers:
  # specifies the worker mode. Options:
  #   - BackgroundQueue - Workers operate asynchronously in the background, processing queued.
  #   - ForegroundBlocking - Workers operate in the foreground and block until tasks are completed.
  #   - BackgroundAsync - Workers operate asynchronously in the background, processing tasks with async capabilities.
  mode: ForegroundBlocking

  

# Mailer Configuration.
# Defaults keep the whole suite on the in-memory stub mailer. The real-SMTP
# smoke test (tests/mailer/smtp_send.rs) opts in by setting these env vars
# before boot; nothing else in the suite sends real mail.
mailer:
  stub: {{ get_env(name="MAILER_STUB", default="true") }}
  # SMTP mailer configuration.
  smtp:
    # Enable/Disable smtp mailer.
    enable: {{ get_env(name="SMTP_ENABLE", default="true") }}
    # SMTP server host. e.x localhost, smtp.gmail.com
    host: "{{ get_env(name="SMTP_HOST", default="localhost") }}"
    # SMTP server port
    port: {{ get_env(name="SMTP_PORT", default="1025") }}
    # Use secure connection (SSL/TLS).
    secure: {{ get_env(name="SMTP_SECURE", default="false") }}
    auth:
      user: "{{ get_env(name="SMTP_USER", default="") }}"
      password: "{{ get_env(name="SMTP_PASSWORD", default="") }}"

# Initializers Configuration
# OAuth2StoreInitializer requires this block to boot (it builds the client store
# in after_routes). Static, non-secret placeholders: tests never perform a real
# OAuth2 handshake, they just need the store to construct successfully.
initializers:
  oauth2:
    # Private-cookie key: a ", "-separated list of >=64 byte values (not a
    # plain string). This is loco-oauth2's documented sample key; fine for tests.
    secret_key: "144, 76, 183, 1, 15, 184, 233, 174, 214, 251, 190, 186, 122, 61, 74, 84, 225, 110, 189, 115, 10, 251, 133, 128, 52, 46, 15, 66, 85, 1, 245, 73, 27, 113, 189, 15, 209, 205, 61, 100, 73, 31, 18, 58, 235, 105, 141, 36, 70, 92, 231, 151, 27, 32, 243, 117, 30, 244, 110, 89, 233, 196, 137, 130"
    authorization_code:
      - client_identifier: google
        client_credentials:
          client_id: test-client-id
          client_secret: test-client-secret
        url_config:
          auth_url: https://accounts.google.com/o/oauth2/auth
          token_url: https://www.googleapis.com/oauth2/v3/token
          redirect_url: http://localhost:5150/api/oauth2/google/callback
          profile_url: https://openidconnect.googleapis.com/v1/userinfo
          scopes:
            - https://www.googleapis.com/auth/userinfo.email
            - https://www.googleapis.com/auth/userinfo.profile
        cookie_config:
          protected_url: http://localhost:5150/
        timeout_seconds: 600

# Database Configuration
database:
  # Database connection URI. Pinned to the throwaway test DB and intentionally
  # NOT read from `DATABASE_URL`: the app loads `.env` on boot (app.rs
  # `load_config`), and this config has `dangerously_recreate: true`, so honoring
  # an env override here would let `cargo test` recreate the dev/prod database.
  uri: "postgres://uni_loco_web_user:3@localhost:5432/kompress_eshop_test"
  # When enabled, the sql query will be logged.
  enable_logging: false
  # Set the timeout duration when acquiring a connection.
  connect_timeout: {{ get_env(name="DB_CONNECT_TIMEOUT", default="500") }}
  # Set the idle duration before closing a connection.
  idle_timeout: {{ get_env(name="DB_IDLE_TIMEOUT", default="500") }}
  # Minimum number of connections for a pool.
  min_connections: {{ get_env(name="DB_MIN_CONNECTIONS", default="1") }}
  # Maximum number of connections for a pool.
  max_connections: {{ get_env(name="DB_MAX_CONNECTIONS", default="1") }}
  # Run migration up when application loaded
  auto_migrate: true
  # Truncate database when application loaded. This is a dangerous operation, make sure that you using this flag only on dev environments or test mode
  dangerously_truncate: true
  # Recreating schema when application loaded.  This is a dangerous operation, make sure that you using this flag only on dev environments or test mode
  dangerously_recreate: true

# Authentication Configuration
auth:
  # JWT authentication
  jwt:
    location:
      - from: Cookie
        name: auth_token
      - from: Bearer
    # Secret key for token generation and verification
    secret: 0yWwoflcGiAhonIzhQyQ
    # Token expiration time in seconds
    expiration: 604800 # 7 days

settings:
  admin_email: admin@example.com
  uploads_root: uploads/test
