{"id":14156375,"url":"https://github.com/zce/mwa","last_synced_at":"2025-03-23T08:31:48.499Z","repository":{"id":42889276,"uuid":"280359423","full_name":"zce/mwa","owner":"zce","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-13T17:21:45.000Z","size":299,"stargazers_count":7,"open_issues_count":4,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-04-14T05:18:58.961Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/zce.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,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":"zce"}},"created_at":"2020-07-17T07:39:00.000Z","updated_at":"2024-04-16T17:54:51.031Z","dependencies_parsed_at":"2023-12-31T17:26:58.317Z","dependency_job_id":"0e0dd0c8-e37c-4695-b963-1a5075331c32","html_url":"https://github.com/zce/mwa","commit_stats":{"total_commits":66,"total_committers":3,"mean_commits":22.0,"dds":0.5303030303030303,"last_synced_commit":"40b1beb635ccb4eee3049e47058018d6632b5d81"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zce%2Fmwa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zce%2Fmwa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zce%2Fmwa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zce%2Fmwa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zce","download_url":"https://codeload.github.com/zce/mwa/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244287029,"owners_count":20428885,"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-08-17T08:05:25.133Z","updated_at":"2025-03-23T08:31:48.075Z","avatar_url":"https://github.com/zce.png","language":"TypeScript","funding_links":["https://github.com/sponsors/zce"],"categories":["others"],"sub_categories":[],"readme":"# mwa\n\n[![Build Status][build-img]][build-url]\n[![Coverage Status][codecov-img]][codecov-url]\n[![License][license-img]][license-url]\n[![NPM Downloads][downloads-img]][downloads-url]\n[![NPM Version][version-img]][version-url]\n[![Dependency Status][dependency-img]][dependency-url]\n[![devDependency Status][devdependency-img]][devdependency-url]\n[![Code Style][style-img]][style-url]\n\n\u003e 😘 **M**iddle **W**are **A**sync, easily create your own middleware layer. It's like koa's middleware.\n\n## Installation\n\n```shell\n$ npm install mwa\n\n# or pnpm\n$ pnpm add mwa\n\n# or yarn\n$ yarn add mwa\n```\n\n\u003e [!NOTE]\n\u003e `mwa` is an [ESM-only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) package.\n\n## Usage\n\n```js\nimport mwa from 'mwa'\n\nconst app = mwa()\n\napp.use(async (state, next) =\u003e {\n  console.log('mw1 start: ', state)\n  state.a = 1\n  await next()\n  console.log('mw1 end: ', state)\n})\n\napp.use(async (state, next) =\u003e {\n  console.log('mw2 start: ', state)\n  state.b = 1\n  await next()\n  console.log('mw2 end: ', state)\n})\n\ntry {\n  await app.run({})\n  console.log('all completed')\n} catch (err) {\n  console.error(err)\n}\n```\n\n## API\n\n### mwa()\n\nReturn a new Mwa instance.\n\n### Instance\n\n#### .use(middleware)\n\nUse the given middleware. Return the instance itself.\n\n##### middleware\n\n- Type: `async function` or `async function[]`\n- Details: middleware function.\n\n#### .run(state)\n\nRun all middlewares. Return a Promise.\n\n##### state\n\n- Type: `any`\n- Details: middleware context.\n\n## Contributing\n\n1. **Fork** it on GitHub!\n2. **Clone** the fork to your own machine.\n3. **Checkout** your feature branch: `git checkout -b my-awesome-feature`\n4. **Commit** your changes to your own branch: `git commit -am 'Add some feature'`\n5. **Push** your work back up to your fork: `git push -u origin my-awesome-feature`\n6. Submit a **Pull Request** so that we can review your changes.\n\n\u003e **NOTE**: Be sure to merge the latest from \"upstream\" before making a pull request!\n\n## License\n\n[MIT](LICENSE) \u0026copy; [zce](https://zce.me)\n\n\n\n[build-img]: https://img.shields.io/github/actions/workflow/status/zce/mwa/main.yml\n[build-url]: https://github.com/zce/mwa/actions\n[codecov-img]: https://img.shields.io/codecov/c/github/zce/mwa\n[codecov-url]: https://codecov.io/gh/zce/mwa\n[license-img]: https://img.shields.io/github/license/zce/mwa\n[license-url]: https://github.com/zce/mwa/blob/master/LICENSE\n[downloads-img]: https://img.shields.io/npm/dm/mwa\n[downloads-url]: https://npm.im/mwa\n[version-img]: https://img.shields.io/npm/v/mwa\n[version-url]: https://npm.im/mwa\n[dependency-img]: https://img.shields.io/david/zce/mwa\n[dependency-url]: https://david-dm.org/zce/mwa\n[devdependency-img]: https://img.shields.io/david/dev/zce/mwa\n[devdependency-url]: https://david-dm.org/zce/mwa?type=dev\n[style-img]: https://img.shields.io/badge/code_style-standard-brightgreen\n[style-url]: https://standardjs.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzce%2Fmwa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzce%2Fmwa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzce%2Fmwa/lists"}