Updates
This commit is contained in:
parent
3f32b67a57
commit
7137810124
10
config.exs
Normal file
10
config.exs
Normal file
|
@ -0,0 +1,10 @@
|
|||
if Mix.env() == :dev do
|
||||
Application.put_env(:sfe, Sfe.Endpoint,
|
||||
# not sure why, but these must be set at compile time?
|
||||
code_reloader: true,
|
||||
debug_errors: true
|
||||
)
|
||||
|
||||
Application.put_env(:sfe, :dev_routes, true)
|
||||
end
|
||||
|
|
@ -2,11 +2,11 @@
|
|||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1708407374,
|
||||
"narHash": "sha256-EECzarm+uqnNDCwaGg/ppXCO11qibZ1iigORShkkDf0=",
|
||||
"lastModified": 1711715736,
|
||||
"narHash": "sha256-9slQ609YqT9bT/MNX9+5k5jltL9zgpn36DpFB7TkttM=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "f33dd27a47ebdf11dc8a5eb05e7c8fbdaf89e73f",
|
||||
"rev": "807c549feabce7eddbf259dbdcec9e0600a0660d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
65
flake.nix
65
flake.nix
|
@ -4,12 +4,11 @@
|
|||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
# self,
|
||||
nixpkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (self) outputs;
|
||||
|
||||
# inherit (self) outputs;
|
||||
systems = [
|
||||
"aarch64-linux"
|
||||
"aarch64-darwin"
|
||||
|
@ -21,39 +20,49 @@
|
|||
|
||||
nixpkgsFor = system: import nixpkgs {inherit system;};
|
||||
in {
|
||||
packages = forAllSystems (system: let
|
||||
pkgs = nixpkgsFor system;
|
||||
# packages = forAllSystems (system: let
|
||||
# pkgs = nixpkgsFor system;
|
||||
|
||||
inherit (pkgs) beamPackages;
|
||||
inherit (beamPackages) mixRelease fetchMixDeps;
|
||||
# inherit (pkgs) beamPackages;
|
||||
# inherit (beamPackages) mixRelease fetchMixDeps;
|
||||
|
||||
version = "0.1.0";
|
||||
src = ./.;
|
||||
pname = "api.lyte.dev";
|
||||
in {
|
||||
# this-package = mixRelease {
|
||||
# inherit pname version src;
|
||||
# mixFodDeps = fetchMixDeps {
|
||||
# inherit version src;
|
||||
# pname = "mix-deps-${pname}";
|
||||
# hash = pkgs.lib.fakeSha256;
|
||||
# };
|
||||
# buildInputs = with pkgs; [sqlite];
|
||||
# HOME = "$(pwd)";
|
||||
# MIX_XDG = "$HOME";
|
||||
# };
|
||||
# version = "0.1.0";
|
||||
# src = ./.;
|
||||
# pname = "api.lyte.dev";
|
||||
# in {
|
||||
# # this-package = mixRelease {
|
||||
# # inherit pname version src;
|
||||
# # mixFodDeps = fetchMixDeps {
|
||||
# # inherit version src;
|
||||
# # pname = "mix-deps-${pname}";
|
||||
# # hash = pkgs.lib.fakeSha256;
|
||||
# # };
|
||||
# # buildInputs = with pkgs; [sqlite];
|
||||
# # HOME = "$(pwd)";
|
||||
# # MIX_XDG = "$HOME";
|
||||
# # };
|
||||
|
||||
# default = outputs.packages.${system}.this-package;
|
||||
});
|
||||
# # default = outputs.packages.${system}.this-package;
|
||||
# });
|
||||
|
||||
devShells = forAllSystems (system: let
|
||||
pkgs = nixpkgsFor system;
|
||||
erlang = pkgs.beam.packages.erlang_26;
|
||||
elixir = erlang.elixir_1_16;
|
||||
pkgs = (nixpkgsFor system).extend (final: prev: {
|
||||
erlang = prev.beam.packages.erlang_26;
|
||||
elixir = final.erlang.elixir_1_16;
|
||||
elixir-ls = prev.elixir-ls.override {elixir = final.elixir;};
|
||||
});
|
||||
in {
|
||||
default = pkgs.mkShell {
|
||||
shellHook = "export LOCALE_ARCHIVE=/usr/lib/locale/locale-archive";
|
||||
buildInputs = with pkgs; [inotify-tools erlang_26 elixir elixir-ls watchexec];
|
||||
buildInputs = with pkgs; [
|
||||
erlang.erlang
|
||||
elixir
|
||||
elixir-ls
|
||||
|
||||
inotify-tools
|
||||
|
||||
watchexec
|
||||
];
|
||||
};
|
||||
});
|
||||
};
|
||||
|
|
64
main.ex
64
main.ex
|
@ -1,3 +1,15 @@
|
|||
Application.put_env(:Sfe, :ecto_repos, [Sfe.Repo])
|
||||
Application.put_env(:Sfe, :generators, binary_id: true)
|
||||
Application.put_env(:Sfe, Sfe.Endpoint, live_reload: [
|
||||
|
||||
patterns: [
|
||||
# ~r{priv/static/.*(js|css|png|jpeg|jpg|gif)$},
|
||||
# ~r{lib/my_app_web/views/.*(ex)$},
|
||||
# ~r{lib/my_app_web/templates/.*(eex)$}
|
||||
~r{main.ex},
|
||||
]
|
||||
])
|
||||
|
||||
# application
|
||||
defmodule Sfe do
|
||||
defmodule Application do
|
||||
|
@ -45,6 +57,12 @@ defmodule Sfe do
|
|||
|
||||
pipeline :browser do
|
||||
plug(:accepts, ["html"])
|
||||
plug(:fetch_session)
|
||||
plug(:fetch_live_flash)
|
||||
# plug(:put_root_layout, {LyricsWeb.Layouts, :root})
|
||||
plug(:protect_from_forgery)
|
||||
plug(:put_secure_browser_headers)
|
||||
# plug(:fetch_current_user)
|
||||
end
|
||||
|
||||
scope "/", Sfe do
|
||||
|
@ -57,13 +75,47 @@ defmodule Sfe do
|
|||
defmodule Endpoint do
|
||||
use Phoenix.Endpoint, otp_app: :sfe
|
||||
|
||||
plug(Plug.RequestId)
|
||||
plug(Plug.Telemetry, event_prefix: [:phoenix, :endpoint])
|
||||
|
||||
@session_options [
|
||||
store: :cookie,
|
||||
key: "_lyrics_key",
|
||||
signing_salt: "1MoCZ/LL",
|
||||
same_site: "Lax"
|
||||
]
|
||||
|
||||
# plug Plug.Static,
|
||||
# at: "/",
|
||||
# from: :lyrics,
|
||||
# gzip: false,
|
||||
# only: LyricsWeb.static_paths()
|
||||
|
||||
IO.inspect(code_reloading?)
|
||||
dbg(code_reloading?)
|
||||
if code_reloading? do
|
||||
socket("/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket)
|
||||
plug(Phoenix.LiveReloader)
|
||||
dbg(Phoenix.LiveReloader)
|
||||
plug(Phoenix.CodeReloader)
|
||||
# plug Phoenix.Ecto.CheckRepoStatus, otp_app: :lyrics
|
||||
end
|
||||
|
||||
socket("/live", Phoenix.LiveView.Socket)
|
||||
require Logger
|
||||
Logger.warning("#{code_reloading?}")
|
||||
|
||||
plug(Plug.Session, @session_options)
|
||||
|
||||
socket("/live", Phoenix.LiveView.Socket,
|
||||
websocket: [connect_info: [session: @session_options]]
|
||||
)
|
||||
|
||||
plug(Plug.Parsers,
|
||||
parsers: [:urlencoded, :multipart, :json],
|
||||
pass: ["*/*"],
|
||||
json_decoder: Phoenix.json_library()
|
||||
)
|
||||
|
||||
plug(Sfe.Router)
|
||||
end
|
||||
end
|
||||
|
@ -86,16 +138,24 @@ defmodule Sfe.HomeLive do
|
|||
|
||||
def render("live.html", assigns) do
|
||||
~H"""
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="csrf-token" content={Phoenix.Controller.get_csrf_token()} />
|
||||
</head>
|
||||
<body>
|
||||
<script src={"https://cdn.jsdelivr.net/npm/phoenix@#{phx_vsn()}/priv/static/phoenix.min.js"}></script>
|
||||
<script src={"https://cdn.jsdelivr.net/npm/phoenix_live_view@#{lv_vsn()}/priv/static/phoenix_live_view.min.js"}></script>
|
||||
<script>
|
||||
let liveSocket = new window.LiveView.LiveSocket("/live", window.Phoenix.Socket)
|
||||
let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content");
|
||||
let liveSocket = new window.LiveView.LiveSocket("/live", window.Phoenix.Socket, {params: {_csrf_token: csrfToken}})
|
||||
liveSocket.connect()
|
||||
</script>
|
||||
<style>
|
||||
* { font-size: 1.1em; }
|
||||
</style>
|
||||
<%= @inner_content %>
|
||||
</body>
|
||||
"""
|
||||
end
|
||||
|
||||
|
|
10
mix.exs
10
mix.exs
|
@ -9,6 +9,8 @@ defmodule Sfe.MixProject do
|
|||
elixirc_paths: ["main.ex"],
|
||||
compilers: Mix.compilers(),
|
||||
start_permanent: Mix.env() == :prod,
|
||||
config_path: "config.exs",
|
||||
aliases: aliases(),
|
||||
elixirc_options: [warnings_as_errors: true],
|
||||
deps: deps()
|
||||
]
|
||||
|
@ -25,7 +27,13 @@ defmodule Sfe.MixProject do
|
|||
{:jason, "~> 1.0"},
|
||||
{:phoenix, "~> 1.7"},
|
||||
{:phoenix_live_view, "~> 0.19.0"},
|
||||
{:phoenix_live_reload, "~> 1.4", only: :dev},
|
||||
{:phoenix_live_reload, "~> 1.5", only: :dev},
|
||||
{:phoenix_pubsub, "~> 2.1"}
|
||||
]
|
||||
|
||||
defp aliases,
|
||||
do: [
|
||||
setup: ["deps.get", "assets.setup", "assets.build"],
|
||||
dev: ["phx.server"]
|
||||
]
|
||||
end
|
||||
|
|
12
mix.lock
12
mix.lock
|
@ -1,20 +1,20 @@
|
|||
%{
|
||||
"bandit": {:hex, :bandit, "1.2.2", "569fe5d0efb107c9af37a1e37e25ce2ceec293101a2d4bc512876fc3207192b5", [:mix], [{:hpax, "~> 0.1.1", [hex: :hpax, repo: "hexpm", optional: false]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:thousand_island, "~> 1.0", [hex: :thousand_island, repo: "hexpm", optional: false]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "2f89adb7281c78d4e75733e0a9e1b24f46f84d2993963d6fa57d0eafadec5f03"},
|
||||
"castore": {:hex, :castore, "1.0.5", "9eeebb394cc9a0f3ae56b813459f990abb0a3dedee1be6b27fdb50301930502f", [:mix], [], "hexpm", "8d7c597c3e4a64c395980882d4bca3cebb8d74197c590dc272cfd3b6a6310578"},
|
||||
"file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
|
||||
"bandit": {:hex, :bandit, "1.4.1", "6ff703b33a967bc20b41ed3840a4c58e62abe62b4cc598cff7429af78e174990", [:mix], [{:hpax, "~> 0.1.1", [hex: :hpax, repo: "hexpm", optional: false]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:thousand_island, "~> 1.0", [hex: :thousand_island, repo: "hexpm", optional: false]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "5bbc0a4c185358b7d566a3b7b32806723ae139a8704cdc841ad787b677adcb9a"},
|
||||
"castore": {:hex, :castore, "1.0.6", "ffc42f110ebfdafab0ea159cd43d31365fa0af0ce4a02ecebf1707ae619ee727", [:mix], [], "hexpm", "374c6e7ca752296be3d6780a6d5b922854ffcc74123da90f2f328996b962d33a"},
|
||||
"file_system": {:hex, :file_system, "1.0.0", "b689cc7dcee665f774de94b5a832e578bd7963c8e637ef940cd44327db7de2cd", [:mix], [], "hexpm", "6752092d66aec5a10e662aefeed8ddb9531d79db0bc145bb8c40325ca1d8536d"},
|
||||
"hpax": {:hex, :hpax, "0.1.2", "09a75600d9d8bbd064cdd741f21fc06fc1f4cf3d0fcc335e5aa19be1a7235c84", [:mix], [], "hexpm", "2c87843d5a23f5f16748ebe77969880e29809580efdaccd615cd3bed628a8c13"},
|
||||
"jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"},
|
||||
"mime": {:hex, :mime, "2.0.5", "dc34c8efd439abe6ae0343edbb8556f4d63f178594894720607772a041b04b02", [:mix], [], "hexpm", "da0d64a365c45bc9935cc5c8a7fc5e49a0e0f9932a761c55d6c52b142780a05c"},
|
||||
"phoenix": {:hex, :phoenix, "1.7.11", "1d88fc6b05ab0c735b250932c4e6e33bfa1c186f76dcf623d8dd52f07d6379c7", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.7", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:websock_adapter, "~> 0.5.3", [hex: :websock_adapter, repo: "hexpm", optional: false]}], "hexpm", "b1ec57f2e40316b306708fe59b92a16b9f6f4bf50ccfa41aa8c7feb79e0ec02a"},
|
||||
"phoenix_html": {:hex, :phoenix_html, "3.3.3", "380b8fb45912b5638d2f1d925a3771b4516b9a78587249cabe394e0a5d579dc9", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "923ebe6fec6e2e3b3e569dfbdc6560de932cd54b000ada0208b5f45024bdd76c"},
|
||||
"phoenix_live_reload": {:hex, :phoenix_live_reload, "1.4.1", "2aff698f5e47369decde4357ba91fc9c37c6487a512b41732818f2204a8ef1d3", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm", "9bffb834e7ddf08467fe54ae58b5785507aaba6255568ae22b4d46e2bb3615ab"},
|
||||
"phoenix_live_reload": {:hex, :phoenix_live_reload, "1.5.3", "f2161c207fda0e4fb55165f650f7f8db23f02b29e3bff00ff7ef161d6ac1f09d", [:mix], [{:file_system, "~> 0.3 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm", "b4ec9cd73cb01ff1bd1cac92e045d13e7030330b74164297d1aee3907b54803c"},
|
||||
"phoenix_live_view": {:hex, :phoenix_live_view, "0.19.5", "6e730595e8e9b8c5da230a814e557768828fd8dfeeb90377d2d8dbb52d4ec00a", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.6.15 or ~> 1.7.0", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.3", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.2 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "b2eaa0dd3cfb9bd7fb949b88217df9f25aed915e986a28ad5c8a0d054e7ca9d3"},
|
||||
"phoenix_pubsub": {:hex, :phoenix_pubsub, "2.1.3", "3168d78ba41835aecad272d5e8cd51aa87a7ac9eb836eabc42f6e57538e3731d", [:mix], [], "hexpm", "bba06bc1dcfd8cb086759f0edc94a8ba2bc8896d5331a1e2c2902bf8e36ee502"},
|
||||
"phoenix_template": {:hex, :phoenix_template, "1.0.4", "e2092c132f3b5e5b2d49c96695342eb36d0ed514c5b252a77048d5969330d639", [:mix], [{:phoenix_html, "~> 2.14.2 or ~> 3.0 or ~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}], "hexpm", "2c0c81f0e5c6753faf5cca2f229c9709919aba34fab866d3bc05060c9c444206"},
|
||||
"plug": {:hex, :plug, "1.15.3", "712976f504418f6dff0a3e554c40d705a9bcf89a7ccef92fc6a5ef8f16a30a97", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "cc4365a3c010a56af402e0809208873d113e9c38c401cabd88027ef4f5c01fd2"},
|
||||
"plug_crypto": {:hex, :plug_crypto, "2.0.0", "77515cc10af06645abbfb5e6ad7a3e9714f805ae118fa1a70205f80d2d70fe73", [:mix], [], "hexpm", "53695bae57cc4e54566d993eb01074e4d894b65a3766f1c43e2c61a1b0f45ea9"},
|
||||
"telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"},
|
||||
"thousand_island": {:hex, :thousand_island, "1.3.2", "bc27f9afba6e1a676dd36507d42e429935a142cf5ee69b8e3f90bff1383943cd", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "0e085b93012cd1057b378fce40cbfbf381ff6d957a382bfdd5eca1a98eec2535"},
|
||||
"thousand_island": {:hex, :thousand_island, "1.3.5", "6022b6338f1635b3d32406ff98d68b843ba73b3aa95cfc27154223244f3a6ca5", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "2be6954916fdfe4756af3239fb6b6d75d0b8063b5df03ba76fd8a4c87849e180"},
|
||||
"websock": {:hex, :websock, "0.5.3", "2f69a6ebe810328555b6fe5c831a851f485e303a7c8ce6c5f675abeb20ebdadc", [:mix], [], "hexpm", "6105453d7fac22c712ad66fab1d45abdf049868f253cf719b625151460b8b453"},
|
||||
"websock_adapter": {:hex, :websock_adapter, "0.5.5", "9dfeee8269b27e958a65b3e235b7e447769f66b5b5925385f5a569269164a210", [:mix], [{:bandit, ">= 0.6.0", [hex: :bandit, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.6", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "4b977ba4a01918acbf77045ff88de7f6972c2a009213c515a445c48f224ffce9"},
|
||||
"websock_adapter": {:hex, :websock_adapter, "0.5.6", "0437fe56e093fd4ac422de33bf8fc89f7bc1416a3f2d732d8b2c8fd54792fe60", [:mix], [{:bandit, ">= 0.6.0", [hex: :bandit, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.6", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "e04378d26b0af627817ae84c92083b7e97aca3121196679b73c73b99d0d133ea"},
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue