{"id":18821400,"url":"https://github.com/borderless/fetch-router","last_synced_at":"2025-04-14T00:32:38.350Z","repository":{"id":47854743,"uuid":"263811732","full_name":"borderless/fetch-router","owner":"borderless","description":"Simple routing middleware for fetch","archived":false,"fork":false,"pushed_at":"2023-12-12T06:31:03.000Z","size":876,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-10T10:38:41.981Z","etag":null,"topics":["cloudflare-workers","fetch","path-to-regexp","router","routing"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/borderless.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":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-05-14T04:07:18.000Z","updated_at":"2021-11-24T11:11:56.000Z","dependencies_parsed_at":"2023-12-27T00:22:06.507Z","dependency_job_id":"8b2c4735-b6e1-4a60-bd88-8de04216e219","html_url":"https://github.com/borderless/fetch-router","commit_stats":{"total_commits":14,"total_committers":2,"mean_commits":7.0,"dds":0.4285714285714286,"last_synced_commit":"2854ffe9480ebda5394b4c39e7d785b0abd1f0c0"},"previous_names":["borderlesslabs/fetch-router"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borderless%2Ffetch-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borderless%2Ffetch-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borderless%2Ffetch-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borderless%2Ffetch-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/borderless","download_url":"https://codeload.github.com/borderless/fetch-router/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223612915,"owners_count":17173632,"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":["cloudflare-workers","fetch","path-to-regexp","router","routing"],"created_at":"2024-11-08T00:40:35.629Z","updated_at":"2024-11-08T00:40:36.500Z","avatar_url":"https://github.com/borderless.png","language":"TypeScript","readme":"# Fetch Router\n\n[![NPM version][npm-image]][npm-url]\n[![NPM downloads][downloads-image]][downloads-url]\n[![Build status][travis-image]][travis-url]\n[![Test coverage][coveralls-image]][coveralls-url]\n\n\u003e Simple routing middleware for [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API).\n\n## Installation\n\n```sh\nnpm install @borderless/fetch-router --save\n```\n\n## Usage\n\n```js\nimport { compose } from \"throwback\";\nimport { get, post, paramsKey } from \"@borderless/fetch-router\";\n\nconst animals = [\"rabbit\", \"dog\", \"cat\"];\n\nconst app = compose([\n  get(\"/pets\", function () {\n    return new Response(animals.join(\"\\n\"));\n  }),\n  get(\"/pets/:id\", function (req) {\n    return new Response(animals[Number(req[paramsKey].id)]);\n  }),\n]);\n```\n\n### Composition\n\nIf you need more control, the package exposes the internally used functions: `method` and `use`.\n\n- `use(path, fn, options?)` - Match an incoming request against [Path To RegExp](https://github.com/pillarjs/path-to-regexp).\n- `method(verb, fn)` - Match an incoming request against a HTTP method.\n\n**Tip:** You can recursively mount routes using `use()` and `{ end: false }`:\n\n```js\nconst nested = get(\"/pets\", () =\u003e new Response(\"test\"));\nconst app = use(\"/api\", nested, { end: false }); // Allows partial match on `/api/pets`.\n```\n\n## TypeScript\n\nThis project is written using [TypeScript](https://github.com/Microsoft/TypeScript) and publishes the definitions directly to NPM.\n\n## License\n\nMIT\n\n[npm-image]: https://img.shields.io/npm/v/@borderless/fetch-router.svg?style=flat\n[npm-url]: https://npmjs.org/package/@borderless/fetch-router\n[downloads-image]: https://img.shields.io/npm/dm/@borderless/fetch-router.svg?style=flat\n[downloads-url]: https://npmjs.org/package/@borderless/fetch-router\n[travis-image]: https://img.shields.io/travis/BorderlessLabs/fetch-router.svg?style=flat\n[travis-url]: https://travis-ci.org/BorderlessLabs/fetch-router\n[coveralls-image]: https://img.shields.io/coveralls/BorderlessLabs/fetch-router.svg?style=flat\n[coveralls-url]: https://coveralls.io/r/BorderlessLabs/fetch-router?branch=master\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborderless%2Ffetch-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fborderless%2Ffetch-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborderless%2Ffetch-router/lists"}