Generates path helpers and API requests automatically from your Rails routes
Used 162 times
M
Maximo Mussini
Usage
JS from Routes generates path helpers and API methods from your Rails routes, allowing you to be more productive and prevent routing-related errors.
Since code generation is fully customizable it can be used in very diverse scenarios.
Features ⚡️
🚀 Productive
No need to specify the URL, just use the controller and action name, preventing mistakes and saving development time.
Features ⚡️
🚀 Productive
No need to specify the URL, just use the controller and action name, preventing mistakes and saving development time.
🎩 Elegant
JSON serialization/deserialization works out of the box, but you can easily opt-out by choosing a different response type.
✅ Safe
If an action is renamed or removed, it can be detected by static analysis or the TypeScript compiler.
Path helpers are fully typed, and client libraries are entirely written in TypeScript.
🛠 Customizable
Run this command in your Rails app directory in the terminal:
rails app:template LOCATION="https://railsbytes.com/script/X6ksgn"
Template Source
Review the code before running this template on your machine.
run "spring stop"
gem_group :development do
gem "js_from_routes"
end
Bundler.with_unbundled_env { run "bundle install" }
run "CI=true npx --package @antfu/ni -- ni @js-from-routes/client"
run "echo 'Visit https://github.com/ElMassimo/js_from_routes for more info'"