Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Umbrella project with multiple apps containing front end logic.

I have 2 applications which have shared functionality/routes. For example, in both applications there is a diary, goal tracking, sleep tracking, etc which work in the same way. There are also routes specific to each app. In AppA, a user can track their mood, and in AppB a user can view notes from their doctor.

Is there a way to have an umbrella project which contains in /apps the generic app, AppA, and AppB? Each app will have it's own router/controllers/templates etc. AppA and AppB will each require the GenericApp as a dependency. So far I have only seen umbrella projects with one app that contains the front end logic (web), with the other apps being libraries that are included in. How can this work with routing across multiple apps? Is there another approach I can take for this?

I have found this question & answer in my search, however it is not exactly what I am looking for. It seems to follow the pattern of one front end app including in other libraries.

like image 779
Katherine Avatar asked Jul 31 '17 10:07

Katherine


1 Answers

Yes, you can certainly split out the 'generic' routes into a separate umbrella app and forward to it from AppA and AppB.

Use the Phoenix.Router.forward/4 function to forward requests from AppA and AppB to the shared code.

For example, this is how the exq_ui can be incorporated into a larger application:

  pipeline :exq do
    plug :accepts, ["html"]
    plug :fetch_session
    plug :fetch_flash
    plug :put_secure_browser_headers
    plug ExqUi.RouterPlug, namespace: "exq"
  end

  scope "/exq", ExqUi do
    pipe_through :exq
    forward "/", RouterPlug.Router, :index
  end
like image 152
Mike Buhot Avatar answered Oct 22 '22 11:10

Mike Buhot