Skip to content
CAI
Software that uses CAICheck a score

railsware/js-routes

57.1

Adequate · 6 November 2026

1.9k

lines of production code

Ruby

with TypeScript, JavaScript

4

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

This system is a Ruby gem that generates JavaScript route helpers from Rails routing definitions, enabling frontend applications to construct URLs and paths dynamically. It supports modern JavaScript module systems (ESM, CJS, AMD, UMD) and provides TypeScript type definitions for static type checking. The library includes tools for automatic route regeneration via Rack middleware and generators, ensuring synchronization between backend routes and frontend code.

How it got here

2011 — TypeScript migration and tooling modernization

7 changes.

The project underwent a comprehensive migration of its JavaScript source base to TypeScript, introducing a new Router class with strict static typing via Sorbet. This effort was accompanied by a modernization of the build toolchain, including a switch to Yarn 4, updated ESLint and Prettier configurations, and refactored test helpers. The release consolidated previous workflows into single commands and added support for modern module systems and development middleware.

2012–2024 — Type safety and middleware integration

11 changes.

This period focused on enhancing type safety through Sorbet configuration and comprehensive TypeScript definitions for generated route helpers. It also introduced a Rack middleware and generator system to automatically synchronize JavaScript routes with Rails, alongside expanded CI support for modern Rails versions.

Features

Add Webpacker and JsRoutes initializer templates

The library now provides generator templates for integrating with Webpacker and configuring JsRoutes. A new \erb.js\ template configures Webpacker to use \rails-erb-loader\ for processing ERB files. An \initializer.rb\ template is added to configure JsRoutes, including a new \include\_undefined\_query\_parameters\ flag (defaulting to false) to control how undefined query parameters are handled, alongside options for module types, naming conventions, and URL generation. A \routes.js.erb\ template is also included to generate the JavaScript route helpers.

lib/templates · high confidence

Add js-routes asset with UTF-8 encoding

A new JavaScript asset file, js-routes.js.erb, has been added to the app/assets/javascripts directory. This file generates JavaScript routes using the JsRoutes library and explicitly declares UTF-8 encoding to ensure correct character handling.

app/assets · high confidence

Initial Sorbet type-checking configuration

Added configuration files to enable Sorbet static type checking for the codebase. The setup includes a main config file to define the source directory and ignore paths (tmp, vendor), a Tapioca configuration for gem DSL generation, and a require file to manage type definitions.

sorbet · high confidence

Introduce rack middleware and generator for automatic route updates

The library now supports a rack middleware approach to keep JavaScript routes in sync with Rails routes automatically. A new generator (\rails generate js\_routes:middleware\) sets up this middleware, configures the Rakefile to regenerate routes before JavaScript bundling (preferring \javascript:build\ over \assets:precompile\ when \jsbundling-rails\ is present), and injects the necessary configuration into environment files. The generator also intelligently locates the main application JavaScript file (supporting both \.js\ and \.ts\ extensions in \packs\ or \controllers\ directories) to inject a sample import, and updates \.gitignore\ to exclude generated route files. A separate Webpacker-specific generator is also added for legacy setups.

_lib/js\routes/generators · high confidence

Behavioural changes

Configurable query parameter serialization and new package generation methods

Users can now explicitly control how undefined or nil query parameters are serialized in generated route helpers via the new \include\_undefined\_query\_parameters\ configuration flag, which defaults to false in future releases (currently warns if unset). Additionally, the library introduces \JsRoutes.package!\ and \JsRoutes.remove!\ methods to support dedicated package generation (when \module\type: 'PKG'\) and cleanup of generated route files, alongside improved handling of Rails 8.0+ route reloading and ESM tree-shaking via \\#\\PURE\\_\ comments.

js-routes · high confidence

Deprecate js:routes:typescript task in favor of js:routes

The \js:routes:typescript\ rake task is now deprecated and issues a warning directing users to use the \js:routes\ task instead. The \js:routes\ task generates JavaScript files with Rails route URL helpers and includes TypeScript definitions by default (via the \typed: true\ option), consolidating the previous two-step process into a single command.

lib/tasks · high confidence

JsRoutes v2.4.1: Sorbet typing, modern module support, and Rack middleware

