{"id":21461774,"url":"https://github.com/appletjs/applet","last_synced_at":"2025-07-15T03:30:31.202Z","repository":{"id":57182859,"uuid":"137641523","full_name":"appletjs/applet","owner":"appletjs","description":"Applet 参考并使用了 Koa框架 核心部分，是一个体积极小且极具表现力的中间件框架，可以运行在Node.js环境下和浏览器端。 ","archived":false,"fork":false,"pushed_at":"2018-06-25T10:00:08.000Z","size":175,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-26T20:53:56.271Z","etag":null,"topics":["applet","framework","javascript","middleware","nodejs","promise"],"latest_commit_sha":null,"homepage":"https://appletjs.github.io/applet/index.html","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/appletjs.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":"2018-06-17T09:00:31.000Z","updated_at":"2019-04-22T06:24:09.000Z","dependencies_parsed_at":"2022-09-14T06:00:32.750Z","dependency_job_id":null,"html_url":"https://github.com/appletjs/applet","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/appletjs/applet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appletjs%2Fapplet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appletjs%2Fapplet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appletjs%2Fapplet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appletjs%2Fapplet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/appletjs","download_url":"https://codeload.github.com/appletjs/applet/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appletjs%2Fapplet/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265397504,"owners_count":23758443,"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":["applet","framework","javascript","middleware","nodejs","promise"],"created_at":"2024-11-23T07:10:53.553Z","updated_at":"2025-07-15T03:30:30.923Z","avatar_url":"https://github.com/appletjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Applet\n\n[![version](https://img.shields.io/npm/v/applet.svg?style=flat-square)](https://www.npmjs.com/package/applet)\n[![downloads](https://img.shields.io/npm/dt/applet.svg?style=flat-square)](https://www.npmjs.com/package/applet)\n[![cdn](https://data.jsdelivr.com/v1/package/npm/applet/badge)](https://www.jsdelivr.com/package/npm/applet)\n[![license](https://img.shields.io/npm/l/applet.svg?style=flat-square)](LICENSE)\n\n#### 简单介绍\n\n`Applet` 参考并使用了 [`Koa框架`](https://koajs.com/) 核心部分，是一个体积极小且极具表现力的中间件框架。\n它没有捆绑任何中间件，也不依赖第三方包，可以运行在**Node.js环境下**和**浏览器端**。\n它的中间件之间按照编码顺序在栈内依次执行，允许我们执行操作并向下传递请求（downstream），之后过滤并逆序返回响应（upstream）。\n\n#### 运行环境\n\n理论上，符合下面任一条件即可：\n\n* 在 Node.js 环境下，Applet 依赖 **node v7.6.0** 或 ES2015及更高版本和 async 方法支持；\n* 在浏览器端则需要通过其它工具转码 [`async 函数`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function)，或者使用 [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)。\n\n\u003e 推荐使用转码工具（如：[buble](https://buble.surge.sh/guide/)、[babel](http://babeljs.io/)）配合打包工具（如：[rollup](https://rollupjs.org)、[parcel](https://parceljs.org/)、[webpack](https://webpack.js.org/)）转换 `async/await`。\n\n\n#### 示例（Example）\n\n必修的 hello world 应用\n\n```js\nconst Applet = require('applet');\nconst app = new Applet();\n\n// handle 执行结果返回一个 promise 实例\nconst handle = app.callback();\n\n// 使用一个普通函数作为中间件\napp.use((ctx, next) =\u003e {\n  ctx.hello = 'hello';\n  return next();\n});\n\n// 使用 async 函数作中间件\napp.use(async (ctx, next) =\u003e {\n  ctx.hello += ' world!';\n  await next();\n});\n\nhandle((ctx) =\u003e {\n console.log(ctx.hello);\n  // =\u003e 'hello world!'\n});\n```\n\n\n## 开发文档\n\n* [简介](https://appletjs.github.io/applet/index.html#introduction)\n* [安装](https://appletjs.github.io/applet/index.html#installation)\n* [应用程序](https://appletjs.github.io/applet/index.html#applet)\n* [中间件](https://appletjs.github.io/applet/index.html#middleware)\n* [上下文](https://appletjs.github.io/applet/index.html#context)\n* [事件接口](https://appletjs.github.io/applet/index.html#event-emitter)\n* [异常处理](https://appletjs.github.io/applet/index.html#exception)\n* [授权协议](https://appletjs.github.io/applet/index.html#license)\n\n\n\n## License\n\nMIT © 2018, \u003ca href=\"mailto:japplet@163.com\" title=\"japplet@163.com\"\u003eMaofeng Zhang\u003c/a\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappletjs%2Fapplet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappletjs%2Fapplet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappletjs%2Fapplet/lists"}