refactor(httpkernel): introduce configuration object for flexibility
- Replace individual constructor arguments with a configuration object. - Add IHttpKernelConfig interface to standardize configuration structure. - Refactor route builder and response decorator usage to use config. - Simplify code and improve extensibility by consolidating parameters. Signed-off-by: Max P. <Mail@MPassarello.de>
This commit is contained in:
8
src/Interfaces/HttpKernelConfig.ts
Normal file
8
src/Interfaces/HttpKernelConfig.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { ResponseDecorator } from '../Types/mod.ts';
|
||||
import { IContext } from './IContext.ts';
|
||||
import { IRouteBuilderFactory } from './IRouteBuilder.ts';
|
||||
|
||||
export interface IHttpKernelConfig<TContext extends IContext = IContext> {
|
||||
decorateResponse: ResponseDecorator<TContext>;
|
||||
routeBuilderFactory: IRouteBuilderFactory;
|
||||
}
|
||||
@@ -4,12 +4,12 @@ import { IMiddleware } from './IMiddleware.ts';
|
||||
import { IRouteDefinition } from './IRouteDefinition.ts';
|
||||
import { IContext } from './mod.ts';
|
||||
|
||||
export interface IRouteBuilderFactory {
|
||||
export interface IRouteBuilderFactory<TContext extends IContext = IContext> {
|
||||
new (
|
||||
registerRoute: (route: IInternalRoute) => void,
|
||||
registerRoute: (route: IInternalRoute<TContext>) => void,
|
||||
def: IRouteDefinition,
|
||||
mws?: IMiddleware[],
|
||||
): IRouteBuilder;
|
||||
mws?: IMiddleware<TContext>[],
|
||||
): IRouteBuilder<TContext>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// deno-coverage-ignore-file
|
||||
|
||||
export type { IHttpKernelConfig } from './HttpKernelConfig.ts';
|
||||
export type { IContext } from './IContext.ts';
|
||||
export type { IHandler } from './IHandler.ts';
|
||||
export type { IHttpKernel } from './IHttpKernel.ts';
|
||||
|
||||
Reference in New Issue
Block a user