https://github.com/chubbyts/chubbyts-framework
A minimal, highly performant middleware PSR-15 inspired function based microframework built with as little complexity as possible, aimed primarily at those developers who want to understand all the vendors they use.
https://github.com/chubbyts/chubbyts-framework
Last synced: 6 months ago
JSON representation
A minimal, highly performant middleware PSR-15 inspired function based microframework built with as little complexity as possible, aimed primarily at those developers who want to understand all the vendors they use.
- Host: GitHub
- URL: https://github.com/chubbyts/chubbyts-framework
- Owner: chubbyts
- License: mit
- Created: 2022-05-24T20:22:28.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-08-12T19:31:22.000Z (10 months ago)
- Last Synced: 2024-11-14T11:36:59.615Z (7 months ago)
- Language: TypeScript
- Homepage: https://chubbyts-framework.dev/
- Size: 343 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - chubbyts/chubbyts-framework - A minimal, highly performant middleware PSR-15 inspired function based microframework built with as little complexity as possible, aimed primarily at those developers who want to understand all the vendors they use. (TypeScript)
README
# chubbyts-framework
[](https://github.com/chubbyts/chubbyts-framework/actions?query=workflow%3ACI)
[](https://coveralls.io/github/chubbyts/chubbyts-framework?branch=master)
[](https://dashboard.stryker-mutator.io/reports/github.com/chubbyts/chubbyts-framework/master)
[](https://www.npmjs.com/package/@chubbyts/chubbyts-framework)[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-framework)
[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-framework)
[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-framework)
[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-framework)
[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-framework)
[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-framework)
[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-framework)
[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-framework)
[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-framework)
[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-framework)
[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-framework)## Description
A minimal, highly [performant][2] middleware [PSR-15][3] inspired function based microframework built with as little complexity as possible, aimed primarily at those developers who want to understand all the vendors they use.

## Requirements
* node: 16
* [@chubbyts/chubbyts-dic-types][4]: ^1.2.1
* [@chubbyts/chubbyts-http-error][5]: ^2.3.1
* [@chubbyts/chubbyts-http-types][6]: ^1.2.3
* [@chubbyts/chubbyts-log-types][7]: ^1.3.2
* [@chubbyts/chubbyts-throwable-to-error][8]: ^1.2.1## Installation
Through [NPM](https://www.npmjs.com) as [@chubbyts/chubbyts-framework][1].
```sh
npm i \
@chubbyts/chubbyts-framework-router-path-to-regexp@^1.4.0 \
@chubbyts/chubbyts-framework@^1.9.4 \
@chubbyts/chubbyts-http@^1.2.1
```## Usage
### App
```ts
import { createApplication } from '@chubbyts/chubbyts-framework/dist/application';
import { createErrorMiddleware } from '@chubbyts/chubbyts-framework/dist/middleware/error-middleware';
import { createRouteMatcherMiddleware } from '@chubbyts/chubbyts-framework/dist/middleware/route-matcher-middleware';
import { createGetRoute } from '@chubbyts/chubbyts-framework/dist/router/route';
import { createRoutesByName } from '@chubbyts/chubbyts-framework/dist/router/routes-by-name';
import { createResponseFactory } from '@chubbyts/chubbyts-http/dist/message-factory';
import { createPathToRegexpRouteMatcher } from '@chubbyts/chubbyts-framework-router-path-to-regexp/dist/path-to-regexp-router';
import { Response, ServerRequest } from '@chubbyts/chubbyts-http-types/dist/message';const responseFactory = createResponseFactory();
const app = createApplication([
createErrorMiddleware(responseFactory, true),
createRouteMatcherMiddleware(
createPathToRegexpRouteMatcher(
createRoutesByName([
createGetRoute({
path: '/hello/:name([a-z]+)',
name: 'hello',
handler: async (request: ServerRequest): Promise => {
const response = responseFactory(200);
response.body.end(`Hello, ${request.attributes.name}`);return {
...response,
headers: { ...response.headers, 'content-type': ['text/plain'] }
};
},
}),
]),
),
),
]);
```### Server
#### Node
Running the application via the standard node http implementation.
```sh
npm i @chubbyts/chubbyts-http-node-bridge@^1.2.0
```Check the [Usage][10] section.
#### Uwebsockets
Running the application via the uwebsockets http implementation. Linux only. Faster than the node implemenation.
```sh
npm i @chubbyts/chubbyts-http-uwebsockets-bridge@^1.2.1
```Check the [Usage][11] section.
## Libraries
* [@chubbyts/chubbyts-api][20]
* [@chubbyts/chubbyts-decode-encode][21]
* [@chubbyts/chubbyts-dic][22]
* [@chubbyts/chubbyts-dic-config][23]
* [@chubbyts/chubbyts-http-cors][24]
* [@chubbyts/chubbyts-http-multipart][25]
* [@chubbyts/chubbyts-http-static-file][26]
* [@chubbyts/chubbyts-negotiation][27]## Skeleton
* [chubbyts/chubbyts-framework-skeleton][30]
* [chubbyts/chubbyts-petstore][31]## Copyright
2024 Dominik Zogg
[1]: https://www.npmjs.com/package/@chubbyts/chubbyts-framework
[2]: https://web-frameworks-benchmark.netlify.app/result
[3]: https://www.php-fig.org/psr/psr-15/#2-interfaces
[4]: https://www.npmjs.com/package/@chubbyts/chubbyts-dic-types
[5]: https://www.npmjs.com/package/@chubbyts/chubbyts-http-error
[6]: https://www.npmjs.com/package/@chubbyts/chubbyts-http-types
[7]: https://www.npmjs.com/package/@chubbyts/chubbyts-log-types
[8]: https://www.npmjs.com/package/@chubbyts/chubbyts-throwable-to-error[10]: https://www.npmjs.com/package/@chubbyts/chubbyts-http-node-bridge#usage
[11]: https://www.npmjs.com/package/@chubbyts/chubbyts-http-uwebsockets-bridge#usage[20]: https://www.npmjs.com/package/@chubbyts/chubbyts-api
[21]: https://www.npmjs.com/package/@chubbyts/chubbyts-decode-encode
[22]: https://www.npmjs.com/package/@chubbyts/chubbyts-dic
[23]: https://www.npmjs.com/package/@chubbyts/chubbyts-dic-config
[24]: https://www.npmjs.com/package/@chubbyts/chubbyts-http-cors
[25]: https://www.npmjs.com/package/@chubbyts/chubbyts-http-multipart
[26]: https://www.npmjs.com/package/@chubbyts/chubbyts-http-static-file
[27]: https://www.npmjs.com/package/@chubbyts/chubbyts-negotiation[30]: https://github.com/chubbyts/chubbyts-framework-skeleton
[31]: https://github.com/chubbyts/chubbyts-petstore