{"id":17148694,"url":"https://github.com/oxoyo/x-restful-api-generator-koa","last_synced_at":"2025-07-31T01:37:23.513Z","repository":{"id":86506803,"uuid":"107961039","full_name":"OXOYO/X-RESTful-API-Generator-Koa","owner":"OXOYO","description":"一个基于 Koa 的 RESTful API 服务脚手架。 A RESTful API generator for Koa","archived":false,"fork":false,"pushed_at":"2018-03-07T09:44:17.000Z","size":148,"stargazers_count":18,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-13T11:48:55.578Z","etag":null,"topics":["jsonwebtoken","jwt","koa","koa-api","koa-generator","koa-jwt","koa-multer","koa-mysql","koa-restful","koa2-demo","koa2-generator","koa2-starter","restful","restful-api"],"latest_commit_sha":null,"homepage":"","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/OXOYO.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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,"zenodo":null}},"created_at":"2017-10-23T09:34:22.000Z","updated_at":"2020-12-31T06:36:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"1f66da34-5807-42d7-9483-30b99d2089d1","html_url":"https://github.com/OXOYO/X-RESTful-API-Generator-Koa","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/OXOYO/X-RESTful-API-Generator-Koa","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OXOYO%2FX-RESTful-API-Generator-Koa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OXOYO%2FX-RESTful-API-Generator-Koa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OXOYO%2FX-RESTful-API-Generator-Koa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OXOYO%2FX-RESTful-API-Generator-Koa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OXOYO","download_url":"https://codeload.github.com/OXOYO/X-RESTful-API-Generator-Koa/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OXOYO%2FX-RESTful-API-Generator-Koa/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267972907,"owners_count":24174396,"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","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["jsonwebtoken","jwt","koa","koa-api","koa-generator","koa-jwt","koa-multer","koa-mysql","koa-restful","koa2-demo","koa2-generator","koa2-starter","restful","restful-api"],"created_at":"2024-10-14T21:29:32.576Z","updated_at":"2025-07-31T01:37:23.500Z","avatar_url":"https://github.com/OXOYO.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# X-RESTful-API-Generator-Koa\n\nA RESTful API service generator by Koa.\n\n[ ![Travis CI Status](https://travis-ci.org/OXOYO/X-RESTful-API-Generator-Koa.svg?branch=master)](https://travis-ci.org/OXOYO/X-RESTful-API-Generator-Koa)\n[![codecov.io](https://codecov.io/github/OXOYO/X-RESTful-API-Generator-Koa/coverage.svg?branch=master)](https://codecov.io/github/OXOYO/X-RESTful-API-Generator-Koa?branch=master)\n[![node](https://img.shields.io/badge/node-v7.6.0+-blue.svg)](https://nodejs.org/)\n[![GitHub package version](https://img.shields.io/github/package-json/v/OXOYO/X-RESTful-API-Generator-Koa.svg)]()\n[![dependencies Status](https://david-dm.org/OXOYO/X-RESTful-API-Generator-Koa/status.svg)](https://david-dm.org/OXOYO/X-RESTful-API-Generator-Koa)\n[![codebeat badge](https://codebeat.co/badges/824b49d9-dd7f-4502-9965-76aef840f8d2)](https://codebeat.co/projects/github-com-oxoyo-x-restful-api-generator-koa-master)\n[![license](https://img.shields.io/github/license/OXOYO/X-RESTful-API-Generator-Koa.svg)]()\n[![Gitter](https://img.shields.io/gitter/room/X-RESTful-API-Generator-Koa/chat.svg)](https://gitter.im/X-RESTful-API-Generator-Koa/chat)\n\nEnglish | [简体中文](./README_CN.md)\n\n## Start\n```bash\n  # clone\n  git clone\n\n  # install dependencies\n  npm i\n\n  # import the src/x-restful-api-generator-koa.sql into the database.\n\n  # start serve with hot reload\n  npm run dev\n```\nNode.js \u003e= 7.6.0 required.\n\n## Develop Step\n  1.Edit config.js\n\n  2.Export the database to schema by [sequelize-auto](https://github.com/sequelize/sequelize-auto)\n\n  ```bash\n    npm -g install mysql\n    sequelize-auto -o \"./src/schema\" -d x-restful-api-generator-koa -h localhost -u root -p 3306 -e mysql\n  ```\n\n  3.Create module directories and files\n  ```bash\n    apps\n      \\_ newModules\n          Ctrl.js\n          Model.js\n          Routers.js\n  ```\n\n## Build\n```bash\n  npm run build\n```\n\n## production\n```bash\n  pm2 start ecosystem.config.js --name x-restful-api-generator-koa --env production\n```\n\n## Demo\n\nTo run the demo, you need to import the `./src/x-restful-api-generator-koa.sql` into Mysql\n\n### demoModule_001\n  URL: http://localhost:3000/x-restful-api-generator-koa/demoModule_001/login\n\n  Resonse:\n  ```bash\n    {\n      \"code\": 200,\n      \"msg\": \"登录成功！\",\n      \"data\": {\n        \"token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyTmFtZSI6InRlc3QiLCJwYXNzd29yZCI6IjEyMzQ1NiIsImlhdCI6MTUwODkyMTY2OSwiZXhwIjoxNTA5MDA4MDY5fQ.2occtME3kLUDxntJXOz5e1dkspybGIVqbDPRgaE6lZA\"\n      }\n    }\n  ```\n\n  URL: http://localhost:3000/x-restful-api-generator-koa/demoModule_001/list\n\n  Response:\n  ```bash\n    {\n      \"code\": 200,\n      \"msg\": \"查询列表成功！\",\n      \"data\": {\n        \"count\": 300,\n        \"list\": []\n      }\n    }\n  ```\n\n  URL: http://localhost:3000/x-restful-api-generator-koa/demoModule_001/verify/list\n\n  Response:\n  ```bash\n    {\n      \"code\": 9999,\n      \"msg\": \"token无效！请重新登录！\",\n      \"data\": {}\n    }\n  ```\n\n### Articles\n\n  URL: http://localhost:3000/x-restful-api-generator-koa/articles/add\n\n  Request Body:\n  ```bash\n    {\n      title: 'myArticle_001'\n      content: 'yyyyyyyyyyyyyyyyyyyyyyy'\n    }\n  ```\n\n  Response:\n  ```bash\n    {\n      \"code\": 200,\n      \"msg\": \"添加文章成功！\",\n      \"data\": {\n        \"id\": 3,\n        \"title\": \"myArticle_001\",\n        \"content\": \"yyyyyyyyyyyyyyyyyyyyyyy\",\n        \"updatedAt\": \"2017-10-27T07:52:21.745Z\",\n        \"createdAt\": \"2017-10-27T07:52:21.745Z\"\n      }\n    }\n  ```\n\n  URL: http://localhost:3000/x-restful-api-generator-koa/articles/update\n\n  Request Body:\n  ```bash\n    {\n      id: '3'\n      content: 'xxxxxx'\n    }\n  ```\n\n  Response:\n  ```bash\n    {\n      \"code\": 200,\n      \"msg\": \"编辑文章成功！\",\n      \"data\": {\n        \"id\": 3,\n        \"title\": \"myArticle_003\",\n        \"content\": \"xxxxxx\",\n        \"createdAt\": \"2017-10-26T23:52:21.000Z\",\n        \"updatedAt\": \"2017-10-27T00:08:55.000Z\"\n      }\n    }\n  ```\n\n  URL: http://localhost:3000/x-restful-api-generator-koa/articles/remove\n\n  Request Body:\n  ```bash\n    {\n      id: '2'\n    }\n  ```\n\n  Response:\n  ```bash\n    {\n      \"code\": 200,\n      \"msg\": \"删除文章成功！\",\n      \"data\": 1\n    }\n  ```\n\n  URL: http://localhost:3000/x-restful-api-generator-koa/articles/list?pageSize=1\u0026currentPage=1\n\n  Response:\n  ```bash\n    {\n      \"code\": 200,\n      \"msg\": \"查询账号列表成功！\",\n      \"data\": {\n        \"count\": 2,\n        \"list\": [\n          {\n            \"id\": 1,\n            \"title\": \"myArticle_001\",\n            \"content\": \"yyyyyyyyyyyyyyyyyyyyyyy\",\n            \"createdAt\": \"2017-10-26T23:46:10.000Z\",\n            \"updatedAt\": \"2017-10-26T23:46:10.000Z\"\n          }\n        ]\n      }\n    }\n  ```\n\n### File Upload\n  URL: http://localhost:63342/X-RESTful-API-Generator-Koa/src/apps/Files/upload.html\n\n  Response:\n  ```bash\n    {\n      \"status\": 200,\n      \"msg\": \"上传成功！\",\n      \"data\": {\n        \"file\": {\n          \"fieldname\": \"file\",\n          \"originalname\": \"app.png\",\n          \"encoding\": \"7bit\",\n          \"mimetype\": \"image/png\",\n          \"destination\": \"E:\\\\Webstorm_WorkSpace\\\\X-RESTful-API-Generator-Koa\\\\assets\\\\uploads\",\n          \"filename\": \"1510817484098.png\",\n          \"path\": \"E:\\\\Webstorm_WorkSpace\\\\X-RESTful-API-Generator-Koa\\\\assets\\\\uploads\\\\1510817484098.png\",\n          \"size\": 958\n        },\n        \"filename\": \"1510817484098.png\",\n        \"url\": \"//localhost:3000/assets/uploads/1510817484098.png\"\n      }\n    }\n  ```\n\n## TODO\n\n```bash\n  1.error handler middleware\n```\n\n## License\n[MIT](http://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxoyo%2Fx-restful-api-generator-koa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foxoyo%2Fx-restful-api-generator-koa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxoyo%2Fx-restful-api-generator-koa/lists"}