{"id":22261430,"url":"https://github.com/mhio/node-koa-api-handle","last_synced_at":"2026-05-08T13:44:12.638Z","repository":{"id":31169241,"uuid":"124603826","full_name":"mhio/node-koa-api-handle","owner":"mhio","description":"Koa API Handler","archived":false,"fork":false,"pushed_at":"2024-02-09T02:14:03.000Z","size":946,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-30T12:28:32.082Z","etag":null,"topics":["api","http","javascript","koa","nodejs"],"latest_commit_sha":null,"homepage":null,"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/mhio.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":"2018-03-09T23:23:50.000Z","updated_at":"2022-07-16T10:02:15.000Z","dependencies_parsed_at":"2025-01-30T12:37:24.228Z","dependency_job_id":null,"html_url":"https://github.com/mhio/node-koa-api-handle","commit_stats":null,"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhio%2Fnode-koa-api-handle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhio%2Fnode-koa-api-handle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhio%2Fnode-koa-api-handle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhio%2Fnode-koa-api-handle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mhio","download_url":"https://codeload.github.com/mhio/node-koa-api-handle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245472559,"owners_count":20621130,"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","http","javascript","koa","nodejs"],"created_at":"2024-12-03T09:12:46.932Z","updated_at":"2026-05-08T13:44:07.599Z","avatar_url":"https://github.com/mhio.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"@mhio/koa-api-handle\n--------------------\n\nA Koa API Handler to do all the request heavy lifting, so you just write logic\n\nHigher level use from: https://github.com/mhio/node-koa-api\n\n## Install\n\n```\nyarn add @mhio/koa-api-handle\nnpm install @mhio/koa-api-handle\n```\n\n## Usage\n\n[API docs](doc/API.md)\n\n```\nconst Koa = require('koa')\nconst Router = require('koa-router')\nconst {KoaApiHandle} = require('@mhio/koa-api-handle')\n\nclass MyHandler {\n  \n  static get error_message(){\n    return 'Failure'\n  }\n\n  static async ok(ctx){\n    return {\n      ok: true,\n      request_id, ctx.state.request_id,\n    }\n  }\n\n  static async other(){\n    return 'other'\n  }\n\n  static async error(){\n    throw new Error(this.error_message)\n  }\n\n}\n\nconst app = new Koa()\nconst router = new Router()\n\napp.use(KoaApiHandle.error())\napp.use(KoaApiHandle.tracking())\n\nrouter.get('/ok', KoaApiHandle.response(MyHandler, 'ok'))\nrouter.post('/other', KoaApiHandle.response(MyHandler, 'other'))\nrouter.get('/error', KoaApiHandle.response(MyHandler.error.bind(MyError)))\n\napp.use(router.routes())\n   .use(router.allowedMethods())\n\napp.use(KoaApiHandle.notFound())\n\napp.listen()\n```\n\n## Changes\n\nv0.12.x -- Node 20+, pino for logger\n\n\nhttps://github.com/mhio/node-koa-api-handle\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmhio%2Fnode-koa-api-handle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmhio%2Fnode-koa-api-handle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmhio%2Fnode-koa-api-handle/lists"}