{"id":19016982,"url":"https://github.com/alchaplinsky/routejs","last_synced_at":"2025-12-12T04:32:13.494Z","repository":{"id":18082735,"uuid":"21146605","full_name":"alchaplinsky/RouteJS","owner":"alchaplinsky","description":"JavaScript routing for non-SPA applications","archived":false,"fork":false,"pushed_at":"2014-06-26T20:09:35.000Z","size":168,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-14T05:04:00.662Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"CoffeeScript","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/alchaplinsky.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-24T00:09:59.000Z","updated_at":"2016-06-27T22:13:31.000Z","dependencies_parsed_at":"2022-09-19T02:11:55.892Z","dependency_job_id":null,"html_url":"https://github.com/alchaplinsky/RouteJS","commit_stats":null,"previous_names":["alchapone/routejs"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/alchaplinsky/RouteJS","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alchaplinsky%2FRouteJS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alchaplinsky%2FRouteJS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alchaplinsky%2FRouteJS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alchaplinsky%2FRouteJS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alchaplinsky","download_url":"https://codeload.github.com/alchaplinsky/RouteJS/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alchaplinsky%2FRouteJS/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259763077,"owners_count":22907408,"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":[],"created_at":"2024-11-08T19:45:25.971Z","updated_at":"2025-12-12T04:32:13.398Z","avatar_url":"https://github.com/alchaplinsky.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## RouteJS\n\nRouteJS is a lightweight JavaScript library - router for non-SPA applications.\n\nWhile working on rich client side (not a Single Page Application) web application, it is sometimes necessary to run different\nbits of javascript code (like instantiating object, passing params to it and call some method)\non different pages. Where is the right place to do it?\n\nView doesn't seem to be the right place even though it is easy to drom `\u003cscript\u003e`\ntag at the bottom of the file with three lines of javascript. It is easy to run into problems\nwith mangled bu assets pipeline javascript names wich are not modified in views. Besides that\nit is really convenient to have all javascript initialization for various pages in one place.\n\nThat's why using JavaScript router similar will help to define what should be run and when.\n\n  - It is placed in javascript code so it will be compiled/minified with whole javascript code.\n  - It gathers all initializations in a single place, so you don't need to search for code through all views.\n  - It uses URL path to determine state of your applications - exactly what URL was designed for.\n\n\n## Usage\n\nDefining handler callbacks inline while define routes.\n```\nrouter = new RouteJS()\nrouter.map (match, done)-\u003e\n  match('/page/:slug').to (params) -\u003e\n    # Do whatever you need on this page. params.slug is available\n\n  match('/country/:country_id/city/:id').to (params) -\u003e\n    # Do whatever you need on this page. params.country_id, params.id are available\n\n  done()\n```\n\nPre-defined object with handler callbacks, to simplify routes description.\n```\nhandlers =\n  findPage: (params) -\u003e\n    ....\n  findCity: (params) -\u003e\n    ....\n\nrouter = new RouteJS(handlers)\nrouter.map (match, done)-\u003e\n  match('/page/:slug').to('findPage')\n  match('/country/:country_id/city/:id').to('findCity')\n  done()\n```\n\n## ALL routes before and after callbacks\n\nThere may be situations when you want to run some javascript on each page, before or after route is triggered. You can simply do it like this:\n\n```\n  router = new RouteJS()\n  router.before -\u003e\n    # Run before all routes\n\n  router.after -\u003e\n    # Run after all routes\n\n  router.map (match, done) -\u003e\n    ..........\n    done()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falchaplinsky%2Froutejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falchaplinsky%2Froutejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falchaplinsky%2Froutejs/lists"}