Skip to content
CAI
Software that uses CAICheck a score

railsware/js-routes

59.2

Adequate · 19 September 2026

1.9k

lines of production code

Ruby

with TypeScript, JavaScript

1

measurement over time

CAI band scale
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 watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Baseline

  • First survey — no prior run to compare against. CAI 59.

Lenses

  • Code Health 58
  • Architecture 96
  • Maturity 55
  • Readiness 56
  • Security 76

Changes since last survey

  • 300 commits — 251 feature/other, 49 fixes

By area

  • (root) — 107 commits
  • lib/js_routes — 63 commits
  • spec/js_routes — 42 commits
  • (repo) — 32 commits
  • .github/workflows — 26 commits
  • lib/js_routes.rb — 8 commits
  • lib/routes.js — 8 commits
  • lib/routes.d.ts — 5 commits
  • lib/templates — 3 commits
  • lib/tasks — 2 commits
  • sorbet/rbi — 2 commits
  • spec/spec_helper.rb — 1 commit
  • spec/support — 1 commit

Notable commits

  • fix: Add pkg_spec.rb and fix duplicate route export bug
  • fix: Allow namespace option only if module_type is nil. Fixes #281.
  • fix: Fix #323 regression. Configure application inline without proc
  • fix: Fix 404 links in CHANGELOG.md
  • fix: Fix NIL mobule type when no namespace is specified. #292
  • fix: Fix NoMethodError when run js:routes:typescript (#327)
  • fix: Fix bugs
  • fix: Fix build
  • fix: Fix build for rails 7
  • fix: Fix cache poisoning vulnerability by replacing pull_request_target with pull_request
  • fix: Fix camelCase DTS definitions for optional parameters
  • fix: Fix changelog extraction breaking on ### subheadings
  • fix: Fix custom file path #295
  • fix: Fix empty object linter warning on DTS module
  • fix: Fix gemfiles path in workflows
  • fix: Fix generate! with typed: true raising when package: option is set
  • fix: Fix implicit any type in DTS serializer test callback
  • fix: Fix linter warning
  • fix: Fix linter warning on dts module
  • fix: Fix list order
  • …and 280 more

Architecture

  • 0 containers · 1 bounded contexts · 0 dependency edges (baseline)

Written by watchdog.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 19 September 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.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-13a154b7f5d1.