this repo has no description

Remove generated cruft from default scaffolding

hauleth.dev 4dda3b83 9a6efa6d

verified
+3 -6
config/config.exs
···
# This configuration file is loaded before any dependency and
# is restricted to this project.
-
# General application configuration
import Config
config :esl_hn,
···
# Configures Elixir's Logger
config :logger, :console,
format: "$time $metadata[$level] $message\n",
-
metadata: [:request_id]
+
metadata: [:request_id, :file, :line, :mfa]
-
# Use Jason for JSON parsing in Phoenix
-
config :phoenix, :json_library, Jason
+
# Use built in JSON for JSON parsing in Phoenix
+
config :phoenix, :json_library, JSON
-
# Import environment specific config. This must remain at the bottom
-
# of this file so it overrides the configuration defined above.
import_config "#{config_env()}.exs"
+2 -10
config/dev.exs
···
# 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 can use it
-
# to bundle .js and .css sources.
config :esl_hn, EslHnWeb.Endpoint,
-
# Binding to loopback ipv4 address prevents access from other machines.
-
# Change to `ip: {0, 0, 0, 0}` to allow access from other machines.
http: [ip: {127, 0, 0, 1}, port: 4000],
check_origin: false,
code_reloader: true,
···
# Enable dev routes for dashboard and mailbox
config :esl_hn, dev_routes: true
-
# Do not include metadata nor timestamps in development logs
-
config :logger, :console, format: "[$level] $message\n"
+
# Do not include timestamps in development logs
+
config :logger, :console, format: "$metadata[$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
-3
config/prod.exs
···
# Do not print debug messages in production
config :logger, level: :info
-
-
# Runtime production configuration, including reading
-
# of environment variables, is done on config/runtime.exs.
-18
config/runtime.exs
···
import Config
-
# config/runtime.exs is executed for all environments, including
-
# during releases. It is executed after compilation and before the
-
# system starts, so it is typically used to load production configuration
-
# and secrets from environment variables or elsewhere. Do not define
-
# any compile-time configuration in here, as it won't be applied.
-
# The block below contains prod specific runtime configuration.
-
# ## Using releases
#
# If you use `mix release`, you need to explicitly enable the server
···
end
if config_env() == :prod do
-
# The secret key base is used to sign/encrypt cookies and other secrets.
-
# A default value is used in config/dev.exs and config/test.exs but you
-
# want to use a different value for prod and you most likely don't want
-
# to check this value into version control, so we use an environment
-
# variable instead.
secret_key_base =
System.get_env("SECRET_KEY_BASE") ||
raise """
···
host = System.get_env("PHX_HOST") || "example.com"
port = String.to_integer(System.get_env("PORT") || "4000")
-
-
config :esl_hn, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY")
config :esl_hn, EslHnWeb.Endpoint,
url: [host: host, port: 443, scheme: "https"],
http: [
-
# Enable IPv6 and bind on all interfaces.
-
# Set it to {0, 0, 0, 0, 0, 0, 0, 1} for local network only access.
-
# See the documentation on https://hexdocs.pm/bandit/Bandit.html#t:options/0
-
# for details about using IPv6 vs IPv4 and loopback vs public addresses.
ip: {0, 0, 0, 0, 0, 0, 0, 0},
port: port
],
-11
lib/esl_hn/application.ex
···
defmodule EslHn.Application do
-
# See https://hexdocs.pm/elixir/Application.html
-
# for more information on OTP Applications
@moduledoc false
use Application
···
def start(_type, _args) do
children = [
EslHnWeb.Telemetry,
-
{DNSCluster,
-
query: Application.get_env(:esl_hn, :dns_cluster_query) || :ignore},
{Phoenix.PubSub, name: EslHn.PubSub},
-
# Start a worker by calling: EslHn.Worker.start_link(arg)
-
# {EslHn.Worker, arg},
-
# Start to serve requests, typically the last entry
EslHnWeb.Endpoint
]
-
# See https://hexdocs.pm/elixir/Supervisor.html
-
# for other strategies and supported options
opts = [strategy: :one_for_one, name: EslHn.Supervisor]
Supervisor.start_link(children, opts)
end
-
# Tell Phoenix to update the endpoint configuration
-
# whenever the application is updated.
@impl true
def config_change(changed, _new, removed) do
EslHnWeb.Endpoint.config_change(changed, removed)
+2 -2
lib/esl_hn_web.ex
···
def controller do
quote do
use Phoenix.Controller,
-
formats: [:html, :json],
-
layouts: [html: EslHnWeb.Layouts]
+
formats: [:json],
+
layouts: []
import Plug.Conn
+2 -11
lib/esl_hn_web/endpoint.ex
···
defmodule EslHnWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :esl_hn
-
# The session will be stored in the cookie and signed,
-
# this means its contents can be read but not tampered with.
-
# Set :encryption_salt if you would also like to encrypt it.
@session_options [
store: :cookie,
key: "_esl_hn_key",
···
websocket: [connect_info: [session: @session_options]],
longpoll: [connect_info: [session: @session_options]]
-
# Serve at "/" the static files from "priv/static" directory.
-
#
-
# You should set gzip to true if you are running phx.digest
-
# when deploying your static files in production.
plug Plug.Static,
at: "/",
from: :esl_hn,
gzip: false,
only: EslHnWeb.static_paths()
-
# Code reloading can be explicitly enabled under the
-
# :code_reloader configuration of your endpoint.
if code_reloading? do
plug Phoenix.CodeReloader
end
···
plug Plug.Telemetry, event_prefix: [:phoenix, :endpoint]
plug Plug.Parsers,
-
parsers: [:urlencoded, :multipart, :json],
-
pass: ["*/*"],
+
parsers: [:json],
+
pass: ["application/json"],
json_decoder: Phoenix.json_library()
plug Plug.MethodOverride
-6
lib/esl_hn_web/router.ex
···
pipe_through :api
end
-
# Enable LiveDashboard in development
if Application.compile_env(:esl_hn, :dev_routes) do
-
# If you want to use the LiveDashboard in production, you should put
-
# it behind authentication and allow only admins to access it.
-
# If your application does not have an admins-only section yet,
-
# you can use Plug.BasicAuth to set up some basic authentication
-
# as long as you are also using SSL (which you should anyway).
import Phoenix.LiveDashboard.Router
scope "/dev" do
+1 -9
lib/esl_hn_web/telemetry.ex
···
@impl true
def init(_arg) do
children = [
-
# Telemetry poller will execute the given period measurements
-
# every 10_000ms. Learn more here: https://hexdocs.pm/telemetry_metrics
{:telemetry_poller, measurements: periodic_measurements(), period: 10_000}
-
# Add reporters as children of your supervision tree.
-
# {Telemetry.Metrics.ConsoleReporter, metrics: metrics()}
]
Supervisor.init(children, strategy: :one_for_one)
···
end
defp periodic_measurements do
-
[
-
# A module, function and arguments to be invoked periodically.
-
# This function must call :telemetry.execute/3 and a metric must be added above.
-
# {EslHnWeb, :count_users, []}
-
]
+
[]
end
end
-15
mix.exs
···
]
end
-
# Configuration for the OTP application.
-
#
-
# Type `mix help compile.app` for more information.
def application do
[
mod: {EslHn.Application, []},
···
]
end
-
# Specifies which paths to compile per environment.
defp elixirc_paths(:test), do: ["lib", "test/support"]
defp elixirc_paths(_), do: ["lib"]
-
# Specifies your project dependencies.
-
#
-
# Type `mix help deps` for examples and options.
defp deps do
[
{:phoenix, "~> 1.7.21"},
{:phoenix_live_dashboard, "~> 0.8.3"},
{:telemetry_metrics, "~> 1.0"},
{:telemetry_poller, "~> 1.0"},
-
{:jason, "~> 1.2"},
-
{:dns_cluster, "~> 0.1.1"},
{:bandit, "~> 1.5"}
]
end
-
# Aliases are shortcuts or tasks specific to the current project.
-
# For example, to install project dependencies and perform other setup tasks, run:
-
#
-
# $ mix setup
-
#
-
# See the documentation for `Mix` for more info on aliases.
defp aliases do
[
setup: ["deps.get"]