Skip to content

fix(installer): default rpc routes to /rpc/run and /rpc/validate - #109

Closed
sfelixalejandro wants to merge 1 commit into
ash-project:mainfrom
sfelixalejandro:fix/igniter-rpc-routes
Closed

sfelixalejandro wants to merge 1 commit into
ash-project:mainfrom
sfelixalejandro:fix/igniter-rpc-routes

Conversation

@sfelixalejandro

Copy link
Copy Markdown

Contributor Checklist

[✓] Did you add tests for your changes?
[✓] Did you update any relevant documentation?

Description

Closes #95.

When installing ash_typescript with Igniter (mix igniter.install ash_typescript), add_rpc_routes/2 previously read run_endpoint and validate_endpoint via Application.get_env(:ash_typescript, ...) before configuration was loaded into the runtime application env. This evaluated to nil and generated invalid empty route paths in the Phoenix router:

post "", AshTypescriptRpcController, :run
post "", AshTypescriptRpcController, :validate

This PR:

  • Safely defaults run_endpoint to "/rpc/run" and validate_endpoint to "/rpc/validate" when not explicitly set or configured as a string.
  • Adds a unit test in test/mix_tasks/install_test.exs verifying that valid RPC routes are appended to Phoenix routers and empty route paths are refuted.

When installing with Igniter, Application.get_env returns nil for run_endpoint
and validate_endpoint because configuration has not been loaded into the application
env yet, causing empty route paths (post "") to be generated in Phoenix routers.

Closes ash-project#95
@sfelixalejandro

Copy link
Copy Markdown
Author

Closing in favor of #102 which is already addressing this issue.

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.

Igniter installation of ash_typescript always creates invalid routes

1 participant