@chubbyts/chubbyts-framework

中文文档
4.2.0发布于 2026/11/08MITTypeScriptES Module近 30 天下载 2191

一个最小的,高性能的中件PSR-15启发了基于功能的微框架,尽可能不复杂地构建,主要针对那些想了解他们使用的所有销售商的开发者.

中文使用文档
文档目录9 节
  1. 说明
  2. 所需资源
  3. 安装
  4. 使用量
  5. 应用程序构建器
  6. 服务器
  7. 汉德勒/中件
  8. 斯凯莱通
  9. 版权

粗体框架

CI Coverage Status Mutation testing badge npm-version

bugs code_smells coverage duplicated_lines_density ncloc sqale_rating alert_status reliability_rating security_rating sqale_index vulnerabilities

说明

最低的,高的 表演者 中间软件 临 时 15 启发基于功能的微观框架尽可能地不复杂地构建,主要针对那些想了解他们使用的所有销售商的开发者.

Workflow

所需资源

安装

穿过 国家预防机制 作为 @ chubbyts/ chubbyts-框架。 。 。 .

npm i \
  @chubbyts/chubbyts-framework-router-path-to-regexp@^4.1.1 \
  @chubbyts/chubbyts-framework@^4.2.0 \
  @chubbyts/chubbyts-http@^3.1.0

使用量

import { createPathToRegexpMatch }
  from '@chubbyts/chubbyts-framework-router-path-to-regexp/path-to-regexp-router';
import { createResponseFactory, createBodyFactory } from '@chubbyts/chubbyts-http/message-factory';
import { createApplication } from '@chubbyts/chubbyts-framework/application';
import { createErrorMiddleware }
  from '@chubbyts/chubbyts-framework/middleware/error-middleware';
import { createRouteMatcherMiddleware }
  from '@chubbyts/chubbyts-framework/middleware/route-matcher-middleware';
import { createGetRoute } from '@chubbyts/chubbyts-framework/router/route';
import { createRoutesByName } from '@chubbyts/chubbyts-framework/router/routes-by-name';

const bodyFactory = createBodyFactory();
const responseFactory = createResponseFactory(bodyFactory);

const app = createApplication([
  createErrorMiddleware(responseFactory, bodyFactory, true),
  createRouteMatcherMiddleware(
    createPathToRegexpMatch(
      createRoutesByName([
        createGetRoute<{ name: string }>({
          path: '/hello/:name',
          name: 'hello',
          handler: async (serverRequest) => {
            const response = responseFactory(200);

            return {
              ...response,
              headers: { ...response.headers, 'content-type': ['text/plain'] },
              body: bodyFactory(`Hello, ${serverRequest.attributes.name}`),
            };
          },
        }),
      ]),
    ),
  ),
]);

应用程序构建器

周围的外表 createApplication 编号 : createErrorMiddleware 编号 : createRouteMatcherMiddleware 编号 : createRoute 编号 : createGroup:纯结构糖,返回的处理器是同一种中间器件管与同一种管 明确组成:先出错中件,后出app中件,再出路由匹配器中件.

第一个论点涉及所有依附关系(ApplicationBuilderDependencies),第二个应用中间软件 (如果没有空阵列).

import { createPathToRegexpMatch as createMatch }
  from '@chubbyts/chubbyts-framework-router-path-to-regexp/path-to-regexp-router';
import { createResponseFactory, createBodyFactory } from '@chubbyts/chubbyts-http/message-factory';
import { createApplicationBuilder } from '@chubbyts/chubbyts-framework/facade';

const bodyFactory = createBodyFactory();
const responseFactory = createResponseFactory(bodyFactory);

const application = createApplicationBuilder(
  {
    createMatch,
    responseFactory,
    bodyFactory,
    // optional: debug, logger, mapToHttpError, createGeneratePath, createGenerateUrl
  },
  [corsMiddleware],
)
  .get('/ping', 'ping', pingHandler)
  .get('/openapi', 'openapi', openApiHandler)
  .group('/api/pets', [acceptNegotiationMiddleware, apiErrorMiddleware], (pets) =>
    pets
      .get('', 'pet_list', petListHandler)
      .post('', 'pet_create', [contentTypeNegotiationMiddleware], petCreateHandler)
      .get('/:id', 'pet_read', petReadHandler)
      .put('/:id', 'pet_update', [contentTypeNegotiationMiddleware], petUpdateHandler)
      .delete('/:id', 'pet_delete', petDeleteHandler),
  )
  .build();

服务器

节点

通过标准节点运行应用程序 http 执行 .

npm i @chubbyts/chubbyts-http-node@^1.0.0

检查 使用量 节.

uWebSockets (中文(简体) )

通过 uWebSockets http 执行运行应用程序 .

npm i @chubbyts/chubbyts-http-uwebsockets@^1.0.0

检查 使用量 节.

汉德勒/中件

斯凯莱通

2026 道米尼克·佐格(英语:

版本与发布记录

@chubbyts/chubbyts-framework 共发布 69 个版本,首次发布于 2022/05/26;过去 12 个月发布了 20 个版本。

版本发布日期距今
4.2.0latest2026/11/081 天前
4.1.12026/11/036 天前
4.1.02026/11/036 天前
4.0.32026/11/027 天前
4.0.22026/11/018 天前
4.0.12026/11/018 天前

关于 @chubbyts/chubbyts-framework 的常见问题

@chubbyts/chubbyts-framework 是什么?

一个最小的,高性能的中件PSR-15启发了基于功能的微框架,尽可能不复杂地构建,主要针对那些想了解他们使用的所有销售商的开发者.

如何安装 @chubbyts/chubbyts-framework?

在项目目录运行 npm install @chubbyts/chubbyts-framework,或使用 pnpm add / yarn add / bun add。

@chubbyts/chubbyts-framework 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@chubbyts/chubbyts-framework 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@chubbyts/chubbyts-framework 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@chubbyts/chubbyts-framework 可以商用吗?

@chubbyts/chubbyts-framework 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@chubbyts/chubbyts-framework 的下载量有多少?

根据 npm 官方下载统计,@chubbyts/chubbyts-framework 在 2026/10/10 – 2026/11/08 这 30 天内被下载 2,191 次,日均约 73 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@chubbyts/chubbyts-framework 还在维护吗?

最新版本 4.2.0 发布于 2026/11/08(1 天前);至今共发布 69 个版本,其中过去 12 个月发布了 20 个;首次发布于 2022/05/26。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。