{"id":19258112,"url":"https://github.com/liyingxuan/eggjs-api-model","last_synced_at":"2025-02-23T18:14:55.142Z","repository":{"id":144740035,"uuid":"156075915","full_name":"liyingxuan/eggjs-api-model","owner":"liyingxuan","description":"学习Egg.js完成第一个RESTful API，包含路由、service、数据库连接、model的增删改查、数据库迁移等基础必备项。","archived":false,"fork":false,"pushed_at":"2018-11-04T12:16:19.000Z","size":45,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-05T09:18:32.678Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/liyingxuan.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":"2018-11-04T11:39:24.000Z","updated_at":"2018-11-04T12:16:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"0b9737ef-f3b3-44e2-a774-7de570cec83c","html_url":"https://github.com/liyingxuan/eggjs-api-model","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liyingxuan%2Feggjs-api-model","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liyingxuan%2Feggjs-api-model/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liyingxuan%2Feggjs-api-model/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liyingxuan%2Feggjs-api-model/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/liyingxuan","download_url":"https://codeload.github.com/liyingxuan/eggjs-api-model/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240356189,"owners_count":19788512,"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":[],"created_at":"2024-11-09T19:12:26.317Z","updated_at":"2025-02-23T18:14:55.093Z","avatar_url":"https://github.com/liyingxuan.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# eggjs-api-model\n\n## 学习eggjs用的api模板\n\n如需进一步了解，参见 [egg 文档][egg]。\n\n### 目录结构\n```\negg-project\n├── package.json\n├── app\n|   ├── router.js（入口）\n│   ├── controller\n│   |   └── users.js\n│   ├── middleware\n│   |   └── error_handler.js\n│   ├── model（数据库ORM相关）\n│   |   └── users.js\n│   ├── public（可选）\n│   |   └── xxx.css\n│   └── service\n│       └── users.js\n├── config\n|   ├── config.default.js\n|   ├── config.local.js\n│   ├── config.prod.js\n|   └── plugin.js\n├── database（数据库）\n├── logs（日志）\n└── test（可选，本项目中木有，因为懒得写）\n```\n\n### 本地开发\n```bash\n$ npm install\n$ npm run dev\n$ open http://localhost:7001/api/users/\n```\n\n### 数据库迁移\n```bash\n$ npx sequelize migration:generate --name=init-users\n修改migrations新生成的变成符合自己需要的\n# 升级数据库\n$ npx sequelize db:migrate\n# 如果有问题需要回滚，可以通过 `db:migrate:undo` 回退一个变更\n# npx sequelize db:migrate:undo\n# 可以通过 `db:migrate:undo:all` 回退到初始状态\n# npx sequelize db:migrate:undo:all\n```\n\n### 部署\n\n线上正式环境用 `EGG_SERVER_ENV=prod` 来启动。\n\n```bash\n$ EGG_SERVER_ENV=prod npm start\n```\n\n### 单元测试\n- 没有\n- 具体参见 [egg 文档 -单元测试](https://eggjs.org/zh-cn/core/unittest)。\n\n### 内置指令\n\n- 使用 `npm run lint` 来做代码风格检查。\n- 使用 `npm run autod` 来自动检测依赖更新，详细参见 [autod](https://www.npmjs.com/package/autod) 。\n\n\n[egg]: https://eggjs.org\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliyingxuan%2Feggjs-api-model","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliyingxuan%2Feggjs-api-model","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliyingxuan%2Feggjs-api-model/lists"}