Sample for phoenix(elixir)-postgres

Signed-off-by: Manolis Kousanakis <ekousanakis@gmail.com>
This commit is contained in:
manolis kousanakis
2020-05-06 21:30:04 +03:00
parent 3599a2e685
commit f156dfb52c
57 changed files with 8997 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
use Mix.Config
config :app, App.Repo,
username: "postgres",
password: "postgres",
database: "AppDB",
hostname: "localhost",
port: "5432",
virtual_host: "/",
show_sensitive_data_on_connection_error: false,
pool_size: 10

View File

@@ -0,0 +1,36 @@
# This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
#
# This configuration file is loaded before any dependency and
# is restricted to this project.
# General application configuration
use Mix.Config
config :app,
ecto_repos: [App.Repo]
# Configures the endpoint
config :app, AppWeb.Endpoint,
url: [host: "localhost"],
secret_key_base: "tdFAenzqlutUbXOzX6UG6a1X4NjdLkVnlwE2Z4Lpa6l8+v1rFJmt+Dv+TikTAiog",
render_errors: [view: AppWeb.ErrorView, accepts: ~w(html json)],
pubsub: [name: App.PubSub, adapter: Phoenix.PubSub.PG2],
live_view: [signing_salt: "0Wt6gBeh"]
# Configures Elixir's Logger
config :logger, :console,
format: "$time $metadata[$level] $message\n",
metadata: [:request_id]
# Use Jason for JSON parsing in Phoenix
config :phoenix, :json_library, Jason
# 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"
if File.exists?("#{__DIR__}/#{Mix.env()}.secrets.exs") do
import_config "#{Mix.env()}.secrets.exs"
end

View File

@@ -0,0 +1,77 @@
use Mix.Config
# Configure your database
config :app, App.Repo,
username: "postgres",
password: "postgres",
database: "AppDB",
hostname: "localhost",
port: "5432",
show_sensitive_data_on_connection_error: true,
pool_size: 10
# 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 :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("../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_web/(live|views)/.*(ex)$",
~r"lib/app_web/templates/.*(eex)$"
]
]
# Do not include metadata nor timestamps in development logs
config :logger, :console, format: "[$level] $message\n"
# Set a higher stacktrace during development. Avoid configuring such
# in production as building large stacktraces may be expensive.
config :phoenix, :stacktrace_depth, 20
# Initialize plugs at runtime for faster development compilation
config :phoenix, :plug_init_mode, :runtime

View File

@@ -0,0 +1,64 @@
use Mix.Config
# For production, don't forget to configure the url host
# to something meaningful, Phoenix uses this information
# when generating URLs.
#
# Note we also include the path to a cache manifest
# containing the digested version of static files. This
# manifest is generated by the `mix phx.digest` task,
# which you should run after static files are built and
# before starting your production server.
config :app, AppWeb.Endpoint,
url: [host: "localhost", port: 80],
cache_static_manifest: "priv/static/cache_manifest.json"
# Do not print debug messages in production
config :logger, level: :info
# ## SSL Support
#
# To get SSL working, you will need to add the `https` key
# to the previous section and set your `:url` port to 443:
#
# config :app, AppWeb.Endpoint,
# ...
# url: [host: "example.com", port: 443],
# https: [
# port: 443,
# cipher_suite: :strong,
# keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"),
# certfile: System.get_env("SOME_APP_SSL_CERT_PATH"),
# transport_options: [socket_opts: [:inet6]]
# ]
#
# The `cipher_suite` is set to `:strong` to support only the
# latest and more secure SSL ciphers. This means old browsers
# and clients may not be supported. You can set it to
# `:compatible` for wider support.
#
# `:keyfile` and `:certfile` expect an absolute path to the key
# and cert in disk or a relative path inside priv, for example
# "priv/ssl/server.key". For all supported SSL configuration
# options, see https://hexdocs.pm/plug/Plug.SSL.html#configure/1
#
# We also recommend setting `force_ssl` in your endpoint, ensuring
# no data is ever sent via http, always redirecting to https:
#
# config :app, AppWeb.Endpoint,
# force_ssl: [hsts: true]
#
# Check `Plug.SSL` for all available options in `force_ssl`.
# Finally import the config/prod.secret.exs which loads secrets
# and configuration from environment variables.
# ## Using releases (Elixir v1.9+)
#
# If you are doing OTP releases, you need to instruct Phoenix
# to start each relevant endpoint:
#
config :app, AppWeb.Endpoint, server: true
#
# Then you can assemble a release by calling `mix release`.
# See `mix help release` for more information.

View File

@@ -0,0 +1,20 @@
import Config
# We load production configuration and secrets from environment variables
config :app, App.Repo,
username: System.fetch_env!("POSTGRES_USER"),
password: System.fetch_env!("POSTGRES_PASSWORD"),
database: System.fetch_env!("POSTGRES_DB"),
hostname: System.fetch_env!("PGHOST"),
port: String.to_integer(System.get_env("PGPORT") || "5432"),
virtual_host: "/",
show_sensitive_data_on_connection_error: false,
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")
config :app, AppWeb.Endpoint,
url: [host: System.get_env("host") || "localhost"],
http: [
port: String.to_integer(System.get_env("PORT") || "4000"),
transport_options: [socket_opts: [:inet6]]
]

View File

@@ -0,0 +1,18 @@
use Mix.Config
# Configure your database
config :app, App.Repo,
username: "postgres",
password: "postgres",
database: "app_test",
hostname: "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 :app, AppWeb.Endpoint,
http: [port: 4002],
server: false
# Print only warnings and errors during test
config :logger, level: :warn