@chubbyts/chubbyts-framework

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

A minimal, highly performant middleware PSR-15 inspired function based micro framework built with as little complexity as possible, aimed primarily at those developers who want to understand all the vendors they use.

原始使用文档
文档目录9 节
  1. Description
  2. Requirements
  3. Installation
  4. Usage
  5. Application builder
  6. Server
  7. Handler's / Middleware's
  8. Skeleton
  9. Copyright

chubbyts-framework

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

Description

A minimal, highly performant middleware PSR-15 inspired function based micro framework built with as little complexity as possible, aimed primarily at those developers who want to understand all the vendors they use.

Workflow

Requirements

Installation

Through NPM as @chubbyts/chubbyts-framework.

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

Usage

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}`),
            };
          },
        }),
      ]),
    ),
  ),
]);

Application builder

A facade around createApplication / createErrorMiddleware / createRouteMatcherMiddleware / createRoute / createGroup: pure construction sugar, the returned handler is the very same middleware pipe as with the explicit composition: error middleware first, app middlewares, route matcher middleware last.

The first argument holds all the dependencies (ApplicationBuilderDependencies), the second one the app middlewares (an empty array if there are none).

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();

Server

node

Running the application via the standard node http implementation.

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

Check the Usage section.

uWebSockets

Running the application via the uWebSockets http implementation.

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

Check the Usage section.

Handler's / Middleware's

Skeleton

2026 Dominik Zogg

版本与发布记录

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

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

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

@chubbyts/chubbyts-framework 是什么?

A minimal, highly performant middleware PSR-15 inspired function based micro framework built with as little complexity as possible, aimed primarily at those developers who want to understand all the vendors they use.

如何安装 @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 和提交记录判断。