feat: DRY up configs

This commit is contained in:
Robert Prehn 2020-09-30 16:31:03 -05:00
parent d89b83c932
commit f6aae2f0cb
3 changed files with 131 additions and 399 deletions

View file

@ -1,67 +1,44 @@
use Mix.Config
# Configures the endpoint
config :app, AppWeb.Endpoint,
[
{:admin, Admin, false},
{:app, AppWeb, true},
{:auth_web, AuthWeb, false},
{:content, Content, false},
{:core, CoreWeb, false},
]
|> Enum.map(fn {otp_app, module, start_server} ->
endpoint = Module.concat(module, "Endpoint")
error_view = Module.concat(module, "ErrorView")
config otp_app, endpoint,
url: [host: "localhost"],
secret_key_base: "r2eN53mJ9RmlGz9ZQ7xf43P3Or59aaO9rdf5D3hRcsuiH44pGW9kPGfl5mt9N1Gi",
render_errors: [view: AppWeb.ErrorView, accepts: ~w(html json), layout: false],
render_errors: [view: error_view, accepts: ~w(html json), layout: false],
pubsub_server: App.PubSub,
live_view: [signing_salt: "g5ltUbnQ"]
live_view: [signing_salt: "g5ltUbnQ"],
server: start_server
end)
config :admin, Admin.Endpoint,
url: [host: "localhost"],
secret_key_base: "r2eN53mJ9RmlGz9ZQ7xf43P3Or59aaO9rdf5D3hRcsuiH44pGW9kPGfl5mt9N1Gi",
render_errors: [view: Admin.ErrorView, accepts: ~w(html json), layout: false],
pubsub_server: Admin.PubSub,
live_view: [signing_salt: "g5ltUbnQ"]
[
{:admin, Admin.Repo},
{:app, App.Repo},
{:auth, Auth.Repo},
{:auth_web, Auth.Repo, :auth},
{:content, Content.Repo},
{:core, Core.Repo},
]
|> Enum.map(fn
{otp_app, repo} ->
config otp_app,
ecto_repos: [repo],
generators: [context_app: otp_app]
config :auth_web, AuthWeb.Endpoint,
url: [host: "localhost"],
secret_key_base: "cjtU4RvTirW4yJZDkdqZJmaj7bvaQRrX6mevkoGYqzEuMujV/Q0w3utlO5+FUsUj",
render_errors: [view: AuthWeb.ErrorView, accepts: ~w(html json), layout: false],
pubsub_server: AuthWeb.PubSub,
live_view: [signing_salt: "AwljJYaY"]
config :content, Content.Endpoint,
url: [host: "localhost"],
secret_key_base: "kNJbLKCmuZYSK99S55+DmirA2TlmOxzs/xz3xnlXtOhQCoBMmYRabaRLTXkcsw5d",
render_errors: [view: Content.ErrorView, accepts: ~w(html json), layout: false],
pubsub_server: Content.PubSub,
live_view: [signing_salt: "Nb8V5NUr"]
config :core, CoreWeb.Endpoint,
url: [host: "localhost"],
secret_key_base: "kNJbLKCmuZYSK99S55+DmirA2TlmOxzs/xz3xnlXtOhQCoBMmYRabaRLTXkcsw5d",
render_errors: [view: CoreWeb.ErrorView, accepts: ~w(html json), layout: false],
pubsub_server: Core.PubSub,
live_view: [signing_salt: "Nb8V5NUr"]
config :content, Content.Endpoint, server: false
config :auth_web, AuthWeb.Endpoint, server: false
config :admin, Admin.Endpoint, server: false
config :app, CoreWeb.Endpoint, server: false
# Configure Mix tasks and generators
config :admin,
ecto_repos: [Admin.Repo],
generators: [context_app: false]
config :app,
ecto_repos: [App.Repo],
generators: [context_app: :app]
config :auth,
ecto_repos: [Auth.Repo]
config :auth_web,
ecto_repos: [Auth.Repo],
generators: [context_app: :auth]
config :content,
ecto_repos: [Content.Repo]
config :core,
ecto_repos: [Core.Repo]
{otp_app, repo, context_app} ->
config otp_app,
ecto_repos: [repo],
generators: [context_app: context_app]
end)
config :auth_web, :pow,
user: Auth.User,
@ -74,11 +51,6 @@ config :auth_web, :pow,
config :core, email_from: "example@example.org"
config :content,
generators: [context_app: false]
import_config "../apps/*/config/config.exs"
# Configures Elixir's Logger
config :logger, :console,
format: "$time $metadata[$level] $message\n",

