{"id":23398928,"url":"https://github.com/firsttimeez/simple-api-router","last_synced_at":"2026-02-07T03:32:00.481Z","repository":{"id":267213215,"uuid":"900557706","full_name":"FirstTimeEZ/simple-api-router","owner":"FirstTimeEZ","description":"A lightweight, flexible API routing library for JavaScript that provides a simple and extensible way to define and manage API Endpoints.","archived":false,"fork":false,"pushed_at":"2024-12-09T08:17:38.000Z","size":13,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T00:52:04.648Z","etag":null,"topics":["api","backend","dynamic","endpoint","execution","extensible","flexible","framework","handler","lightweight","router","routing","server","simple"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/simple-api-router","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FirstTimeEZ.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-09T03:17:09.000Z","updated_at":"2024-12-09T08:17:07.000Z","dependencies_parsed_at":"2024-12-09T04:22:26.978Z","dependency_job_id":"30324c9e-f37b-4ea1-b7d6-46376e303950","html_url":"https://github.com/FirstTimeEZ/simple-api-router","commit_stats":null,"previous_names":["firsttimeez/simple-api-router"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FirstTimeEZ%2Fsimple-api-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FirstTimeEZ%2Fsimple-api-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FirstTimeEZ%2Fsimple-api-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FirstTimeEZ%2Fsimple-api-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FirstTimeEZ","download_url":"https://codeload.github.com/FirstTimeEZ/simple-api-router/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248448575,"owners_count":21105329,"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":["api","backend","dynamic","endpoint","execution","extensible","flexible","framework","handler","lightweight","router","routing","server","simple"],"created_at":"2024-12-22T09:49:53.842Z","updated_at":"2026-02-07T03:32:00.475Z","avatar_url":"https://github.com/FirstTimeEZ.png","language":"JavaScript","readme":"# Simple API Router\n\nA lightweight, flexible `API` routing library for `JavaScript` that provides a simple and extensible way to define and manage `API Endpoints`.\n\n## Features\n\n- Simple `API` and `Endpoint` class structure\n- Easy route and method matching\n- Flexible endpoint handler execution\n- Supports dynamic API routing\n\n## Usage Example\n\nThis example is taken from a [`Full Working Example`](https://github.com/FirstTimeEZ/server-ssl)\n\nDefining an `API`\n\n```javascript\nimport { Api, Endpoint } from 'simple-api-router';\n\nconst API = new Api(\"/api/\");\n\nAPI.addEndpoint(new Endpoint(\"time\", \"GET\", (req, res) =\u003e {\n    return STATE.respondWithContent(res, Date.now().toString(), STATE.TEXT_HTML);\n}));\n\nconst HTTPS_SERVER = createServerHTTPS(STATE.loadDefaultSecureContext(), (req, res) =\u003e {\n    if (API.checkFindExecute(req, res)) {\n        return;\n    }\n    \n    ...\n})...\n```\n\nCalling an `API`\n\n```javascript\nfetch(\"/api/time\").then((response) =\u003e response.json().then((time) =\u003e console.log(time)));\n```\n\n## API Classes\n\n### `Api` Class\n\n#### Constructor\n- `new Api(apiRoute)`: Create a new API with a base route\n\n#### Methods\n- `addEndpoint(endpoint)`: Add an endpoint to the API\n- `checkRoute(url)`: Check if a URL matches the API's base route\n- `findEndpoint(endpointPath)`: Find an endpoint matching a given path\n- `findEndpointCheckMethod(req)`: Find an endpoint and verify its HTTP method\n- `checkFindExecute(req, res)`: Attempt to execute the handler for a matching endpoint\n\n### `Endpoint` Class\n\n#### Constructor\n- `new Endpoint(path, method, handler)`: Create a new endpoint\n\n#### Methods\n- `checkMethod(method)`: Verify the HTTP method\n- `executeHandler(req, res)`: Execute the endpoint's handler\n- `executeHandlerArgs(req, res, ...args)`: Execute the handler with additional arguments\n\n## Key Concepts\n\n- The `Api` class manages a collection of endpoints for a specific route prefix\n- `Endpoint` instances define specific path, HTTP method, and handler combinations\n- `checkFindExecute` method provides a convenient way to route and handle requests","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirsttimeez%2Fsimple-api-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffirsttimeez%2Fsimple-api-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirsttimeez%2Fsimple-api-router/lists"}