chubbyts-framework
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.
Requirements
- node: 22
- @chubbyts/chubbyts-dic-types: ^2.4.0
- @chubbyts/chubbyts-http-error: ^3.6.0
- @chubbyts/chubbyts-http-types: ^4.1.0
- @chubbyts/chubbyts-log-types: ^3.4.0
- @chubbyts/chubbyts-throwable-to-error: ^2.4.0
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
- @chubbyts/chubbyts-http-api
- @chubbyts/chubbyts-http-cors
- @chubbyts/chubbyts-http-multipart
- @chubbyts/chubbyts-http-oidc
- @chubbyts/chubbyts-http-rate-limit
- @chubbyts/chubbyts-http-static-file
- @chubbyts/chubbyts-http-trusted-proxy
Skeleton
Copyright
2026 Dominik Zogg