the phoenix template has too much stuff
Seriously, who needs all of this?
So, I'm starting a new project. I want to get this blog setup to send and receive Webmentions, so that I can do some fun social stuff here. Comments, linking to other people talking about what I write, that sorta thing. I started out by trying to implement it into the blogging engine itself, but I felt like I was running up against the design of Astro (the framework powering this place) trying to squeeze a public API and a message queue into what's basically just an on-demand static site generator. So, I'm gonna try write an external server instead.
My language of choice for building web servers lately has been Elixir. It's a decently nice language with a crazy powerful runtime - Erlang and the OTP do not fuck around. Usually I prefer to write servers from scratch, since it keeps the initial architecture nice and small, while giving me room to expand when I need some other particular feature. This time around though, I know I'm going to want a few things right off the bat:
- Some sort of worker pool, so processing Webmentions can be done asynchronously without blocking the rest of the server
- A database to hold records of all the Webmentions that come my way
- Some HTML rendering so I can have status pages for senders to see if their request was processed, and also an admin panel so I can easily review incoming Webmentions
At this point, I think we're starting to get complex enough that I'd benefit from bringing in Phoenix, the de facto standard web app framework for Elixir. It's got most of this loaded in and ready to go (LiveView in particular sounds great for my admin panel stuff), so I figure it's probably smart to start off with it.
So, I make a new Phoenix project. Easy enough - docs say:
mix archive.install phx_new
mix phx.new project_name
So I run it, and...
* creating project_name/lib/project_name/application.ex * creating project_name/lib/project_name.ex * creating project_name/lib/project_name_web/controllers/error_json.ex * creating project_name/lib/project_name_web/endpoint.ex * creating project_name/lib/project_name_web/router.ex * creating project_name/lib/project_name_web/telemetry.ex * creating project_name/lib/project_name_web.ex * creating project_name/mix.exs * creating project_name/README.md * creating project_name/.formatter.exs * creating project_name/.gitignore * creating project_name/test/support/conn_case.ex * creating project_name/test/test_helper.exs * creating project_name/test/project_name_web/controllers/error_json_test.exs * creating project_name/lib/project_name/repo.ex * creating project_name/priv/repo/migrations/.formatter.exs * creating project_name/priv/repo/seeds.exs * creating project_name/test/support/data_case.ex * creating project_name/lib/project_name_web/controllers/error_html.ex * creating project_name/test/project_name_web/controllers/error_html_test.exs * creating project_name/lib/project_name_web/components/core_components.ex * creating project_name/lib/project_name_web/controllers/page_controller.ex * creating project_name/lib/project_name_web/controllers/page_html.ex * creating project_name/lib/project_name_web/controllers/page_html/home.html.heex * creating project_name/test/project_name_web/controllers/page_controller_test.exs * creating project_name/lib/project_name_web/components/layouts/root.html.heex * creating project_name/lib/project_name_web/components/layouts/app.html.heex * creating project_name/lib/project_name_web/components/layouts.ex * creating project_name/priv/static/images/logo.svg * creating project_name/lib/project_name/mailer.ex * creating project_name/lib/project_name_web/gettext.ex * creating project_name/priv/gettext/en/LC_MESSAGES/errors.po * creating project_name/priv/gettext/errors.pot * creating project_name/priv/static/robots.txt * creating project_name/priv/static/favicon.ico * creating project_name/assets/js/app.js * creating project_name/assets/vendor/topbar.js * creating project_name/assets/css/app.css * creating project_name/assets/tailwind.config.js
...that's a lot of stuff. What is all this?
# Configures the mailer
#
# By default it uses the "Local" adapter which stores the emails
# locally. You can see the emails in your browser, at "/dev/mailbox".
#
# For production it's recommended to configure a different adapter
# at the `config/runtime.exs`.
config :project_name, ProjectName.Mailer, adapter: Swoosh.Adapters.Local
What
# Configure esbuild (the version is required)
config :esbuild,
version: "0.17.11",
project_name: [
args:
~w(js/app.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*),
cd: Path.expand("../assets", __DIR__),
env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
]
No, stop
# Configure tailwind (the version is required)
config :tailwind,
version: "3.4.3",
project_name: [
args: ~w(
--config=tailwind.config.js
--input=css/app.css
--output=../priv/static/assets/app.css
),
cd: Path.expand("../assets", __DIR__)
]
PLEASE
# Specifies your project dependencies.
#
# Type `mix help deps` for examples and options.
defp deps do
[
{:phoenix, "~> 1.7.21"},
{:phoenix_ecto, "~> 4.5"},
{:ecto_sql, "~> 3.10"},
{:postgrex, ">= 0.0.0"},
{:phoenix_html, "~> 4.1"},
{:phoenix_live_reload, "~> 1.2", only: :dev},
{:phoenix_live_view, "~> 1.0"},
{:floki, ">= 0.30.0", only: :test},
{:phoenix_live_dashboard, "~> 0.8.3"},
{:esbuild, "~> 0.8", runtime: Mix.env() == :dev},
{:tailwind, "~> 0.2.0", runtime: Mix.env() == :dev},
{:heroicons,
github: "tailwindlabs/heroicons",
tag: "v2.1.1",
sparse: "optimized",
app: false,
compile: false,
depth: 1},
{:swoosh, "~> 1.5"},
{:finch, "~> 0.13"},
{:telemetry_metrics, "~> 1.0"},
{:telemetry_poller, "~> 1.0"},
{:gettext, "~> 0.26"},
{:jason, "~> 1.2"},
{:dns_cluster, "~> 0.1.1"},
{:bandit, "~> 1.5"}
]
end
OH GOD WHY ARE THERE SO MANY DEPENDENCIES AAAAAAA
Seriously, who needs all this??? Why does the starter template come preloaded with a fucking library for sending emails? This isn't basic starter stuff! I don't need bloody Tailwind to write HTML templates! There's just so much stuff in this starter template - I probably need like, half of it? I thought I would just get an Elixir project with the Phoenix dependencies ready to go, and maybe a simple skeleton with a one-page "Welcome to Phoenix!" included, not the entire god damn kitchen sink? Why? WHY is there so much here??? Aaaaaah!!!
deep breath in
rm -rf project_name
mix new project_name
exhale. There we go. That's better. Time to see how possible it is to set this up from scratch.
Not that hard? Nice. My sanity survives another day.