{"id":13715997,"url":"https://github.com/dotcypress/micro-route","last_synced_at":"2025-03-17T05:32:24.272Z","repository":{"id":57296549,"uuid":"75455437","full_name":"dotcypress/micro-route","owner":"dotcypress","description":"Tiny and super fast http routing helper","archived":false,"fork":false,"pushed_at":"2017-11-16T04:13:39.000Z","size":13,"stargazers_count":94,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-05-08T08:32:34.002Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/dotcypress.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":"2016-12-03T06:06:51.000Z","updated_at":"2024-01-19T20:32:01.000Z","dependencies_parsed_at":"2022-09-07T03:21:28.601Z","dependency_job_id":null,"html_url":"https://github.com/dotcypress/micro-route","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotcypress%2Fmicro-route","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotcypress%2Fmicro-route/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotcypress%2Fmicro-route/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotcypress%2Fmicro-route/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dotcypress","download_url":"https://codeload.github.com/dotcypress/micro-route/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243179870,"owners_count":20249185,"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-08-03T00:01:05.911Z","updated_at":"2025-03-17T05:32:23.908Z","avatar_url":"https://github.com/dotcypress.png","language":"JavaScript","funding_links":[],"categories":["Modules"],"sub_categories":["Routing"],"readme":"[![NPM Version](https://img.shields.io/npm/v/micro-route.svg?style=flat-square)](https://www.npmjs.com/package/micro-route)\n[![node](https://img.shields.io/node/v/micro-route.svg?style=flat-square)](https://www.npmjs.com/package/micro-route)\n[![Build Status](https://img.shields.io/travis/dotcypress/micro-route.svg?branch=master\u0026style=flat-square)](https://travis-ci.org/dotcypress/micro-route)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](http://standardjs.com/)\n\n# micro-route\n\u003e  🎛 Tiny http routing helper based on [`url-pattern`](https://github.com/snd/url-pattern)\n\n## Installation\n\nInstall from NPM:\n\n```js\n$ npm install micro-route --save\n```\n\n## Examples\n\n```js\nconst route = require('micro-route')\n\nconst corsRoute = route('*', 'OPTIONS')\nconst fooRoute = route('/', ['POST', 'PUT'])\nconst barRoute = route('/api/collection/:id', 'DELETE')\nconst anotherRoute = route('/api/transactions/:id')\n\nmodule.exports = function (req, res) {\n  if (corsRoute(req)) {\n    // Send CORS headers \n  } else if (fooRoute(req)) {\n    // Do cool stuff\n  }\n}\n```\n\n```js\nconst match = require('micro-route/match')\n\nmodule.exports = function (req, res) {\n  const { params, query } = match(req, '/api/transactions/:id?ts=12', true)\n  console.log('Transaction id:', params.id)  \n  console.log('ts:', query.ts)  \n}\n```\n\n```js\nconst dispatch = require('micro-route/dispatch')\n\nmodule.exports = dispatch()\n  .dispatch('*', 'OPTIONS', (req, res) =\u003e ... )\n  .dispatch('/', ['POST', 'PUT'], (req, res) =\u003e ... )\n  .dispatch('/api/collection/:id', 'DELETE', (req, res) =\u003e ... )\n  .dispatch('/api/transactions/:id', '*', (req, res, { params, query }) =\u003e ... )\n  .otherwise((req, res) =\u003e ... )\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotcypress%2Fmicro-route","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdotcypress%2Fmicro-route","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotcypress%2Fmicro-route/lists"}