#
# Copyright (c) 2020 Bubble, Inc.  All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/
#
# Things in {{CURLIES}} will be read from the process environment.
# Values are typically set in ${HOME}/.bubble.env

serverName: bubble-api

publicUriBase: {{PUBLIC_BASE_URI}}

defaultLocale: {{#exists BUBBLE_DEFAULT_LOCALE}}{{BUBBLE_DEFAULT_LOCALE}}{{else}}en_US{{/exists}}
testMode: {{#exists BUBBLE_TEST_MODE}}{{BUBBLE_TEST_MODE}}{{else}}false{{/exists}}

database:
  driver: org.postgresql.Driver
  url: jdbc:postgresql://127.0.0.1:5432/bubble
  user: bubble
  password: '{{#exists BUBBLE_PG_PASSWORD}}{{BUBBLE_PG_PASSWORD}}{{else}}{{key_file '.BUBBLE_PG_PASSWORD'}}{{/exists}}'

  encryptionEnabled: true
  encryptionKey: '{{#exists BUBBLE_DB_ENCRYPTION_KEY}}{{BUBBLE_DB_ENCRYPTION_KEY}}{{else}}{{key_file '.BUBBLE_DB_ENCRYPTION_KEY'}}{{/exists}}'
  encryptorPoolSize: 50

  migrationEnabled: true

  hibernate:
    entityPackages:
    - bubble.model
    - org.cobbzilla.wizard.model.crypto   # for encrypted column support
    - org.cobbzilla.wizard.model.json     # for JSONB column support
    dialect: org.cobbzilla.wizard.model.json.JSONBPostgreSQLDialect
    showSql: {{#exists BUBBLE_SHOW_SQL}}{{BUBBLE_SHOW_SQL}}{{else}}false{{/exists}}
    hbm2ddlAuto: validate
    validationMode: ddl

staticAssets:
  baseUri: /
  assetRoot: site/
  localOverride: {{BUBBLE_ASSETS_DIR}}
  singlePageApp: /index.html
  utilPaths:
    INDEX_PATH: /index.html
    INDEX_ALIASES: /:/index.php

http:
  port: {{#exists BUBBLE_SERVER_PORT}}{{BUBBLE_SERVER_PORT}}{{else}}8090{{/exists}}
  baseUri: /api
  {{#exists BUBBLE_SELECTOR_THREADS}}selectorThreads: {{BUBBLE_SELECTOR_THREADS}}{{/exists}}
  {{#exists BUBBLE_WORKER_THREADS}}workerThreads: {{BUBBLE_WORKER_THREADS}}{{/exists}}

jersey:
  resourcePackages:
   - bubble.resources
   - org.cobbzilla.wizard.server
   - org.cobbzilla.wizard.filters
  providerPackages:
   - org.cobbzilla.wizard.exceptionmappers
  requestFilters:
   - bubble.auth.BubbleAuthFilter
   - bubble.filters.BubbleRateLimitFilter
  responseFilters:
   - org.cobbzilla.wizard.filters.ScrubbableScrubber
   - org.cobbzilla.wizard.filters.EntityTypeHeaderResponseFilter

redis:
  key: '{{#exists BUBBLE_REDIS_ENCRYPTION_KEY}}{{BUBBLE_REDIS_ENCRYPTION_KEY}}{{else}}{{key_file '.BUBBLE_REDIS_ENCRYPTION_KEY'}}{{/exists}}'
  prefix: bubble

errorApi:
  url: {{ERRBIT_URL}}
  key: {{ERRBIT_KEY}}
  env: {{ERRBIT_ENV}}

localNotificationStrategy: {{#exists BUBBLE_LOCAL_NOTIFY}}{{BUBBLE_LOCAL_NOTIFY}}{{else}}inline{{/exists}}

letsencryptEmail: {{LETSENCRYPT_EMAIL}}
localStorageDir: {{LOCALSTORAGE_BASE_DIR}}

disallowedCountries: {{DISALLOWED_COUNTRIES}}

promoCodePolicy: {{#exists BUBBLE_PROMO_CODE_POLICY}}{{BUBBLE_PROMO_CODE_POLICY}}{{else}}disabled{{/exists}}
requireSendMetrics: true

rateLimits:
  - { limit: 500, interval: 3s, block: 5m }
  - { limit: 2000, interval: 1m, block: 5m }
  - { limit: 10000, interval: 10m, block: 1h }
  - { limit: 50000, interval: 1h, block: 24h }
  - { limit: 100000, interval: 6h, block: 96h }

support:
  email: {{SUPPORT_EMAIL}}
  site: {{SUPPORT_SITE}}
  locale:
    en_US:
      email: {{SUPPORT_EMAIL}}
      site: {{SUPPORT_SITE}}

appLinks:
  ios: {{APP_LINK_IOS}}
  android: {{APP_LINK_ANDROID}}
  windows: {{APP_LINK_WINDOWS}}
  macosx: {{APP_LINK_MACOSX}}
  linux: {{APP_LINK_LINUX}}
  locale:
    en_US:
      ios: {{APP_LINK_IOS}}
      android: {{APP_LINK_ANDROID}}
      windows: {{APP_LINK_WINDOWS}}
      macosx: {{APP_LINK_MACOSX}}
      linux: {{APP_LINK_LINUX}}
