{"id":20364410,"url":"https://github.com/brookshi/webapi-router","last_synced_at":"2025-04-12T04:43:17.262Z","repository":{"id":100478895,"uuid":"79431950","full_name":"brookshi/webapi-router","owner":"brookshi","description":"create restful api with the same feeling of Asp.Net WebApi based on Koa","archived":false,"fork":false,"pushed_at":"2018-10-04T14:58:10.000Z","size":32,"stargazers_count":16,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-26T00:12:11.887Z","etag":null,"topics":["koa","nodejs","router","webapi","webapi-router"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/brookshi.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":"2017-01-19T08:24:04.000Z","updated_at":"2021-01-07T05:27:34.000Z","dependencies_parsed_at":"2023-05-15T03:00:15.401Z","dependency_job_id":null,"html_url":"https://github.com/brookshi/webapi-router","commit_stats":{"total_commits":19,"total_committers":3,"mean_commits":6.333333333333333,"dds":"0.42105263157894735","last_synced_commit":"33f41a6385646a8d46ed7bb41a736c256ac72ded"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brookshi%2Fwebapi-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brookshi%2Fwebapi-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brookshi%2Fwebapi-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brookshi%2Fwebapi-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brookshi","download_url":"https://codeload.github.com/brookshi/webapi-router/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248107910,"owners_count":21049035,"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":["koa","nodejs","router","webapi","webapi-router"],"created_at":"2024-11-15T00:11:39.180Z","updated_at":"2025-04-12T04:43:17.257Z","avatar_url":"https://github.com/brookshi.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# webapi-router\n[\u003cimg src=\"https://badge.fury.io/js/webapi-router.svg\"\u003e](https://www.npmjs.com/package/webapi-router/)\n\ncreate restful api application with the same feeling of Asp.Net WebApi\n\n## Feature\nDont need write the annoying koa.use(...). Instead, webapi-router will auto use the controller file path for router path.\n\nAlso, use decorator `@GET(path)` can indicate the router path directly.\n\nSupport `@GET`, `@POST`, `@DELETE`, `@PUT`, `@OPTIONS`, `@HEAD`, `@PATCH`.\n\n## Usage\n### 1. set folder of controllers and restful api prefix in index.ts/js.\n```ts\nimport { WebApiRouter } from '../lib/index';\n\napp.use(new WebApiRouter().router('sample/controllers', 'api'));\n```\n### 2. add controller base on BaseController\n```ts\nexport class TestController extends BaseController\n{\n\n}\n```\n### 3. add decorator for function\n```ts\n///:name is a path param, get it in arguments by using @PathParam\n/// get body by using @BodyParam\n/// get query param by using @QueryParam\n@POST('/user/:name') // argument is option, if empty, will using controller file path as router path.\npostWithPathParam(@PathParam('name') name: string, @QueryParam('id') id: string, @BodyParam body: any) {\n    console.info(`TestController - post with name: ${name}, body: ${JSON.stringify(body)}`);\n    return 'ok';\n}\n```\n\n## That is all!!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrookshi%2Fwebapi-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrookshi%2Fwebapi-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrookshi%2Fwebapi-router/lists"}