{"id":15133373,"url":"https://github.com/funnyzak/koa-starter","last_synced_at":"2025-10-23T09:31:16.280Z","repository":{"id":61208519,"uuid":"449999531","full_name":"funnyzak/koa-starter","owner":"funnyzak","description":"基于 Koa2 构建的快速开始 Web 脚手架。","archived":false,"fork":false,"pushed_at":"2025-01-27T02:18:56.000Z","size":1245,"stargazers_count":12,"open_issues_count":3,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-06T07:22:10.233Z","etag":null,"topics":["aliyun","koa","koa2","mocha","mongodb","mysql","nodejs","oss","supertest","test"],"latest_commit_sha":null,"homepage":"https://koa.gp.yycc.dev","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/funnyzak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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,"lfx_crowdfunding":null,"custom":["https://github.com/funnyzak/funnyzak/blob/storage/assets/coffee.png"]}},"created_at":"2022-01-20T07:38:01.000Z","updated_at":"2024-09-24T12:10:50.000Z","dependencies_parsed_at":"2023-02-16T03:15:56.175Z","dependency_job_id":"e309c75f-4f52-429d-bf96-acc7d5d006f2","html_url":"https://github.com/funnyzak/koa-starter","commit_stats":null,"previous_names":[],"tags_count":5,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funnyzak%2Fkoa-starter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funnyzak%2Fkoa-starter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funnyzak%2Fkoa-starter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funnyzak%2Fkoa-starter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/funnyzak","download_url":"https://codeload.github.com/funnyzak/koa-starter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237807447,"owners_count":19369595,"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":["aliyun","koa","koa2","mocha","mongodb","mysql","nodejs","oss","supertest","test"],"created_at":"2024-09-26T05:01:00.155Z","updated_at":"2025-10-23T09:31:15.875Z","avatar_url":"https://github.com/funnyzak.png","language":"JavaScript","funding_links":["https://github.com/funnyzak/funnyzak/blob/storage/assets/coffee.png"],"categories":[],"sub_categories":[],"readme":"# Koa2 Starter\n\n基于 Koa2 构建的快速开始 Web 脚手架。\n\n[![Build Status][build-status-image]][build-status]\n[![license][license-image]][repository-url]\n[![Sourcegraph][sg-image]][sg-url]\n[![GitHub last commit][last-commit-image]][repository-url]\n[![GitHub repo size][repo-size-image]][repository-url]\n\n\u003c!-- [![action][ci-image]][ci-url] --\u003e\n\u003c!-- [![npm download][download-image]][download-url] --\u003e\n\u003c!-- [![GitHub commit activity][commit-activity-image]][repository-url] --\u003e\n\n[build-status-image]: https://github.com/funnyzak/koa-starter/actions/workflows/test.yml/badge.svg\n[sg-image]: https://img.shields.io/badge/view%20on-Sourcegraph-brightgreen.svg?style=flat-square\n[sg-url]: https://sourcegraph.com/github.com/funnyzak/koa-starter\n[build-status]: https://github.com/funnyzak/koa-starter/actions\n[last-commit-image]: https://img.shields.io/github/last-commit/funnyzak/koa-starter?style=flat-square?style=flat-square\u0026label=last%20commit\n[license-image]: https://img.shields.io/github/license/funnyzak/koa-starter.svg?style=flat-square\n[repository-url]: https://github.com/funnyzak/koa-starter\n[repo-size-image]: https://img.shields.io/github/repo-size/funnyzak/koa-starter?style=flat-square\u0026logo=github\u0026logoColor=white\u0026label=size\n\n## 目录\n\n- [Koa2 Starter](#koa2-starter)\n  - [目录](#目录)\n  - [特点](#特点)\n  - [运行](#运行)\n  - [接口](#接口)\n  - [结构](#结构)\n  - [部署](#部署)\n    - [Compose 部署](#compose-部署)\n    - [Docker 启动](#docker-启动)\n  - [参考](#参考)\n  - [Contribution](#contribution)\n  - [License](#license)\n\n## 特点\n\n1. 基于 Koa2 的 Web 框架\n2. 集成 MongoDB 数据库\n3. 集成 MySQL 数据库\n4. 集成 Redis 数据库\n5. 集成 JOI 路由验证\n6. 集成 koa-session\n7. eslint、prettier 代码规范\n8. ejs 模板引擎\n9. 支持跨域、文件静态、多路由声明\n10. 支持测试覆盖\n11. 简单的文件存储服务（集成了阿里云）\n\n## 运行\n\n1. **config**下，创建 **config-[name].js** 配置文件；\n2. 安装项目依赖，启动项目。\n\n```bash\nnpm ci\n\n# 开发启动\nnpm run watch\n\n# 生产启动\nnpm start\n# or\nexport NODE_ENV=production \u0026\u0026 node index.js\n\n# 测试覆盖\nnpm run cov\n```\n\n## 接口\n\n已经实现的接口，已梳理为接口文档，托管在[APIPOST](\u003c(https://docs.apipost.cn/preview/360b0518f5e2805e/4d5c697edb4e2b6b)\u003e)，[在线查看](https://docs.apipost.cn/preview/360b0518f5e2805e/4d5c697edb4e2b6b)。\n\n## 结构\n\n    ├── .vscode                                // vscode 配置\n    ├── app.js                                 // app入口文件\n    ├── common                                 // 公共库\n    ├── config                                 // 应用配置\n    ├── docker-compose                         // Dokcer 部署示例\n    ├── controller                             // 路由控制器\n    ├── index.js                               // 启动文件\n    ├── lib                                    // 工具库\n    ├── logs                                   // 日志文件夹\n    ├── middleware                             // 中间件\n    ├── test                                   // 测试覆盖\n    ├── models                                 // db model\n    ├── public                                 // 静态资源文件夹\n    ├── router                                 // 路由\n    ├── schema                                 // 验证规则\n    ├── service                                // 应用业务\n    └── views                                  // 模板\n\n## 部署\n\n### Compose 部署\n\n可以通过配置 Docker-Compose 结合 git-webhook 完成自动化部署，可看[示例配置](https://github.com/funnyzak/koa-starter/tree/main/docker-compose)。\n\n### Docker 启动\n\n也可以通过 Docker 启动，需要注意的是，需要挂载项目文件到容器中，否则无法启动。\n\n```bash\ndocker run -v \"$(pwd)\":/app -e NODE_ENV=production --name my-node-app  -p 81:3000 funnyzak/java-nodejs-python-go-etc node /app/index.js\n```\n\n以上是生产环境的启动命令，因此需要修改 `config/config-production.js` 配置文件。\n\n- `-v \"$(pwd)\":/app` 将当前目录映射到容器的`/app`目录。\n- `-e NODE_ENV=production` 设置环境变量`NODE_ENV`为`production`。\n- `--name my-node-app` 指定容器的名称为`my-node-app`。\n- `-p 81:3000` 将容器的`3000`端口映射到主机的`81`端口。\n- `funnyzak/java-nodejs-python-go-etc` 是您要使用的镜像名称。\n- `node /app/index.js` 是要在容器中执行的启动命令。\n\n## 参考\n\n- [Mongodb-utils](https://github.com/mono-js/mongodb-utils)\n- [Redis](http://doc.redisfans.com/)\n- [IoRedis](https://docs.redis.com/latest/rs/references/client_references/client_ioredis/)\n- [MongoDb](https://docs.mongodb.com/)\n- [sequelizejs](https://sequelize.org/master/manual/getting-started.html)\n- [Joi](https://joi.dev/api/)\n\n## Contribution\n\nIf you have any questions or suggestions, please feel free to open an issue or pull request.\n\n\u003ca href=\"https://github.com/funnyzak/koa-starter/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=funnyzak/koa-starter\" /\u003e\n\u003c/a\u003e\n\n## License\n\nMIT License © 2021 [funnyzak](https://github.com/funnyzak)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunnyzak%2Fkoa-starter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffunnyzak%2Fkoa-starter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunnyzak%2Fkoa-starter/lists"}