Skip to content

feat: support {App, Path} tuples in static routes#378

Open
Taure wants to merge 3 commits intomasterfrom
feat/priv-dir-routes
Open

feat: support {App, Path} tuples in static routes#378
Taure wants to merge 3 commits intomasterfrom
feat/priv-dir-routes

Conversation

@Taure
Copy link
Collaborator

@Taure Taure commented Mar 20, 2026

Summary

  • Support {App, Path} tuples in static routes to serve files from any dependency's priv directory
  • Enables libraries like arizona_core to serve their own JS/CSS assets without copying files

Usage

routes(_Env) ->
    [#{prefix => "", routes => [
        %% Serve app's own static assets (existing behaviour)
        {"/assets/[...]", "static/assets"},
        %% Serve arizona_core's JS/CSS from its priv dir
        {"/arizona/[...]", {arizona_core, "static/assets"}}
    ]}].

Why

Currently Nova's static routes only resolve files from the current application's priv directory. This forces libraries to require users to copy assets into their app's priv. Phoenix/LiveView solves this by allowing deps to serve from their own priv — this brings the same capability to Nova.

The immediate use case is arizona_core serving arizona.min.js directly, but it works for any dependency that ships static assets.

Implementation

One new parse_url clause matching {RemotePath, {DepApp, LocalPath}}. Resolves via code:priv_dir(DepApp) and creates the appropriate nova_file_controller handler — same mechanism as existing string-based static routes.

Test plan

  • All 347 existing tests pass
  • Manual test with arizona_core serving JS via {arizona_core, "static/assets"}

@Taure Taure requested a review from burbas March 20, 2026 05:51
Allows serving static files from any dependency's priv directory
using a simple two-tuple: {AppName, "path/in/priv"}.

Usage in router:
  {"/arizona/[...]", {arizona_core, "static/assets"}}
  {"/assets/[...]", "static/assets"}
@Taure Taure force-pushed the feat/priv-dir-routes branch from 37779cf to 42628a8 Compare March 20, 2026 05:53
@Taure Taure changed the title feat: support {priv_dir, App, Path} in static routes feat: support {App, Path} tuples in static routes Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant