{"id":20093030,"url":"https://github.com/jojobyte/theway","last_synced_at":"2026-02-03T06:02:22.542Z","repository":{"id":256929624,"uuid":"853109054","full_name":"jojobyte/theway","owner":"jojobyte","description":"A tiny (zero dependency) isomorphic router for browsers \u0026 servers.","archived":false,"fork":false,"pushed_at":"2024-12-04T13:52:14.000Z","size":43,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-03T00:30:04.257Z","etag":null,"topics":["backend","browser","frontend","isomorphic","isomorphic-javascript","router","server","vanilla","vanilla-js","zero-dependencies","zero-dependency"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jojobyte.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-06T02:28:46.000Z","updated_at":"2025-10-26T18:11:17.000Z","dependencies_parsed_at":"2024-12-04T14:30:42.986Z","dependency_job_id":"b0d792d7-e6e4-439c-bbee-8ae71cb4e41f","html_url":"https://github.com/jojobyte/theway","commit_stats":null,"previous_names":["jojobyte/theway"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/jojobyte/theway","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jojobyte%2Ftheway","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jojobyte%2Ftheway/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jojobyte%2Ftheway/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jojobyte%2Ftheway/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jojobyte","download_url":"https://codeload.github.com/jojobyte/theway/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jojobyte%2Ftheway/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29035241,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-03T02:28:16.591Z","status":"ssl_error","status_checked_at":"2026-02-03T02:27:48.904Z","response_time":96,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["backend","browser","frontend","isomorphic","isomorphic-javascript","router","server","vanilla","vanilla-js","zero-dependencies","zero-dependency"],"created_at":"2024-11-13T16:45:36.030Z","updated_at":"2026-02-03T06:02:22.526Z","avatar_url":"https://github.com/jojobyte.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The Way\n\nA tiny (zero dependency) isomorphic router for browsers \u0026 servers.\n\n- History \u0026 Hash based routing for browser\n- Server-side (express style) routing (req,res,next) \u0026 middleware\n- Simple Static file server\n- Support for layouts\n\n### Install\n```sh\nnpm install theway\n```\n\n### Usage\n```js\n// app.js\nimport Way from 'theway'\nimport {\n  loadRoute,\n} from 'theway/utils.js'\n\nconst router = new Way('/');\n\nexport const createApp = (entrypoint, routeBase) =\u003e router\n  .use(\"/\", loadRoute('/path/to/route/home.js', 'home'))\n  .use(\n    \"/about\",\n    loadRoute('/path/to/route/about.js', 'about'),\n  )\n  .use(\n    \"/thing/*?\",\n    loadRoute('/path/to/route/thing.js', 'thing'),\n  )\n  .use(\n    \"/compare/:crypto?/:fiat?\",\n    loadRoute('/path/to/route/compare.js', 'compare'),\n  )\n\nexport default createApp\n```\n\n```js\n// main.js - browser\nimport createApp from './app.js'\n\nlet app = createApp(\n  document.querySelector('#app')\n)\n\napp.listen();\n```\n\n```js\n// server.js\nimport http from 'node:http'\nimport { readFileSync } from 'node:fs'\nimport { readFile, writeFile } from 'node:fs/promises'\nimport { join, extname } from 'node:path'\n\nimport createApp from './app.js'\n\nimport {\n  DOMFaker,\n  serveStaticFiles,\n} from 'theway/server.js'\n\nconst BASE = /\u003cbase href=\"([\\s\\S]+?)\" \\/\u003e/ig\nconst routeBase = import.meta?.dirname + '/routes/'\nconst theWaySrcDir = join(import.meta.dirname, '../../')\nconst entryPage = readFileSync('./index.html', 'utf8').replace(BASE, '')\nconst fakeDOM = DOMFaker(`\u003cmain id=\"app\"\u003e\u003c/main\u003e`, entryPage)\n\nconst httpServer = http.createServer();\n\nconst app = createApp(\n  fakeDOM,\n  routeBase,\n)\n\napp\n  .get(\"/api/users\", async ({params}, res, next) =\u003e {\n    try {\n      let req = await fetch(\n        'https://dummyjson.com/users?limit=3\u0026select=firstName,age',\n        {\n          headers: {\n            'Content-Type': 'application/json',\n          },\n        }\n      )\n\n      if (req.ok) {\n        let users = await req.text()\n\n        if (users) {\n          console.log('router get /api/users', params, users)\n\n          return res.json(users)\n        }\n      }\n    } catch (err) {\n      next(err)\n    }\n\n    next('failed to retrieve users data')\n  })\n  .use(serveStaticFiles(join(import.meta.dirname, '../')))\n\nhttpServer.on('request', app.listen);\n\nhttpServer.listen(8080, () =\u003e {\n  console.log('Listening on http://127.0.0.1:8080');\n});\n```\n\n\n---\n### Special Thanks\nOriginally forked from [NavAid](https://github.com/lukeed/navaid), but with significant changes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjojobyte%2Ftheway","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjojobyte%2Ftheway","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjojobyte%2Ftheway/lists"}