This release introduces Sorbet static typing across the library (configuration, engine, middleware, types, and utils) to improve code reliability. It adds support for modern JavaScript module types (ESM and DTS) via a new \module\_type\ configuration option and allows splitting output into a router and routes file using the \PKG\ module type. A new Rack middleware is included to automatically regenerate the JavaScript routes file on every request when \routes.rb\ changes, ensuring development accuracy. The configuration also gains options for \include\_undefined\_query\_parameters\, \optional\_definition\_params\, and customizable banners, while deprecating the \prefix\ option in favor of \default\_url\_options.script\_name\.

_lib/js\routes · high confidence

Migrate JavaScript route generation to TypeScript with a new Router class

The library's JavaScript source base has been rewritten in TypeScript, introducing a new \Router\ class that handles route generation and serialization at the instance level. This change brings strict static typing via Sorbet and new TypeScript definition files (\router.d.ts\, \routes.d.ts\) to improve developer experience. The refactoring also updates the module system to default to ESM, adds support for \bigint\ route parameters, and implements a new \PKG\ module type for bundling the router instance directly.

lib · high confidence

Test coverage

Added TypeScript type definitions and tests for the DTS module; Added test coverage for all supported JavaScript module types; Added test coverage for serialization, options, and Rails compatibility; Added test fixtures for dummy application assets and routing; Added test support routes for engine and application routing scenarios; Added tests for JsRoutes generator middleware source root; Refactor test suite with TypeScript support and modernized helpers.

Dependencies

Expanded CI support for Rails 5.0–8.1 with Sprockets 3 and 4

The gemfile set has been updated to include new Appraisal configurations for Rails 5.0, 5.1, 5.2, 7.0, 8.0, and 8.1, enabling continuous integration testing across these versions. The configurations pair older Rails versions (5.x) with Sprockets 3 and newer versions (7.x, 8.x) with Sprockets 4, ensuring the library remains compatible with the full range of supported Rails and asset pipeline versions.

gemfiles · high confidence

Migrate to Yarn 4 and modernize TypeScript tooling

The project has migrated its package manager to Yarn 4 (configured via .yarnrc.yml) and replaced the legacy .eslintrc.js with the modern flat eslint.config.js. TypeScript compilation is now governed by a new tsconfig.json targeting ES2020 modules, and the Rakefile has been updated to use Appraisals for testing across multiple Rails versions. Legacy build artifacts and configuration files (Jeweler, RDoc, .rspec, README.rdoc) have been removed.

(repo-wide) · high confidence

Update Ruby and JavaScript dependency requirements

The project updates its dependency constraints: the Ruby gem now requires Ruby \>= 2.7 and Rails railties \>= 5, while the JavaScript tooling upgrades to ESLint 10, Prettier 3, and TypeScript 6, with the lockfile regenerated for Yarn 4.

(dependencies) · high confidence

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 50 → 57 (+7.2)
  • Rubric changed (rubric-2026.10.5 → rubric-2026.11.2) — scores are not directly comparable.

Lenses

  • Code Health 58 → 58 (+0.0)
  • Architecture 97 → 97 (+0.0)
  • Maturity 34 → 51 (+16.8)
  • Readiness 58 → 58 (+0.0)
  • Security 76 → 67 (-9.7)

Resolved (4)

  • Duplicate intent. JsRoutes.setup and Configuration.setup appear to perform the same configuration initialization task. Users may be confused about whether they should configure via the main JsRoutes module or the Configuration class directly.
  • Inconsistent naming and arity for generation operations. JsRoutes exposes both generate (no file output implied) and generate! (explicit file output), while Instance exposes generate and generate!. The distinction between the '!' and non-'!' variants is not immediately obvious from the signature alone (one takes a filename, the other doesn't), and the existence of two parallel entry points (JsRoutes singleton vs Instance) with similar but distinct method names creates confusion about which API surface to use.
  • Off-boarding risk: anonymized user #1
  • Same inconsistency as generate: package and package! are used in both JsRoutes and Instance with inconsistent signatures (one takes a filename, the other does not). This duplicates the confusion found in the generation methods.

New (2)

  • Medium CVE: [GHSA redacted] (yarn.lock)
  • Off-boarding risk: anonymized user #1

Architecture

  • Unchanged — 0 containers · 1 contexts · 0 edges

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

railsware/js-routes was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 6 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 1e1fa2890144422187a9ffba11d062db6737faec — the exact code this score is about.
  • Scored under rubric-2026.11.2 — the same rubric and the same method as every other entry in this index.
  • Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.2+preprod-5c4e66d9318b.