View file

@ -6,288 +6,79 @@ use Mix.Config
# The watchers configuration can be used to run external
# watchers to your application. For example, we use it
# with webpack to recompile .js and .css sources.
config :app, AppWeb.Endpoint,
http: [port: 4000],
debug_errors: true,
code_reloader: true,
check_origin: false,
watchers: [
node: [
"node_modules/webpack/bin/webpack.js",
"--mode",
"development",
"--watch-stdin",
cd: Path.expand("../apps/app/assets", __DIR__)
[
{:admin, Admin},
{:app, AppWeb},
{:auth_web, AuthWeb},
{:content, Content},
{:core, CoreWeb},
]
|> Enum.map(fn {otp_app, module} ->
config otp_app, Module.concat(module, "Endpoint"),
http: [port: 4000],
debug_errors: true,
code_reloader: true,
check_origin: false,
watchers: [
node: [
"node_modules/webpack/bin/webpack.js",
"--mode",
"development",
"--watch-stdin",
cd: Path.expand("../apps/#{otp_app}/assets", __DIR__)
]
]
]
config :admin, Admin.Endpoint,
http: [port: 4000],
debug_errors: true,
code_reloader: true,
check_origin: false,
watchers: [
node: [
"node_modules/webpack/bin/webpack.js",
"--mode",
"development",
"--watch-stdin",
cd: Path.expand("../apps/admin/assets", __DIR__)
config otp_app, Module.concat(module, "Endpoint"),
live_reload: [
patterns: [
~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
~r"priv/gettext/.*(po)$",
~r"lib/app/(live|views)/.*(ex)$",
~r"lib/app/templates/.*(eex)$"
]
]
]
end)
config :auth_web, AuthWeb.Endpoint,
http: [port: 4000],
debug_errors: true,
code_reloader: true,
check_origin: false,
watchers: [
node: [
"node_modules/webpack/bin/webpack.js",
"--mode",
"development",
"--watch-stdin",
cd: Path.expand("../apps/auth_web/assets", __DIR__)
]
]
config :content, Content.Endpoint,
http: [port: 4000],
debug_errors: true,
code_reloader: true,
check_origin: false,
watchers: [
node: [
"node_modules/webpack/bin/webpack.js",
"--mode",
"development",
"--watch-stdin",
cd: Path.expand("../assets", __DIR__)
]
]
# ## SSL Support
#
# In order to use HTTPS in development, a self-signed
# certificate can be generated by running the following
# Mix task:
#
# mix phx.gen.cert
#
# Note that this task requires Erlang/OTP 20 or later.
# Run `mix help phx.gen.cert` for more information.
#
# The `http:` config above can be replaced with:
#
# https: [
# port: 4001,
# cipher_suite: :strong,
# keyfile: "priv/cert/selfsigned_key.pem",
# certfile: "priv/cert/selfsigned.pem"
# ],
#
# If desired, both `http:` and `https:` keys can be
# configured to run both http and https servers on
# different ports.
# Watch static and templates for browser reloading.
config :app, AppWeb.Endpoint,
live_reload: [
patterns: [
~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
~r"priv/gettext/.*(po)$",
~r"lib/app/(live|views)/.*(ex)$",
~r"lib/app/templates/.*(eex)$"
]
]
config :content, Content.Endpoint,
live_reload: [
patterns: [
~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
~r"priv/gettext/.*(po)$",
~r"lib/content_web/(live|views)/.*(ex)$",
~r"lib/content_web/templates/.*(eex)$"
]
]
# ## SSL Support
#
# In order to use HTTPS in development, a self-signed
# certificate can be generated by running the following
# Mix task:
#
# mix phx.gen.cert
#
# Note that this task requires Erlang/OTP 20 or later.
# Run `mix help phx.gen.cert` for more information.
#
# The `http:` config above can be replaced with:
#
# https: [
# port: 4001,
# cipher_suite: :strong,
# keyfile: "priv/cert/selfsigned_key.pem",
# certfile: "priv/cert/selfsigned.pem"
# ],
#
# If desired, both `http:` and `https:` keys can be
# configured to run both http and https servers on
# different ports.
# Watch static and templates for browser reloading.
config :admin, Admin.Endpoint,
live_reload: [
patterns: [
~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
~r"priv/gettext/.*(po)$",
~r"lib/admin/(live|views)/.*(ex)$",
~r"lib/admin/templates/.*(eex)$"
]
]
# Configure your database
config :auth, Auth.Repo,
username: "postgres",
password: "postgres",
database: "legendary_dev",
hostname: "localhost",
show_sensitive_data_on_connection_error: true,
pool_size: 10
# Configure your database
config :admin, Admin.Repo,
username: "postgres",
password: "postgres",
database: "legendary_dev",
hostname: "localhost",
show_sensitive_data_on_connection_error: true,
pool_size: 10
# Configure your database
config :app, App.Repo,
username: "postgres",
password: "postgres",
database: "legendary_dev",
hostname: "localhost",
show_sensitive_data_on_connection_error: true,
pool_size: 10
config :content, Content.Repo,
username: "postgres",
password: "postgres",
database: "legendary_dev",
hostname: "localhost",
show_sensitive_data_on_connection_error: true,
pool_size: 10
config :core, Core.Repo,
username: "postgres",
password: "postgres",
database: "legendary_dev",
hostname: "localhost",
show_sensitive_data_on_connection_error: true,
pool_size: 10
# ## SSL Support
#
# In order to use HTTPS in development, a self-signed
# certificate can be generated by running the following
# Mix task:
#
# mix phx.gen.cert
#
# Note that this task requires Erlang/OTP 20 or later.
# Run `mix help phx.gen.cert` for more information.
#
# The `http:` config above can be replaced with:
#
# https: [
# port: 4001,
# cipher_suite: :strong,
# keyfile: "priv/cert/selfsigned_key.pem",
# certfile: "priv/cert/selfsigned.pem"
# ],
#
# If desired, both `http:` and `https:` keys can be
# configured to run both http and https servers on
# different ports.
# Watch static and templates for browser reloading.
config :auth_web, AuthWeb.Endpoint,
live_reload: [
patterns: [
~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
~r"priv/gettext/.*(po)$",
~r"lib/auth_web/(live|views)/.*(ex)$",
~r"lib/auth_web/templates/.*(eex)$"
]
]
config :core, CoreWeb.Endpoint,
live_reload: [
patterns: [
~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
~r"priv/gettext/.*(po)$",
~r"lib/core_web/(live|views)/.*(ex)$",
~r"lib/core_web/templates/.*(eex)$"
]
]
# For development, we disable any cache and enable
# debugging and code reloading.
#
# The watchers configuration can be used to run external
# watchers to your application. For example, we use it
# with webpack to recompile .js and .css sources.
config :content, Content.Endpoint,
http: [port: 4000],
debug_errors: true,
code_reloader: true,
check_origin: false,
watchers: [
node: [
"node_modules/webpack/bin/webpack.js",
"--mode",
"development",
"--watch-stdin",
cd: Path.expand("../apps/content_web/assets", __DIR__)
]
]
# ## SSL Support
#
# In order to use HTTPS in development, a self-signed
# certificate can be generated by running the following
# Mix task:
#
# mix phx.gen.cert
#
# Note that this task requires Erlang/OTP 20 or later.
# Run `mix help phx.gen.cert` for more information.
#
# The `http:` config above can be replaced with:
#
# https: [
# port: 4001,
# cipher_suite: :strong,
# keyfile: "priv/cert/selfsigned_key.pem",
# certfile: "priv/cert/selfsigned.pem"
# ],
#
# If desired, both `http:` and `https:` keys can be
# configured to run both http and https servers on
# different ports.
# Watch static and templates for browser reloading.
config :content, Content.Endpoint,
live_reload: [
patterns: [
~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
~r"priv/gettext/.*(po)$",
~r"lib/content_web/(live|views)/.*(ex)$",
~r"lib/content_web/templates/.*(eex)$"
]
]
[
{:admin, Admin.Repo},
{:app, App.Repo},
{:auth, Auth.Repo},
{:content, Content.Repo},
{:core, Core.Repo}
]
|> Enum.map(fn {otp_app, repo} ->
config otp_app, repo,
username: "postgres",
password: "postgres",
database: "legendary_dev",
hostname: "localhost",
show_sensitive_data_on_connection_error: true,
pool_size: 10
end)
config :core, CoreMailer, adapter: Bamboo.LocalAdapter
# ## SSL Support
#
# In order to use HTTPS in development, a self-signed
# certificate can be generated by running the following
# Mix task:
#
# mix phx.gen.cert
#
# Note that this task requires Erlang/OTP 20 or later.
# Run `mix help phx.gen.cert` for more information.
#
# The `http:` config above can be replaced with:
#
# https: [
# port: 4001,
# cipher_suite: :strong,
# keyfile: "priv/cert/selfsigned_key.pem",
# certfile: "priv/cert/selfsigned.pem"
# ],
#
# If desired, both `http:` and `https:` keys can be
# configured to run both http and https servers on
# different ports.

View file

@ -2,71 +2,40 @@ use Mix.Config
# We don't run a server during test. If one is required,
# you can enable the server option below.
config :app, App.Endpoint,
http: [port: 4002],
server: false
# We don't run a server during test. If one is required,
# you can enable the server option below.
config :admin, Admin.Endpoint,
http: [port: 4002],
server: false
[
{:admin, Admin},
{:app, AppWeb},
{:auth_web, AuthWeb},
{:content, Content},
{:core, CoreWeb},
]
|> Enum.map(fn {otp_app, module} ->
config otp_app, Module.concat(module, "Endpoint"),
http: [port: 4002],
server: false
end)
# Configure your database
#
# The MIX_TEST_PARTITION environment variable can be used
# to provide built-in test partitioning in CI environment.
# Run `mix help test` for more information.
config :auth, Auth.Repo,
username: "postgres",
password: "postgres",
database: "legendary_test#{System.get_env("MIX_TEST_PARTITION")}",
hostname: System.get_env("DATABASE_URL") || "localhost",
pool: Ecto.Adapters.SQL.Sandbox
config :content, Content.Repo,
username: "postgres",
password: "postgres",
database: "legendary_test#{System.get_env("MIX_TEST_PARTITION")}",
hostname: System.get_env("DATABASE_URL") || "localhost",
pool: Ecto.Adapters.SQL.Sandbox
config :core, Core.Repo,
username: "postgres",
password: "postgres",
database: "legendary_test#{System.get_env("MIX_TEST_PARTITION")}",
hostname: System.get_env("DATABASE_URL") || "localhost",
pool: Ecto.Adapters.SQL.Sandbox
config :admin, Admin.Repo,
username: "postgres",
password: "postgres",
database: "legendary_test#{System.get_env("MIX_TEST_PARTITION")}",
hostname: System.get_env("DATABASE_URL") || "localhost",
pool: Ecto.Adapters.SQL.Sandbox
config :app, App.Repo,
username: "postgres",
password: "postgres",
database: "legendary_test#{System.get_env("MIX_TEST_PARTITION")}",
hostname: System.get_env("DATABASE_URL") || "localhost",
pool: Ecto.Adapters.SQL.Sandbox
# We don't run a server during test. If one is required,
# you can enable the server option below.
config :auth_web, AuthWeb.Endpoint,
http: [port: 4002],
server: false
# We don't run a server during test. If one is required,
# you can enable the server option below.
config :content, Content.Endpoint,
http: [port: 4002],
server: false
config :core, AppWeb.Endpoint,
http: [port: 4002],
server: false
[
{:admin, Admin.Repo},
{:app, App.Repo},
{:auth, Auth.Repo},
{:content, Content.Repo},
{:core, Core.Repo}
]
|> Enum.map(fn {otp_app, repo} ->
config otp_app, repo,
username: "postgres",
password: "postgres",
database: "legendary_test#{System.get_env("MIX_TEST_PARTITION")}",
hostname: System.get_env("DATABASE_URL") || "localhost",
pool: Ecto.Adapters.SQL.Sandbox
end)
config :core, CoreMailer, adapter: Bamboo.TestAdapter