elixir phoenix example

This commit is contained in:
Andras Bacsai
2024-09-10 11:53:27 +02:00
parent 8e86943e66
commit 0a67a3103e
45 changed files with 2585 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
defmodule Hello.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
@impl true
def start(_type, _args) do
children = [
HelloWeb.Telemetry,
Hello.Repo,
{DNSCluster, query: Application.get_env(:hello, :dns_cluster_query) || :ignore},
{Phoenix.PubSub, name: Hello.PubSub},
# Start the Finch HTTP client for sending emails
{Finch, name: Hello.Finch},
# Start a worker by calling: Hello.Worker.start_link(arg)
# {Hello.Worker, arg},
# Start to serve requests, typically the last entry
HelloWeb.Endpoint
]
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: Hello.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
HelloWeb.Endpoint.config_change(changed, removed)
:ok
end
end

View File

@@ -0,0 +1,3 @@
defmodule Hello.Mailer do
use Swoosh.Mailer, otp_app: :hello
end

View File

@@ -0,0 +1,5 @@
defmodule Hello.Repo do
use Ecto.Repo,
otp_app: :hello,
adapter: Ecto.Adapters.Postgres
end