@chubbyts/chubbyts-framework
Version:
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.
19 lines (18 loc) • 955 B
JavaScript
import { pipe } from '@chubbyts/chubbyts-undici-server/dist/server';
import { createRouteHandler } from './handler/route-handler.js';
/**
* ```ts
* import type { Middleware } from '@chubbyts/chubbyts-undici-server/dist/server';
* import { createErrorMiddleware } from '@chubbyts/chubbyts-framework/dist/middleware/error-middleware';
* import { createRouteMatcherMiddleware } from '@chubbyts/chubbyts-framework/dist/middleware/route-matcher-middleware';
* import { createApplication } from '@chubbyts/chubbyts-framework/dist/application';
*
* const errorMiddleware: Middleware = createErrorMiddleware(...);
* const routeMatcherMiddleware: Middleware = createRouteMatcherMiddleware(...);
*
* const application = createApplication([ errorMiddleware, routeMatcherMiddleware ]);
* ```
*/
export const createApplication = (middlewares, handler = createRouteHandler()) => {
return (serverRequest) => pipe(middlewares)(serverRequest, handler);
};