Skip to content

Commit

Permalink
endpoint ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
APB9785 committed Jan 17, 2025
1 parent 2ca68dd commit 8fc8a74
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/mix/tasks/beacon.gen.proxy_endpoint.ex
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ defmodule Mix.Tasks.Beacon.Gen.ProxyEndpoint do
end

defp add_endpoint_to_application(igniter, fallback_endpoint, proxy_endpoint_module_name) do
Igniter.Project.Application.add_new_child(igniter, proxy_endpoint_module_name, after: [fallback_endpoint])
Igniter.Project.Application.add_new_child(igniter, proxy_endpoint_module_name, after: [fallback_endpoint, Beacon])
end

def add_session_options_config(igniter, otp_app, signing_salt, options) do
Expand Down
2 changes: 1 addition & 1 deletion lib/mix/tasks/beacon.gen.site.ex
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ defmodule Mix.Tasks.Beacon.Gen.Site do
defp maybe_add_new_endpoint_to_application(igniter, nil, _), do: igniter

defp maybe_add_new_endpoint_to_application(igniter, host, repo) do
Igniter.Project.Application.add_new_child(igniter, new_endpoint_module(igniter, host), after: [repo, Phoenix.PubSub, Finch])
Igniter.Project.Application.add_new_child(igniter, new_endpoint_module(igniter, host), after: [repo, Phoenix.PubSub, Finch, Beacon])
end

defp new_endpoint_module(igniter, host) do
Expand Down
15 changes: 9 additions & 6 deletions test/mix/tasks/gen_site_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -267,18 +267,21 @@ defmodule Mix.Tasks.Beacon.GenSiteTest do
test "updates runtime.exs", %{project: project} do
project
|> Igniter.compose_task("beacon.gen.site", @opts_host)
# add beacon site config
|> assert_has_patch("config/runtime.exs", """
53 + |config :test, TestWeb.ExampleEndpoint,
54 + | url: [host: "example.com", port: #{@secure_port}, scheme: "https"],
55 + | http: [ip: {0, 0, 0, 0, 0, 0, 0, 0}, port: #{@port}],
56 + | secret_key_base: secret_key_base
57 + |
2 + |config :beacon, my_site: [site: :my_site, repo: Test.Repo, endpoint: TestWeb.ExampleEndpoint, router: TestWeb.Router]
""")
# adds host to proxy endpoint allowed origins
|> assert_has_patch("config/runtime.exs", """
48 + | check_origin: [host, "example.com"],
""")
# add config for new endpoint
|> assert_has_patch("config/runtime.exs", """
2 + |config :beacon, my_site: [site: :my_site, repo: Test.Repo, endpoint: TestWeb.ExampleEndpoint, router: TestWeb.Router]
53 + |config :test, TestWeb.ExampleEndpoint,
54 + | url: [host: "example.com", port: #{@secure_port}, scheme: "https"],
55 + | http: [ip: {0, 0, 0, 0, 0, 0, 0, 0}, port: #{@port}],
56 + | secret_key_base: secret_key_base
57 + |
""")
end

Expand Down

0 comments on commit 8fc8a74

Please sign in to comment.