{"id":16293763,"url":"https://github.com/axetroy/kost","last_synced_at":"2025-03-20T03:31:13.574Z","repository":{"id":145997445,"uuid":"121424918","full_name":"axetroy/kost","owner":"axetroy","description":"基于Koa，使用Typescript开发的Web框架","archived":false,"fork":false,"pushed_at":"2019-06-13T04:52:20.000Z","size":338,"stargazers_count":38,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T22:55:23.213Z","etag":null,"topics":["koa","kost","nodejs","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/axetroy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"contributing.md","funding":".github/FUNDING.yml","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},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":"https://github.com/axetroy/buy-me-a-cup-of-tea"}},"created_at":"2018-02-13T19:14:29.000Z","updated_at":"2023-04-19T17:18:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"77b4eb16-0969-40e2-85b2-6cbdd2504668","html_url":"https://github.com/axetroy/kost","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axetroy%2Fkost","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axetroy%2Fkost/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axetroy%2Fkost/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axetroy%2Fkost/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/axetroy","download_url":"https://codeload.github.com/axetroy/kost/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244047647,"owners_count":20389206,"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","kost","nodejs","typescript"],"created_at":"2024-10-10T20:12:17.552Z","updated_at":"2025-03-20T03:31:13.275Z","avatar_url":"https://github.com/axetroy.png","language":"TypeScript","funding_links":["https://github.com/axetroy/buy-me-a-cup-of-tea"],"categories":[],"sub_categories":[],"readme":"## Kost\n\n[![Build Status](https://travis-ci.org/axetroy/kost.svg?branch=master)](https://travis-ci.org/axetroy/kost)\n[![Coverage Status](https://coveralls.io/repos/github/axetroy/kost/badge.svg?branch=master)](https://coveralls.io/github/axetroy/kost?branch=master)\n[![Dependency](https://david-dm.org/axetroy/kost.svg)](https://david-dm.org/axetroy/kost)\n![License](https://img.shields.io/badge/license-MIT-green.svg)\n[![Prettier](https://img.shields.io/badge/Code%20Style-Prettier-green.svg)](https://github.com/prettier/prettier)\n![Node](https://img.shields.io/badge/node-%3E=8.9-blue.svg?style=flat-square)\n[![npm version](https://badge.fury.io/js/%40axetroy%2Fkost.svg)](https://badge.fury.io/js/%40axetroy%2Fkost)\n![Size](https://github-size-badge.herokuapp.com/axetroy/kost.svg)\n\nKost 基于 Koa，使用 Typescript 编写，借鉴于 egg 的**约定大于配置**的思想以及 nest 的依赖注入和装饰器路由。\n\n是一款内置多个功能，并遵循一系列规范的 Web 框架\n\n**特性**\n\n* [x] 依赖注入\n* [x] 使用 Typescript 编写\n* [x] 装饰器风格的路由定义\n* [x] 支持中间件，包括 Koa 的中间件\n* [x] 引入服务的概念\n* [x] 支持加载不同环境下的配置文件\n* [x] 兼容 Koa 中间件\n\n**内置特性**\n\n* [x] Http/Websocket 的代理\n* [x] 静态文件服务\n* [x] 解析 Http Body\n* [x] 视图引擎\n* [x] 跨域资源分享\n* [ ] 错误捕捉\n* [ ] 定时任务\n\n### 框架架构\n\n![kost](https://raw.githubusercontent.com/axetroy/kost/master/kost.png)\n\n### 快速开始\n\n```bash\nnpm install @axetroy/kost --save\n```\n\n这是示例的项目目录, 最简单的搭建一个服务\n\n```\n.\n├── app.ts\n├── controllers\n│   └── home.controller.ts\n└── tsconfig.json\n```\n\n```typescript\n// app.ts\nimport Kost from \"@axetroy/kost\";\n\nconst app = new Kost();\n\napp\n  .start()\n  .then(function(server) {\n    console.log(`Listen on ${server.address().port}`);\n  })\n  .catch(err =\u003e {\n    console.error(err);\n  });\n```\n\n```typescript\n// controllers/home.controller.ts\nimport { Controller, Get } from \"@axetroy/kost\";\n\nexport default class HomeController extends Controller {\n  @Get(\"/\")\n  index(ctx) {\n    ctx.body = \"hello world\";\n  }\n}\n```\n\n```bash\n$ ts-node ./app.ts\n```\n\n## [文档](https://github.com/axetroy/kost/blob/master/doc/useage.md)\n\n## Q \u0026 A\n\nQ: 为什么开发这样的框架\n\n\u003e A: 框架基于以前的项目经验沉淀而来，首先是坚持 Typescript 不动摇，能在开发阶段避免了很多 bug。\n\nQ: 为什么不使用 nest？\n\n\u003e A: 因为它是基于 Express，而我以前的项目都是 Typescript + Koa\n\nQ: 为什么不使用 egg?\n\n\u003e A: egg 使用 JS 开发，目前对 Typescript 没有一个很好的方案(见识短，没发现)，而且 egg 的 service 会丢失类型 IDE 提示，目前 egg 成员已在着手解决这个问题，期待中...\n\nQ: 与两者的框架区别在哪里?\n\n\u003e A: 借鉴了 egg 的约定大于配置的思想，约定了一些文件目录，文件名，如果不按照框架写，就会 boom。借鉴了 nest 的 OOP 编程思想，所有的，包括 Controller、Service、Middleware 都是类，都可以进行依赖注入，而且路由定义是装饰器风格，语法糖会让你更加的直观。对于开发而言，会有很好的 IDE 提示。\n\nQ: 框架内置了一些特性，会不会平白增加性能负担？\n\n\u003e A: 根据你是否开启特性，来决定是否引入包，所以不会有性能损耗。\n\nQ: 是否需要配套 CLI 工具?\n\n\u003e A: 目前没有，编译成 JS 就能运行，可以用 pm2 进行负载均衡。\n\nQ: 框架是否包含进程管理?\n\n\u003e A: 框架本身不进行进程管理，没有类似 egg 的 master 主进程管理子进程，没有 agent\n\n## 贡献者\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\n| [\u003cimg src=\"https://avatars1.githubusercontent.com/u/9758711?v=3\" width=\"100px;\"/\u003e\u003cbr /\u003e\u003csub\u003eAxetroy\u003c/sub\u003e](http://axetroy.github.io)\u003cbr /\u003e[💻](https://github.com/axetroy/kost/commits?author=axetroy) 🔌 [⚠️](https://github.com/axetroy/kost/commits?author=axetroy) [🐛](https://github.com/axetroy/kost/issues?q=author%3Aaxetroy) 🎨 |\n| :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |\n\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\n## 开源许可协议\n\nThe [MIT License](https://github.com/axetroy/kost/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxetroy%2Fkost","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faxetroy%2Fkost","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxetroy%2Fkost/lists"}