{"id":13799693,"url":"https://github.com/zedgu/koa-ovenware","last_synced_at":"2026-02-28T17:04:01.431Z","repository":{"id":26656277,"uuid":"30112548","full_name":"zedgu/koa-ovenware","owner":"zedgu","description":"Automatic Model / Controller Loader for Koa","archived":false,"fork":false,"pushed_at":"2017-06-12T07:18:06.000Z","size":17,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-26T09:26:28.341Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zedgu.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}},"created_at":"2015-01-31T13:11:20.000Z","updated_at":"2022-02-08T10:59:56.000Z","dependencies_parsed_at":"2022-09-20T03:12:03.285Z","dependency_job_id":null,"html_url":"https://github.com/zedgu/koa-ovenware","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/zedgu/koa-ovenware","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zedgu%2Fkoa-ovenware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zedgu%2Fkoa-ovenware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zedgu%2Fkoa-ovenware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zedgu%2Fkoa-ovenware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zedgu","download_url":"https://codeload.github.com/zedgu/koa-ovenware/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zedgu%2Fkoa-ovenware/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29943685,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-28T13:49:17.081Z","status":"ssl_error","status_checked_at":"2026-02-28T13:48:50.396Z","response_time":90,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-08-04T00:01:05.161Z","updated_at":"2026-02-28T17:04:01.389Z","avatar_url":"https://github.com/zedgu.png","language":"JavaScript","funding_links":[],"categories":["仓库"],"sub_categories":["中间件"],"readme":"Koa-Ovenware\n=======\n\n[![NPM version][npm-image]][npm-url] \n[![build status][travis-image]][travis-url] \n[![Test coverage][coveralls-image]][coveralls-url]\n[![NPM Monthly Downloads][npm-download]][npm-url]\n[![Dependencies][david-image]][david-url]\n[![License][license-image]][license-url]\n[![Tips][tips-image]][tips-url]\n\nAutomatic Model / Controller Loader for Koa\n\n* Write a controller and get all route pattern you want.\n* Compatible with other middlewares including view renders.\n\nInstall\n-------\n```sh\nnpm install koa-ovenware --save\n```\n\nSimple Usage\n------------\n####Require...\n```js\nvar kow = require('koa-ovenware');\n```\n\n####Config...\n```js\nkow(app);\n```\n\n####Controller file\nDefault path of controllers: ./lib/controllers/\n\nin index.js:\n```js\nexports.index = function *() {\n  this.body = 'hello koa';\n};\n```\nCheckout the [examples](https://github.com/zedgu/koa-ovenware/tree/master/examples).\n\nConventions\n-----------\n\n####Action Mapping\n```\nroute           http method    function of ctrl\n:resource       get            index\n:resource       post           create\n:resource/:id   get            get\n:resource/:id   put            update\n:resource/:id   del            del\n```\nAll routes can be customized by setting, see [Default values](#default-values); and also can be changed by controller api singly, see [APIs - Routes](#routes).\n\n####Resource\nResource name will be the file name of the controller, if there is no alias set for the controller, see [APIs - Alias](#alias).\n\nAPIs\n----\n####Options\n```js\nkow(app[, options])\n```\n`options` see [Default values](#default-values)\n\n####Controller APIs\n#####Alias\nSet alias for the controller.\n\n```js\nexports.alias = 'name_you_want';\n```\n\n#####Routes\nSet routes for the controller.\n\n```js\nexports.routes = {\n  entry: {\n    method: 'get',\n    path: '/index'\n  }\n};\n```\n\n#####Model\nGet model object.\n\n```js\n/**\n * get model object by given controller file name\n *\n * @param   {String}   modelName   optional, undefined for the model has\n *                                 the the same name as this controller\n * @return  {Object}               model object\n */\nthis.model([modelName])\nexports.model([modelName])\n```\n\nfor exmample:\n\n```js\nexports.get = function *() {\n  this.model('abc');\n};\n// or\nexports.todo = function() {\n  this.model(); // this === exports\n};\n```\n\n#####Ctrl\nGet controller object.\n\n```js\n/**\n * get ctrl object by given controller file name\n *\n * @param   {String}   ctrlName   optional, undefined for self\n * @return  {Object}              ctrl object\n */\nthis.ctrl([ctrlName])\nexports.ctrl([ctrlName])\n```\n\nfor exmample:\n\n```js\nexports.get = function *() {\n  this.ctrl(); // =\u003e return this exports\n};\n// or\nexports.todo = function() {\n  exports.ctrl('abc');\n};\n```\n\nGlobal configuration\n--------------------\n####Default values\n```js\n{\n  root: './lib',        // root dir\n  ctrl: 'controllers',  // controllers dir\n  model: 'models'       // model dir\n  format: 'json',       // format by default\n  prefix: '/',          // String or RegExp\n  aliases: {\n    'index': ''\n  },\n  routes: {\n    'index': {\n      method: 'get',\n      path: ''\n    },\n    'create': {\n      method: 'post',\n      path: ''\n    },\n    'get': {\n      method: 'get',\n      path: '/:id'\n    },\n    'update': {\n      method: 'put',\n      path: '/:id'\n    },\n    'del': {\n      method: 'del',\n      path: '/:id'\n    }\n  }\n}\n```\n\nLicense\n-------\nMIT\n\n[npm-image]: https://img.shields.io/npm/v/koa-ovenware.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/koa-ovenware\n[travis-image]: https://img.shields.io/travis/zedgu/koa-ovenware.svg?style=flat-square\n[travis-url]: https://travis-ci.org/zedgu/koa-ovenware\n[coveralls-image]: https://img.shields.io/coveralls/zedgu/koa-ovenware.svg?style=flat-square\n[coveralls-url]: https://coveralls.io/r/zedgu/koa-ovenware?branch=master\n[david-image]: http://img.shields.io/david/zedgu/koa-ovenware.svg?style=flat-square\n[david-url]: https://david-dm.org/zedgu/koa-ovenware\n[npm-status]: https://nodei.co/npm/koa-ovenware.png?downloads=true\n[npm-status-url]: https://nodei.co/npm/koa-ovenware/\n[license-image]: http://img.shields.io/npm/l/koa-ovenware.svg?style=flat-square\n[license-url]: https://github.com/zedgu/koa-ovenware/blob/master/LICENSE\n[npm-download]: http://img.shields.io/npm/dm/koa-ovenware.svg?style=flat-square\n[tips-image]: http://img.shields.io/gittip/zedgu.svg?style=flat-square\n[tips-url]: https://www.gittip.com/zedgu/","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzedgu%2Fkoa-ovenware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzedgu%2Fkoa-ovenware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzedgu%2Fkoa-ovenware/lists"}