{"id":23707239,"url":"https://github.com/skyfe79/tiny-router","last_synced_at":"2026-02-14T00:07:07.136Z","repository":{"id":269071839,"uuid":"906279825","full_name":"skyfe79/tiny-router","owner":"skyfe79","description":"A tiny router supporting Express-style route patterns","archived":false,"fork":false,"pushed_at":"2024-12-22T12:23:04.000Z","size":117,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-30T16:36:31.036Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@skyfe79/tiny-router","language":"TypeScript","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/skyfe79.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-12-20T14:46:51.000Z","updated_at":"2024-12-22T12:23:07.000Z","dependencies_parsed_at":"2024-12-20T18:25:56.989Z","dependency_job_id":"4c936e32-fed6-448a-a13f-d7a32ee0d73c","html_url":"https://github.com/skyfe79/tiny-router","commit_stats":null,"previous_names":["skyfe79/tiny-router"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skyfe79%2Ftiny-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skyfe79%2Ftiny-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skyfe79%2Ftiny-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skyfe79%2Ftiny-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skyfe79","download_url":"https://codeload.github.com/skyfe79/tiny-router/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239787646,"owners_count":19697056,"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-12-30T16:33:46.931Z","updated_at":"2025-09-17T23:53:11.702Z","avatar_url":"https://github.com/skyfe79.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @skyfe79/tiny-router\n\nA lightweight and flexible TypeScript router implementation designed for:\n\n- **API Mocking \u0026 Testing**: Create mock API endpoints with dynamic URL patterns for testing and development\n- **URL Pattern Matching**: Parse and extract parameters from dynamic URLs\n- **API Gateway Simulation**: Test API gateway routing logic locally\n- **Command Line Tools**: Route command arguments to specific handlers\n- **Event Routing**: Map event patterns to handlers in event-driven architectures\n\n## Installation\n\n```bash\nnpm install @skyfe79/tiny-router\n```\n\n## Usage\n\n### ESM (ECMAScript Modules)\n\n```typescript\nimport createTinyRouter from '@skyfe79/tiny-router';\n\nconst router = createTinyRouter();\n\n// Basic route\nrouter.map('/', (params) =\u003e {\n  console.log('Root path');\n});\n\n// Route with parameters\nrouter.map('/users/:id', (params) =\u003e {\n  console.log('User ID:', params.id);\n});\n\n// Execute route\nrouter.route('/users/123'); // User ID: 123\n```\n\n### CommonJS\n\n```javascript\nconst { createTinyRouter } = require('@skyfe79/tiny-router');\n\nconst router = createTinyRouter();\n\n// Basic route\nrouter.map('/', (params) =\u003e {\n  console.log('Root path');\n});\n\n// Route with parameters\nrouter.map('/users/:id', (params) =\u003e {\n  console.log('User ID:', params.id);\n});\n\n// Execute route\nrouter.route('/users/123'); // User ID: 123\n```\n\n## HTTP Method Support\n\nThe router supports the following HTTP methods:\n\n```typescript\n// GET method (map is an alias for get)\nrouter.get('/users/:id', (params) =\u003e {\n  console.log('GET User:', params.id);\n});\n\n// POST method\nrouter.post('/users', (params) =\u003e {\n  console.log('Create User');\n});\n\n// PUT method\nrouter.put('/users/:id', (params) =\u003e {\n  console.log('Update User:', params.id);\n});\n\n// DELETE method\nrouter.delete('/users/:id', (params) =\u003e {\n  console.log('Delete User:', params.id);\n});\n\n// Specify method and path together\nrouter.route('POST', '/users');\n```\n\n## Advanced Routing Features\n\n### Optional Parameters\n\n```typescript\nrouter.map('/users/:id?', (params) =\u003e {\n  if (params.id) {\n    console.log('User ID:', params.id);\n  } else {\n    console.log('All users');\n  }\n});\n```\n\n### Wildcards\n\n```typescript\n// Single wildcard\nrouter.map('/files/*', (params) =\u003e {\n  console.log('File path:', params.wildcard);\n});\n\n// Multiple wildcards\nrouter.map('/files/*/versions/*', (params) =\u003e {\n  console.log('File paths:', params.wildcards);\n});\n```\n\n## Features\n\n- Express-style route patterns\n- Support for path parameters (`:param`)\n- Optional parameters (`:param?`)\n- Wildcard support (`*`)\n- Full HTTP method support\n- TypeScript support with type definitions\n- Works with both ESM and CommonJS\n- Zero dependencies\n- Lightweight and fast\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskyfe79%2Ftiny-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskyfe79%2Ftiny-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskyfe79%2Ftiny-router/lists"}