• Stars
    star
    86
  • Rank 368,574 (Top 8 %)
  • Language
    Ruby
  • License
    MIT License
  • Created almost 4 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ›ฃ๏ธ Generate path helpers and API methods from your Rails routes


Build Status Maintainability Test Coverage Gem Version License

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.

Why? ๐Ÿค”

Path helpers in Rails make it easy to build URLs, while avoiding typos and mistakes.

With JS From Routes, it's possible the enjoy the same benefits in JS, and even more if using TypeScript.

Read more about it in the blog announcement.

Features โšก๏ธ

  • ๐Ÿš€ Path and Request Helpers
  • ๐Ÿ” Serialization / Deserialization
  • โœ… Prevent Routing Errors
  • ๐Ÿค– Automatic Generation
  • ๐Ÿ›  Customizable Generation
  • And more!

Documentation ๐Ÿ“–

Visit the documentation website to check out the guides and searchable configuration reference.

Installation ๐Ÿ’ฟ

For a one liner, you can use this template:

rails app:template LOCATION='https://railsbytes.com/script/X6ksgn'

Else, add this line to your application's Gemfile in the development group and execute bundle:

group :development, :test do
  gem 'js_from_routes'
end

Then, add the client library to your package.json:

npm install @js-from-routes/client # yarn add @js-from-routes/client

There are more client libraries available.

Getting Started ๐Ÿš€

The following is a short excerpt from the guide.

Specify the routes you want

Use the export attribute to determine which routes should be taken into account when generating JS.

Rails.application.routes.draw do
  resources :video_clips, export: true do
    get :download, on: :member
  end
end

Use the path helpers in your JS application

Path helpers will be automatically generated when refreshing the page.

import { videoClips } from '~/api'

const video = await videoClips.get({ id: 'oHg5SJYRHA0' })

const downloadPath = videoClips.download.path(video)

Check the documentation website for more information.

For a working example, check this repo.

More Repositories

1

vite_ruby

โšก๏ธ Vite.js in Ruby, bringing joy to your JavaScript experience
Ruby
1,124
star
2

iles

๐Ÿ The joyful site generator
TypeScript
1,043
star
3

vite-plugin-image-presets

๐Ÿ–ผ Image Presets for Vite.js apps
TypeScript
243
star
4

vite-plugin-environment

Easily expose environment variables in Vite.js
TypeScript
132
star
5

vite-plugin-full-reload

โ™ป๏ธ Automatically reload the page when files are modified
JavaScript
121
star
6

oj_serializers

โšก๏ธ Faster JSON serialization for Ruby on Rails. Easily migrate away from Active Model Serializers.
Ruby
98
star
7

request_store_rails

๐Ÿ“ฆ Per-request global storage for Rails prepared for multi-threaded apps
Ruby
83
star
8

types_from_serializers

โœ… Generate TypeScript interfaces from your JSON serializers
Ruby
71
star
9

vuex-stores

๐Ÿ—„ Store objects for Vuex, a simple and more fluid API for state-management.
JavaScript
63
star
10

vue-custom-element-example

An example on how to define custom elements using Vue 3
TypeScript
54
star
11

mongoid_includes

๐ŸŒฟ Improves eager loading support for Mongoid
Ruby
46
star
12

jekyll-vite

โšก๏ธ๐Ÿฉธ Use Vite.js in Jekyll as your assets pipeline
Ruby
44
star
13

queryable

โ” Gives your queries a home and avoid tucking scopes inside your models
Ruby
42
star
14

vite-plugin-stimulus-hmr

โšก๏ธ HMR for Stimulus controllers in Vite.js
TypeScript
42
star
15

stimulus-vite-helpers

Helpers to easily load all your Stimulus controllers when using Vite.js
TypeScript
37
star
16

capybara-compose

โœ… Easily write fluent integration tests with Capybara in Ruby
Ruby
31
star
17

better_settings

โš™ Settings for Ruby apps โ€“ fast, immutable, better.
Ruby
20
star
18

vite-plugin-bugsnag

Report builds and upload source maps to Bugsnag
TypeScript
18
star
19

i18n_multitenant

๐ŸŒŽ Provides a convenient way to use tenant-specific translations
Ruby
16
star
20

vite-plugin-manifest-sri

Subresource Integrity for Vite.js manifest files
JavaScript
13
star
21

resourcerer

โœจ Works like magic to dry up your controllers
Ruby
10
star
22

sublime-toggle-dark-mode

๐ŸŒš๐ŸŒž Toggle between dark and light mode in Sublime Text 4
JavaScript
9
star
23

pakiderm

๐Ÿ˜ Pakiderm will never forget the return value
Ruby
7
star
24

presenter_rails

๐Ÿ”ญ Expose your view models in a convenient way
Ruby
6
star
25

vite-plugin-erb

Use ERB files in Vite.js projects with a Ruby backend
TypeScript
5
star
26

journeyman

Let your factories use your business logic, making them flexible and easier to update.
Ruby
5
star
27

jekyll-vite-minima

โšก๏ธ๐Ÿฉธ Use Vite.js in Jekyll minima theme as your assets pipeline
Ruby
3
star
28

automatic-music-transcription

Automatically exported from code.google.com
C
2
star
29

vite-plugin-xdm

Use XDM in VIte.js
JavaScript
2
star
30

crouton

๐Ÿž Context sensitive notifications for Rails
Ruby
1
star
31

fast-food-mvc

Automatically exported from code.google.com
C#
1
star
32

ElMassimo

1
star
33

vite-vue-router-hmr-repro

Vue
1
star