Skip to content

Commit

Permalink
Split configuration into runtime readable file
Browse files Browse the repository at this point in the history
  • Loading branch information
hashrocketeer committed May 19, 2020
1 parent 9e1001a commit e2fca78
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 31 deletions.
32 changes: 1 addition & 31 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,6 @@ config :tilex, :page_size, 5
config :tilex, :auth_controller, AuthController
config :tilex, :slack_notifier, Tilex.Notifications.Notifiers.Slack
config :tilex, :twitter_notifier, Tilex.Notifications.Notifiers.Twitter
config :tilex, :organization_name, System.get_env("ORGANIZATION_NAME")
config :tilex, :canonical_domain, System.get_env("CANONICAL_DOMAIN")
config :tilex, :default_twitter_handle, System.get_env("DEFAULT_TWITTER_HANDLE")
config :tilex, :cors_origin, System.get_env("CORS_ORIGIN")
config :tilex, :hosted_domain, System.get_env("HOSTED_DOMAIN")
config :tilex, :guest_author_whitelist, System.get_env("GUEST_AUTHOR_WHITELIST")
config :tilex, :date_display_tz, System.get_env("DATE_DISPLAY_TZ")
config :tilex, :imgur_client_id, System.get_env("IMGUR_CLIENT_ID")

config :tilex,
:rate_limiter_requests_per_time_period,
System.get_env("RATE_LIMIT_REQUESTS_PER_TIME_PERIOD") || 5

config :tilex,
:rate_limiter_time_period_minutes,
System.get_env("RATE_LIMIT_TIME_PERIOD_MINUTES") || 1

config :tilex,
:rate_limiter_cleanup_interval,
# every 10 hours
System.get_env("RATE_LIMIT_CLEANUP_INTERVAL") || 10 * 60 * 60_000

config :tilex, :date_time_module, DateTime

Expand All @@ -64,10 +43,6 @@ config :ueberauth, Ueberauth,
]}
]

config :ueberauth, Ueberauth.Strategy.Google.OAuth,
client_id: System.get_env("GOOGLE_CLIENT_ID"),
client_secret: System.get_env("GOOGLE_CLIENT_SECRET")

config :tilex, Tilex.Auth.Guardian,
issuer: "tilex",
ttl: {30, :days},
Expand All @@ -78,12 +53,7 @@ config :tilex, Tilex.Auth.Guardian,
"kty" => "oct"
}

config :extwitter, :oauth,
consumer_key: System.get_env("twitter_consumer_key"),
consumer_secret: System.get_env("twitter_consumer_secret"),
access_token: System.get_env("twitter_access_token"),
access_token_secret: System.get_env("twitter_access_token_secret")

import_config "env_vars.exs"
# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{Mix.env()}.exs"
33 changes: 33 additions & 0 deletions config/env_vars.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
use Mix.Config

config :tilex, :organization_name, System.get_env("ORGANIZATION_NAME")
config :tilex, :canonical_domain, System.get_env("CANONICAL_DOMAIN")
config :tilex, :default_twitter_handle, System.get_env("DEFAULT_TWITTER_HANDLE")
config :tilex, :cors_origin, System.get_env("CORS_ORIGIN")
config :tilex, :hosted_domain, System.get_env("HOSTED_DOMAIN")
config :tilex, :guest_author_whitelist, System.get_env("GUEST_AUTHOR_WHITELIST")
config :tilex, :date_display_tz, System.get_env("DATE_DISPLAY_TZ")
config :tilex, :imgur_client_id, System.get_env("IMGUR_CLIENT_ID")

config :tilex,
:rate_limiter_requests_per_time_period,
System.get_env("RATE_LIMIT_REQUESTS_PER_TIME_PERIOD") || 5

config :tilex,
:rate_limiter_time_period_minutes,
System.get_env("RATE_LIMIT_TIME_PERIOD_MINUTES") || 1

config :tilex,
:rate_limiter_cleanup_interval,
# every 10 hours
System.get_env("RATE_LIMIT_CLEANUP_INTERVAL") || 10 * 60 * 60_000

config :extwitter, :oauth,
consumer_key: System.get_env("twitter_consumer_key"),
consumer_secret: System.get_env("twitter_consumer_secret"),
access_token: System.get_env("twitter_access_token"),
access_token_secret: System.get_env("twitter_access_token_secret")

config :ueberauth, Ueberauth.Strategy.Google.OAuth,
client_id: System.get_env("GOOGLE_CLIENT_ID"),
client_secret: System.get_env("GOOGLE_CLIENT_SECRET")
2 changes: 2 additions & 0 deletions config/releases.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ config :tilex, TilexWeb.Endpoint,
server: true,
http: [port: {:system, "PORT"}],
url: [host: System.get_env("APP_NAME") <> ".gigalixirapp.com", port: 443]

import_config "env_vars.exs"

0 comments on commit e2fca78

Please sign in to comment.