{"id":25065783,"url":"https://github.com/dubniczky/oneapi","last_synced_at":"2026-05-03T20:39:14.521Z","repository":{"id":160030710,"uuid":"631205949","full_name":"dubniczky/OneApi","owner":"dubniczky","description":"JSON object-based single-endpoint server API","archived":false,"fork":false,"pushed_at":"2023-06-10T11:11:13.000Z","size":61,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-09T12:45:07.037Z","etag":null,"topics":["api","json","nodejs","server"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/oneapi.js","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/dubniczky.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":"2023-04-22T09:20:45.000Z","updated_at":"2023-06-10T11:12:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"428d4d3f-39b3-4eb6-8d23-12238cea5275","html_url":"https://github.com/dubniczky/OneApi","commit_stats":{"total_commits":21,"total_committers":1,"mean_commits":21.0,"dds":0.0,"last_synced_commit":"6200f678fef9f8298fbab426a004443642b72fe2"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/dubniczky/OneApi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dubniczky%2FOneApi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dubniczky%2FOneApi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dubniczky%2FOneApi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dubniczky%2FOneApi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dubniczky","download_url":"https://codeload.github.com/dubniczky/OneApi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dubniczky%2FOneApi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272252013,"owners_count":24900564,"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","status":"online","status_checked_at":"2025-08-26T02:00:07.904Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","json","nodejs","server"],"created_at":"2025-02-06T19:45:00.784Z","updated_at":"2026-05-03T20:39:14.479Z","avatar_url":"https://github.com/dubniczky.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OneAPI\n\nJSON object-based single-endpoint server API for JavaScript\n\n## Overview\n\nThis API simplifies the creation of a fully JSON-based HTTP server by providing JSON field-based routing. This routing schema allows multi-dimensional routing strategies with more complex parameters than what normal HTTP headers and paths provide.\n\n## Example\n\n```js\nimport { OneApi } from \"./oneapi.js\"\n\n// Create server object\nconst api = new OneApi()\n\n// Apply middleware\napi.use(async (json) =\u003e {\n    json['middleware'] = true\n    return null\n})\n\n// Add routes\napi.add({ type: 'ping' }, async (json) =\u003e {\n    return { type: 'pong' }\n})\n\napi.add({ type: 'echo' }, async (json) =\u003e {\n    return json\n})\n\napi.default(async (json) =\u003e {\n    return { test: 'nopath'}\n})\n\n\n// Start listening on port\napi.listen(3000)\n```\n\nYou can also specify multiple parameters for your routing. The following example chooses this path if both the `first` and `second` fields are present and contain the specified values.\n\n```js\napi.add({ first: 'a', second: 3 }, async (json) =\u003e {\n    return { correct: true }\n})\n```\n\nThe OneAPI class uses the standard `http` module from NodeJS and exposes the raw request and response objects where you can check and manipulate headers. This is generally not recommended though, unless your application has to use some form of fixed authentication, such as cookies.\n\n```js\napi.add({ a: 'g' }, async (json, req, res) =\u003e {\n    const customHeader = req.headers['custom-header']\n    res.setHeader('custom-header', customHeader)\n\n    return { correct: true }\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdubniczky%2Foneapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdubniczky%2Foneapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdubniczky%2Foneapi/lists"}