defmodule Shadix.Website.Endpoint do @moduledoc """ Phoenix endpoint for the Shadix docs site (compiled only outside :prod). Serves the LiveView pages plus the locally-built CSS/JS bundles. """ use Phoenix.Endpoint, otp_app: :shadix @session_options [ store: :cookie, key: "_shadix_docs_key", signing_salt: "shadix-docs", same_site: "Lax" ] socket("/live", Phoenix.LiveView.Socket, websocket: [connect_info: [session: @session_options]]) # Local dev only (`code_reloading?` is true when `config :shadix, __MODULE__, # code_reloader: true` — set for :dev in config/config.exs). Recompiles changed # sources on each request and pushes a browser reload / CSS hot-swap when watched # files change. The `if` is compile-time, so in :test/:docs the body (and the # dev-only `Phoenix.LiveReloader` reference) is stripped entirely. if code_reloading? do socket("/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket) plug(Phoenix.LiveReloader) plug(Phoenix.CodeReloader) end # The locally-built CSS/JS bundles live under priv/static and are served at # /assets via this Plug.Static. plug(Plug.Static, at: "/", from: :shadix, only: ~w(assets) ) plug(Plug.RequestId) plug(Plug.Telemetry, event_prefix: [:phoenix, :endpoint]) plug(Plug.Parsers, parsers: [:urlencoded, :multipart, :json], pass: ["*/*"], json_decoder: Phoenix.json_library() ) plug(Plug.MethodOverride) plug(Plug.Head) plug(Plug.Session, @session_options) plug(Shadix.Website.Router) end