{"id":20077579,"url":"https://github.com/digitaledgeit/no-frills-router","last_synced_at":"2025-07-02T20:05:44.116Z","repository":{"id":65459728,"uuid":"42810518","full_name":"digitaledgeit/no-frills-router","owner":"digitaledgeit","description":"A simple router used in a few of my isomorphic experiments.","archived":false,"fork":false,"pushed_at":"2015-10-20T10:05:51.000Z","size":128,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-25T12:03:22.187Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/digitaledgeit.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}},"created_at":"2015-09-20T11:26:45.000Z","updated_at":"2015-09-20T11:28:11.000Z","dependencies_parsed_at":"2023-01-24T14:25:10.662Z","dependency_job_id":null,"html_url":"https://github.com/digitaledgeit/no-frills-router","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaledgeit%2Fno-frills-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaledgeit%2Fno-frills-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaledgeit%2Fno-frills-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaledgeit%2Fno-frills-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/digitaledgeit","download_url":"https://codeload.github.com/digitaledgeit/no-frills-router/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241509618,"owners_count":19974071,"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-13T15:09:05.120Z","updated_at":"2025-03-02T12:44:51.967Z","avatar_url":"https://github.com/digitaledgeit.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# no-frills-router\n\nA simple router used in a few of my isomorphic experiments.\n\n## Installation\n\n    npm install --save no-frills-router\n    \n## Usage\n    \n    var nfr = require('no-frills-router');\n    var http = require('http');\n    \n    var router = nfr()\n      .map('index', '/', require('./lib/home'))\n      .map('profile', '/user/:username', require('./lib/profile'))\n      .map('*', require('./lib/not-found'), {status: 404})\n    ;\n    \n    http.createServer(function(req, res) {\n    \n      //match a URL to a handler\n      var match = router.match(req.url);\n    \n      res.status = match.status || 200;\n      res.end(match.handler(match, router));\n    \n    }).listen(3001);\n                \n## API\n\n### new Router()\n\nCreate a new router.\n\n### .map([name : string,] pattern : string, handler : mixed [, data : object])\n  \nMap a URL pattern to a handler.\n\nParameters:\n\n- `[name]` - the route name - used for the `.assemble()` method\n- `pattern` - a pattern - see [path-to-regex](https://www.npmjs.com/package/path-to-regexp) for details\n- `handler` - a function, object, react component or whatever you want\n- `[data]` - any other data you want to access when the route is matched\n\n### .match(url : string) : object|null\n               \nMatch a URL to a handler.\n\nParameters:\n\n- `url` - the URL\n\nReturns:\n\n- `name` - the route name\n- `params` - the route params\n- `handler` - the route handler\n- `...` - the other data you passed to the `.route()` method\n\n\n### .assemble(name : string [, params : Object]) : string|null\n\nAssemble a URL for a handler.\n                \n- `name` - the route name\n- `params` - the route parameters\n                \n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2015 James Newell","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitaledgeit%2Fno-frills-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigitaledgeit%2Fno-frills-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitaledgeit%2Fno-frills-router/lists"}