{"id":13879473,"url":"https://github.com/fnando/enroute","last_synced_at":"2025-04-17T00:51:58.603Z","repository":{"id":43046447,"uuid":"240404851","full_name":"fnando/enroute","owner":"fnando","description":"Generates a TypeScript file that defines all named routes from Rails as helper functions.","archived":false,"fork":false,"pushed_at":"2024-02-08T22:55:56.000Z","size":121,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-11T22:38:56.417Z","etag":null,"topics":["rails","rails-routes","routes","typescript"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fnando.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["fnando"],"custom":["https://paypal.me/fnando/🍕"]}},"created_at":"2020-02-14T01:36:49.000Z","updated_at":"2024-05-27T05:05:25.000Z","dependencies_parsed_at":"2024-01-13T20:57:17.804Z","dependency_job_id":"4b80eff6-811f-4961-949a-6e05b4177195","html_url":"https://github.com/fnando/enroute","commit_stats":{"total_commits":29,"total_committers":2,"mean_commits":14.5,"dds":"0.31034482758620685","last_synced_commit":"a4b51eeb4d927f90bed749e55c0c51d48de9bfe0"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Fenroute","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Fenroute/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Fenroute/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Fenroute/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fnando","download_url":"https://codeload.github.com/fnando/enroute/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249294934,"owners_count":21246011,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rails","rails-routes","routes","typescript"],"created_at":"2024-08-06T08:02:22.164Z","updated_at":"2025-04-17T00:51:58.585Z","avatar_url":"https://github.com/fnando.png","language":"Ruby","funding_links":["https://github.com/sponsors/fnando","https://paypal.me/fnando/🍕"],"categories":["Ruby"],"sub_categories":[],"readme":"# Enroute\n\nGenerates a TypeScript file that defines all named routes from Rails as helper\nfunctions.\n\n[![Tests](https://github.com/fnando/enroute/workflows/tests/badge.svg)](https://github.com/fnando/enroute)\n[![Gem](https://img.shields.io/gem/v/enroute.svg)](https://rubygems.org/gems/enroute)\n[![Gem](https://img.shields.io/gem/dt/enroute.svg)](https://rubygems.org/gems/enroute)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem \"enroute\"\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install enroute\n\n## Usage\n\nAll you have to do is call the `enroute` binary with the main file you want to\nload and a output path.\n\n```console\n$ bundle exec enroute export --output ./app/frontend/scripts/config/routes.ts\n```\n\nBy default, `\u003cpwd\u003e/config/environment.rb` will be loaded. If you want to use a\ndifferent file, use the `--require` switch.\n\n```console\n$ bundle exec enroute export --require ./different-file.rb --output ./routes.ts\n```\n\nYou can also ignore routes by using a config file.\n\n```console\n$ bundle exec enroute export --output ./app/frontend/scripts/config/routes.ts --config ./config/enroute.yml\n```\n\nThe config file must look like this:\n\n```yaml\n---\nignore:\n  - route_name\n```\n\nThere's also a `:only` option that will include only the matching named routes.\n\n```yaml\n---\nonly:\n  - route_name\n```\n\nBy default, route params will be typed as `any`. To add a custom typing\nannotation, you can use the `typings` key on the configuration file. Imagine you\nhave the route `get \"settings/edit(/:section)\" =\u003e \"\", as: \"edit_settings\"`; you\ncan have a config file like this:\n\n```yaml\n---\ntypings:\n  _default:\n    format: '\"html\" | \"json\"'\n\n  edit_settings:\n    section: string\n```\n\n### Importing helpers on TypeScript\n\nYou can then import any route that's been exported. Parameters are positional.\n\n```typescript\nimport { userUrl } from \"./routes\";\n\nuserUrl({ id: 1234 });\n//=\u003e \"/users/1234\"\n\nuserUrl({ id: 1234, format: \"json\" });\n//=\u003e \"/users/1234.json\"\n```\n\nYou can also have routes with optional segments. For instance, imagine you have\ndefine the route `get \"settings/edit(/:section)\" =\u003e \"\", as: \"edit_settings\"`.\nYou could then use the helper `editSettingsUrl()` like this:\n\n```typescript\nimport { editSettingsUrl } from \"./routes\";\n\neditSettingsUrl();\n//=\u003e \"/settings/edit\"\n\neditSettingsUrl({ section: \"security\" });\n//=\u003e \"/settings/edit/security\"\n```\n\nAll helpers are typed accordingly to the route definition. For convenience, you\nmay pass any primitives as a url parameter, which will then be converted into\nstring.\n\nAn exception will be raised if you forget to provide a required parameter; empty\nstrings, `null` and `undefined` will be rejected, but `false` is accepted.\n\n```typescript\nimport { userUrl } from \"./routes\";\n\nuserUrl();\n//=\u003e raises `id is required, but received undefined`\n```\n\n## Maintainer\n\n- [Nando Vieira](https://github.com/fnando)\n\n## Contributors\n\n- https://github.com/fnando/enroute/contributors\n\n## Contributing\n\nFor more details about how to contribute, please read\nhttps://github.com/fnando/enroute/blob/main/CONTRIBUTING.md.\n\n## License\n\nThe gem is available as open source under the terms of the\n[MIT License](https://opensource.org/licenses/MIT). A copy of the license can be\nfound at https://github.com/fnando/enroute/blob/main/LICENSE.md.\n\n## Code of Conduct\n\nEveryone interacting in the enroute project's codebases, issue trackers, chat\nrooms and mailing lists is expected to follow the\n[code of conduct](https://github.com/fnando/enroute/blob/main/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnando%2Fenroute","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffnando%2Fenroute","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnando%2Fenroute/lists"}