Skip to content

Commit d9daa2b

Browse files
committed
Update everything and more
1 parent 693ba3a commit d9daa2b

File tree

25 files changed

+219
-160
lines changed

25 files changed

+219
-160
lines changed

.tool-versions

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
erlang 26.0.2
2-
elixir 1.15.5-otp-26
1+
erlang 27.3.2
2+
elixir 1.18.3-otp-27
33
nodejs 20.5.1

assets/css/app.css

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
.home {
2-
display: flex;
3-
flex-direction: column;
4-
justify-content: center;
5-
align-items: center;
6-
padding: 40px;
7-
text-align: center;
1+
body {
82
font-family:
93
system-ui,
104
-apple-system,
@@ -19,6 +13,15 @@
1913
'Segoe UI Emoji',
2014
'Segoe UI Symbol',
2115
'Noto Color Emoji';
16+
}
17+
18+
.home {
19+
display: flex;
20+
flex-direction: column;
21+
justify-content: center;
22+
align-items: center;
23+
padding: 40px;
24+
text-align: center;
2225
line-height: 1.4;
2326
}
2427

@@ -37,7 +40,24 @@
3740

3841
.flash-messages {
3942
position: fixed;
40-
top: 0;
41-
right: 0;
43+
top: 5px;
44+
right: 5px;
45+
display: flex;
46+
flex-direction: column;
47+
gap: 5px;
48+
z-index: 1000;
49+
}
50+
51+
#flash-success {
52+
padding: 10px;
53+
color: #123c12;
54+
border: 1px solid rgb(62, 146, 62);
55+
background-color: #90d690;
56+
}
57+
58+
#flash-error {
4259
padding: 10px;
60+
color: #3c1212;
61+
border: 1px solid rgb(144, 35, 35);
62+
background-color: #d68d8d;
4363
}

assets/js/app.js renamed to assets/js/app.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
1-
import 'simple-css-reset/reset.css';
21
import '../css/app.css';
32

43
import {Socket} from 'phoenix';
54
import {LiveSocket} from 'phoenix_live_view';
65

7-
const FLASH_TTL = 8000;
8-
const Hooks = {};
6+
interface Hook {
7+
mounted?(): void;
8+
destroyed?(): void;
9+
}
10+
11+
interface FlashHook extends Hook {
12+
el: HTMLElement;
13+
timer: ReturnType<typeof setTimeout>;
14+
FLASH_TTL: number;
15+
_hide(): void;
16+
}
17+
18+
const Hooks: Record<string, Hook> = {};
919

