Skip to content

Commit

Permalink
Support embedded test_api
Browse files Browse the repository at this point in the history
  • Loading branch information
nallwhy committed Jun 12, 2022
1 parent 44848b0 commit e49b88e
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 3 deletions.
6 changes: 6 additions & 0 deletions apps/json_corp_web/lib/json_corp_web/endpoint.ex
Expand Up @@ -22,6 +22,12 @@ defmodule JsonCorpWeb.Endpoint do
gzip: false,
only: ~w(assets fonts images favicon.ico robots.txt)

plug Plug.Static,
at: "/test_api",
from: {:json_corp_web, "priv/static/test_api"},
gzip: false,
only: ~w(assets fonts images favicon.ico robots.txt)

# Code reloading can be explicitly enabled under the
# :code_reloader configuration of your endpoint.
if code_reloading? do
Expand Down
2 changes: 1 addition & 1 deletion apps/json_corp_web/mix.exs
Expand Up @@ -62,7 +62,7 @@ defmodule JsonCorpWeb.MixProject do
[
setup: ["deps.get"],
test: ["ecto.create --quiet", "ecto.migrate --quiet", "test"],
"assets.deploy": ["esbuild default --minify", "phx.digest"]
"assets.deploy": ["esbuild default --minify", "esbuild test_api --minify", "phx.digest"]
]
end
end
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions config/config.exs
Expand Up @@ -57,3 +57,5 @@ config :phoenix, :json_library, Jason
# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{config_env()}.exs"

import_config "./test_api/config.exs"
3 changes: 2 additions & 1 deletion config/dev.exs
Expand Up @@ -25,7 +25,8 @@ config :json_corp_web, JsonCorpWeb.Endpoint,
secret_key_base: "jEJVnRRjK7KAdp/PZdOHxAl1mbjg3ovmIoUXGSau53IloeOccUFToPRhXYFMpd3y",
watchers: [
# Start the esbuild watcher by calling Esbuild.install_and_run(:default, args)
esbuild: {Esbuild, :install_and_run, [:default, ~w(--sourcemap=inline --watch)]}
esbuild: {Esbuild, :install_and_run, [:default, ~w(--sourcemap=inline --watch)]},
esbuild: {Esbuild, :install_and_run, [:test_api, ~w(--sourcemap=inline --watch)]}
]

# ## SSL Support
Expand Down
17 changes: 17 additions & 0 deletions config/test_api/config.exs
@@ -0,0 +1,17 @@
import Config

# Configures the endpoint
config :test_api, TestApiWeb.Endpoint,
url: [host: "localhost", path: "/test_api"],
render_errors: [view: TestApiWeb.ErrorView, accepts: ~w(html json), layout: false],
pubsub_server: TestApi.PubSub

# Configure esbuild (the version is required)
config :esbuild,
version: "0.14.0",
test_api: [
args:
~w(../../../deps/test_api/assets/js/app.js --bundle --target=es2017 --outdir=../priv/static/test_api/assets),
cd: Path.expand("../../apps/json_corp_web/assets", __DIR__),
env: %{"NODE_PATH" => Path.expand("../../deps", __DIR__)}
]
2 changes: 1 addition & 1 deletion mix.lock
Expand Up @@ -32,6 +32,6 @@
"telemetry": {:hex, :telemetry, "1.1.0", "a589817034a27eab11144ad24d5c0f9fab1f58173274b1e9bae7074af9cbee51", [:rebar3], [], "hexpm", "b727b2a1f75614774cff2d7565b64d0dfa5bd52ba517f16543e6fc7efcc0df48"},
"telemetry_metrics": {:hex, :telemetry_metrics, "0.6.1", "315d9163a1d4660aedc3fee73f33f1d355dcc76c5c3ab3d59e76e3edf80eef1f", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7be9e0871c41732c233be71e4be11b96e56177bf15dde64a8ac9ce72ac9834c6"},
"telemetry_poller": {:hex, :telemetry_poller, "1.0.0", "db91bb424e07f2bb6e73926fcafbfcbcb295f0193e0a00e825e589a0a47e8453", [:rebar3], [{:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "b3a24eafd66c3f42da30fc3ca7dda1e9d546c12250a2d60d7b81d264fbec4f6e"},
"test_api": {:git, "https://github.com/nallwhy/test_api.git", "4fb42a767756a945fed54d23f92926823f0dfa3a", []},
"test_api": {:git, "https://github.com/nallwhy/test_api.git", "06041197b2f0295a2cec3a6305c13797743bd544", []},
"timeout": {:git, "https://github.com/nallwhy/timeout.git", "64846583674617a8290b61d06025ec69f66456b9", []},
}

0 comments on commit e49b88e

Please sign in to comment.