boisebrigade / courtbot

Courtbot is a simple web service for subscribing to case hearing details via SMS.
https://openboise.org
ISC License
9 stars 3 forks source link

Revamp Configuration #6

Closed tylersamples closed 6 years ago

tylersamples commented 6 years ago

In an effort to cleanup configuration, make HOST, PORT, and POOL_SIZE non-compile time needed configuration (default them to sane values per env.)

Allow the mix config in courtbot.exs to act as a single source of configuration with no dependency on any other environment variables being set for ExCourtbot to run (not including COOKIE). This will include changing init callbacks to check for config values before raising.

tylersamples commented 6 years ago

First pass at a "complete" mix config only courtbot.exs

use Mix.Config

# ExTwilio config.
config :ex_twilio,
  account_sid: "sid",
  auth_token: "token"

# Phoenix configuraiton
config :excourtbot, ExCourtbotWeb.Endpoint,
  load_from_system_env: false,
  secret_key_base: "keybase",
  url: [
    port: 4000,
    host: "localhost"
  ]

# Database Configuration.
config :excourtbot, ExCourtbot.Repo,
  load_from_system_env: false,
  url: "postgres://postgres:postgres@0.0.0.0:5432/excourtbot",
  ssl: false,
  pool_size: 10

# Provides table encryption for phone numbers. Currently not disableable.
config :excourtbot, ExCourtbot.Vault,
  ciphers: [
    default: {Cloak.Ciphers.AES.GCM, tag: "AES.GCM.V1", key: Base.decode64!("your-key-here")}
  ]

# ExCourtbot config.
config :excourtbot, ExCourtbot,
  locales: %{
    "en" => "12083144089"
  },
  court_url: "https://mycourts.idaho.gov/",
  queued_ttl_days: 14,
  subscribe_limit: 10,
  import_time: "0 9 * * *",
  notify_time: "0 13 * * *",
  types: %{
    "Criminal" => ~r/^[A-Z]{2}\d{0,2}?-\d{2,4}-\d{2,}/
  },
  importer: %{
    file: "/tmp/boise.csv",
    type:
      {:csv,
       [
         {:has_headers, true},
         {:headers,
          [
            :case_number,
            :last_name,
            :first_name,
            nil,
            nil,
            nil,
            {:date, "%-m/%e/%Y"},
            {:time, "%k:%M"},
            nil,
            :county
          ]}
       ]}
  }