1020
Hooks.Flash = {
11-
mounted() {
12-
this.timer = setTimeout(() => this._hide(), FLASH_TTL);
21+
el: null as unknown as HTMLElement,
22+
timer: null as unknown as ReturnType<typeof setTimeout>,
23+
FLASH_TTL: 8000,
24+
25+
mounted(this: FlashHook) {
26+
this.timer = setTimeout(() => this._hide(), this.FLASH_TTL);
1327

1428
this.el.addEventListener('mouseover', () => {
1529
clearTimeout(this.timer);
16-
this.timer = setTimeout(() => this._hide(), FLASH_TTL);
30+
this.timer = setTimeout(() => this._hide(), this.FLASH_TTL);
1731
});
1832
},
1933

@@ -24,11 +38,11 @@ Hooks.Flash = {
2438
_hide() {
2539
liveSocket.execJS(this.el, this.el.getAttribute('phx-click'));
2640
}
27-
};
41+
} as FlashHook;
2842

2943
const csrfToken = document
3044
.querySelector("meta[name='csrf-token']")
31-
.getAttribute('content');
45+
?.getAttribute('content');
3246

3347
const liveSocket = new LiveSocket('/live', Socket, {
3448
hooks: Hooks,

assets/package-lock.json

Lines changed: 31 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@
1010
"dependencies": {
1111
"phoenix": "^1.7.7",
1212
"phoenix_html": "^3.3.1",
13-
"phoenix_live_view": "^0.20.14",
14-
"simple-css-reset": "^3.0.0"
13+
"phoenix_live_view": "^1.0.0"
1514
},
1615
"devDependencies": {
1716
"@babel/eslint-parser": "^7.23.10",
17+
"@types/phoenix": "^1.6.6",
18+
"@types/phoenix_live_view": "^1.0.0",
1819
"eslint": "^8.57.0",
1920
"eslint-plugin-mirego": "^1.0.0",
2021
"prettier": "^3.2.5",
2122
"stylelint": "^15.11.0",
2223
"stylelint-config-mirego": "^2.3.0",
23-
"stylelint-scss": "^5.3.2",
24-
"stylelint-order": "^6.0.4"
24+
"stylelint-order": "^6.0.4",
25+
"stylelint-scss": "^5.3.2"
2526
}
2627
}

config/config.exs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,45 @@ import Config
22

33
version = Mix.Project.config()[:version]
44

5-
config :elixir_boilerplate,
6-
ecto_repos: [ElixirBoilerplate.Repo],
7-
version: version
8-
9-
config :phoenix, :json_library, Jason
5+
config :absinthe_security, AbsintheSecurity.Phase.MaxAliasesCheck, max_alias_count: 100
6+
config :absinthe_security, AbsintheSecurity.Phase.MaxDepthCheck, max_depth_count: 100
7+
config :absinthe_security, AbsintheSecurity.Phase.MaxDirectivesCheck, max_directive_count: 100
108

11-
config :elixir_boilerplate, ElixirBoilerplateWeb.Endpoint,
12-
pubsub_server: ElixirBoilerplate.PubSub,
13-
render_errors: [view: ElixirBoilerplateWeb.Errors, accepts: ~w(html json)]
9+
config :elixir_boilerplate, Corsica, allow_headers: :all
10+
config :elixir_boilerplate, ElixirBoilerplate.Gettext, default_locale: "en"
1411

1512
config :elixir_boilerplate, ElixirBoilerplate.Repo,
1613
migration_primary_key: [type: :binary_id, default: {:fragment, "gen_random_uuid()"}],
1714
migration_timestamps: [type: :utc_datetime_usec],
1815
start_apps_before_migration: [:ssl]
1916

20-
config :elixir_boilerplate, Corsica, allow_headers: :all
21-
22-
config :elixir_boilerplate, ElixirBoilerplate.Gettext, default_locale: "en"
23-
2417
config :elixir_boilerplate, ElixirBoilerplateGraphQL, token_limit: 2000
2518

19+
config :elixir_boilerplate, ElixirBoilerplateWeb.Endpoint,
20+
pubsub_server: ElixirBoilerplate.PubSub,
21+
render_errors: [view: ElixirBoilerplateWeb.Errors, accepts: ~w(html json)]
22+
2623
config :elixir_boilerplate, ElixirBoilerplateWeb.Plugs.Security, allow_unsafe_scripts: false
2724

28-
config :absinthe_security, AbsintheSecurity.Phase.MaxAliasesCheck, max_alias_count: 100
29-
config :absinthe_security, AbsintheSecurity.Phase.MaxDepthCheck, max_depth_count: 100
30-
config :absinthe_security, AbsintheSecurity.Phase.MaxDirectivesCheck, max_directive_count: 100
25+
config :elixir_boilerplate,
26+
ecto_repos: [ElixirBoilerplate.Repo],
27+
version: version
3128

3229
config :esbuild,
3330
version: "0.16.4",
3431
default: [
35-
args: ~w(js/app.js --bundle --target=es2016 --outdir=../priv/static/assets),
32+
args: ~w(js/app.ts --bundle --target=es2020 --outdir=../priv/static/assets),
3633
cd: Path.expand("../assets", __DIR__),
3734
env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
3835
]
3936

37+
config :logger, backends: [:console, Sentry.LoggerBackend]
38+
39+
# Import environment configuration
40+
config :phoenix, :json_library, Jason
41+
4042
config :sentry,
41-
included_environments: [:all],
4243
root_source_code_path: File.cwd!(),
4344
release: version
4445

45-
config :logger, backends: [:console, Sentry.LoggerBackend]
46-
47-
# Import environment configuration
4846
import_config "#{Mix.env()}.exs"

config/dev.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ config :elixir_boilerplate, ElixirBoilerplateWeb.Plugs.Security, allow_unsafe_sc
1919

2020
config :logger, :console, format: "[$level] $message\n"
2121

22-
config :phoenix, :stacktrace_depth, 20
2322
config :phoenix, :plug_init_mode, :runtime
23+
config :phoenix, :stacktrace_depth, 20

config/prod.exs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ config :elixir_boilerplate, ElixirBoilerplateWeb.Endpoint,
44
cache_static_manifest: "priv/static/cache_manifest.json",
55
debug_errors: false
66

7+
config :elixir_boilerplate, :logger, [
8+
{:handler, :sentry_handler, Sentry.LoggerHandler,
9+
%{
10+
config: %{
11+
metadata: [:file, :line],
12+
rate_limiting: [max_events: 10, interval: _1_second = 1_000],
13+
capture_log_messages: true,
14+
level: :error
15+
}
16+
}}
17+
]
18+
719
config :logger, :console,
820
format: "$time $metadata[$level] $message\n",
921
level: :info,

config/runtime.exs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,28 @@ import ElixirBoilerplate.Config
44
canonical_uri = get_env("CANONICAL_URL", :uri)
55
static_uri = get_env("STATIC_URL", :uri)
66

7-
config :elixir_boilerplate,
8-
canonical_host: get_uri_part(canonical_uri, :host),
9-
force_ssl: get_uri_part(canonical_uri, :scheme) == "https"
10-
117
config :elixir_boilerplate, ElixirBoilerplate.Repo,
128
url: get_env!("DATABASE_URL"),
139
ssl: get_env("DATABASE_SSL", :boolean),
1410
pool_size: get_env!("DATABASE_POOL_SIZE", :integer),
1511
socket_options: if(get_env("DATABASE_IPV6", :boolean), do: [:inet6], else: [])
1612

13+
config :elixir_boilerplate,
14+
canonical_host: get_uri_part(canonical_uri, :host),
15+
force_ssl: get_uri_part(canonical_uri, :scheme) == "https"
16+
1717
# NOTE: Only set `server` to `true` if `PHX_SERVER` is present. We cannot set
1818
# it to `false` otherwise because `mix phx.server` will stop working without it.
1919
if get_env("PHX_SERVER", :boolean) == true do
2020
config :elixir_boilerplate, ElixirBoilerplateWeb.Endpoint, server: true
2121
end
2222

23+
config :absinthe_security, AbsintheSecurity.Phase.FieldSuggestionsCheck, enable_field_suggestions: get_env("GRAPHQL_ENABLE_FIELD_SUGGESTIONS", :boolean)
24+
config :absinthe_security, AbsintheSecurity.Phase.IntrospectionCheck, enable_introspection: get_env("GRAPHQL_ENABLE_INTROSPECTION", :boolean)
25+
26+
config :elixir_boilerplate, Corsica, origins: get_env("CORS_ALLOWED_ORIGINS", :cors)
27+
config :elixir_boilerplate, ElixirBoilerplate.TelemetryUI, share_key: get_env("TELEMETRY_UI_SHARE_KEY")
28+
2329
config :elixir_boilerplate, ElixirBoilerplateWeb.Endpoint,
2430
http: [port: get_env!("PORT", :integer)],
2531
secret_key_base: get_env!("SECRET_KEY_BASE"),
@@ -29,19 +35,12 @@ config :elixir_boilerplate, ElixirBoilerplateWeb.Endpoint,
2935
url: get_endpoint_url_config(canonical_uri),
3036
static_url: get_endpoint_url_config(static_uri)
3137

32-
config :elixir_boilerplate, Corsica, origins: get_env("CORS_ALLOWED_ORIGINS", :cors)
33-
3438
config :elixir_boilerplate,
3539
basic_auth: [
3640
username: get_env("BASIC_AUTH_USERNAME"),
3741
password: get_env("BASIC_AUTH_PASSWORD")
3842
]
3943

40-
config :elixir_boilerplate, ElixirBoilerplate.TelemetryUI, share_key: get_env("TELEMETRY_UI_SHARE_KEY")
41-
4244
config :sentry,
4345
dsn: get_env("SENTRY_DSN"),
4446
environment_name: get_env("SENTRY_ENVIRONMENT_NAME")
45-
46-
config :absinthe_security, AbsintheSecurity.Phase.IntrospectionCheck, enable_introspection: get_env("GRAPHQL_ENABLE_INTROSPECTION", :boolean)
47-
config :absinthe_security, AbsintheSecurity.Phase.FieldSuggestionsCheck, enable_field_suggestions: get_env("GRAPHQL_ENABLE_FIELD_SUGGESTIONS", :boolean)

config/test.exs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ defmodule TestEnvironment do
1515
end
1616
end
1717

18+
# This config is to output keys instead of translated message in test
19+
config :elixir_boilerplate, ElixirBoilerplate.Gettext, priv: "priv/null", interpolation: ElixirBoilerplate.GettextInterpolation
20+
1821
config :elixir_boilerplate, ElixirBoilerplate.Repo,
1922
pool: Ecto.Adapters.SQL.Sandbox,
2023
url: TestEnvironment.get_database_url()
2124

2225
config :elixir_boilerplate, ElixirBoilerplateWeb.Endpoint, server: false
2326

24-
# This config is to output keys instead of translated message in test
25-
config :elixir_boilerplate, ElixirBoilerplate.Gettext, priv: "priv/null", interpolation: ElixirBoilerplate.GettextInterpolation
26-
2727
config :logger, level: :warning

0 commit comments

Comments
 (0)