@@ -150,7 +150,7 @@ start_cowboy(Configuration) ->
150150 throw ({error , no_nova_app_defined });
151151 App ->
152152 ExtraApps = application :get_env (App , nova_apps , []),
153- nova_router :compile ([nova |[ App | ExtraApps ]] )
153+ nova_router :compile (resolve_nova_apps ( [nova , App | ExtraApps ], []) )
154154 end ,
155155
156156 CowboyOptions2 =
@@ -223,3 +223,21 @@ get_version(Application) ->
223223 false ->
224224 not_found
225225 end .
226+
227+ % % @doc Recursively resolve nested nova_apps.
228+ % % Each nova_app can declare its own nova_apps dependencies.
229+ % % Dependencies are resolved depth-first so child app routes
230+ % % are registered before the parent.
231+ -spec resolve_nova_apps ([atom ()], [atom ()]) -> [atom ()].
232+ resolve_nova_apps ([], Acc ) ->
233+ lists :reverse (Acc );
234+ resolve_nova_apps ([App | Rest ], Acc ) ->
235+ case lists :member (App , Acc ) of
236+ true ->
237+ % % Already resolved — skip to prevent cycles
238+ resolve_nova_apps (Rest , Acc );
239+ false ->
240+ Nested = application :get_env (App , nova_apps , []),
241+ Acc1 = resolve_nova_apps (Nested , [App | Acc ]),
242+ resolve_nova_apps (Rest , Acc1 )
243+ end .
0 commit comments