{"id":16013445,"url":"https://github.com/magicdawn/egg-compose","last_synced_at":"2026-04-03T23:05:00.853Z","repository":{"id":57220359,"uuid":"90988734","full_name":"magicdawn/egg-compose","owner":"magicdawn","description":"compose koa middleware to an egg.js action","archived":false,"fork":false,"pushed_at":"2017-05-11T15:22:02.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-17T05:24:24.843Z","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/magicdawn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2017-05-11T14:30:27.000Z","updated_at":"2017-05-11T14:37:15.000Z","dependencies_parsed_at":"2022-08-28T23:23:24.963Z","dependency_job_id":null,"html_url":"https://github.com/magicdawn/egg-compose","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicdawn%2Fegg-compose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicdawn%2Fegg-compose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicdawn%2Fegg-compose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicdawn%2Fegg-compose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magicdawn","download_url":"https://codeload.github.com/magicdawn/egg-compose/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237506568,"owners_count":19321205,"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-10-08T14:41:23.140Z","updated_at":"2025-10-21T15:31:26.884Z","avatar_url":"https://github.com/magicdawn.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# egg-compose\n\u003e compose koa middleware to an egg.js action\n\n[![Build Status](https://img.shields.io/travis/magicdawn/egg-compose.svg?style=flat-square)](https://travis-ci.org/magicdawn/egg-compose)\n[![Coverage Status](https://img.shields.io/codecov/c/github/magicdawn/egg-compose.svg?style=flat-square)](https://codecov.io/gh/magicdawn/egg-compose)\n[![npm version](https://img.shields.io/npm/v/egg-compose.svg?style=flat-square)](https://www.npmjs.com/package/egg-compose)\n[![npm downloads](https://img.shields.io/npm/dm/egg-compose.svg?style=flat-square)](https://www.npmjs.com/package/egg-compose)\n[![npm license](https://img.shields.io/npm/l/egg-compose.svg?style=flat-square)](http://magicdawn.mit-license.org)\n\n## Install\n```sh\n$ npm i egg-compose --save\n```\n\n## API\n```js\nconst compose = require('egg-compose');\n```\n\n### action example\n```js\nconst compose = require('egg-compose')\n\nmodule.exports = app =\u003e {\n  class HomeController extends app.Controller {}\n\n  Object.assign(HomeController.prototype, {\n    hello: compose([\n      async(ctx, next) =\u003e {\n        ctx.body = 'hello'\n        return next()\n      },\n      async(ctx, next) =\u003e {\n        ctx.body += ' world'\n      },\n    ])\n  })\n\n  return HomeController\n}\n```\n\nthe `home.hello` will results `hello world` text\n\n### co-wechat example\nhttps://github.com/node-webot/co-wechat#middleware-方法变更\n\n使用 compose 包装一层即可使用\n\n```js\nconst compose = require('egg-compose')\nconst wechat = require('co-wechat')\n\nmodule.exports = app =\u003e {\n  class HomeController extends app.Controller {}\n\n  Object.assign(HomeController.prototype, {\n    wechat: compose([\n      wechat(config).middleware(async message =\u003e {\n        // blabla\n      })\n    ])\n  })\n\n  return HomeController\n}\n```\n\n## Changelog\n[CHANGELOG.md](CHANGELOG.md)\n\n## License\nthe MIT License http://magicdawn.mit-license.org","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagicdawn%2Fegg-compose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagicdawn%2Fegg-compose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagicdawn%2Fegg-compose/lists"}