refactor(types): unify handler and middleware definitions
- Consolidates `Handler` and `Middleware` types under `Types` module - Replaces `IHandler` and `IMiddleware` interfaces with typed functions - Simplifies imports and improves code organization - Enhances debugging with named handlers and middlewares
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
import {
|
||||
IContext,
|
||||
IHandler,
|
||||
IHttpKernel,
|
||||
IHttpKernelConfig,
|
||||
IInternalRoute,
|
||||
IMiddleware,
|
||||
IRouteBuilder,
|
||||
IRouteDefinition,
|
||||
isHandler,
|
||||
isMiddleware,
|
||||
} from './Interfaces/mod.ts';
|
||||
import {
|
||||
DeepPartial,
|
||||
Handler,
|
||||
HTTP_404_NOT_FOUND,
|
||||
HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
HttpStatusTextMap,
|
||||
isHandler,
|
||||
isMiddleware,
|
||||
Middleware,
|
||||
} from './Types/mod.ts';
|
||||
import { RouteBuilder } from './RouteBuilder.ts';
|
||||
import { createEmptyContext, normalizeError } from './Utils/mod.ts';
|
||||
@@ -151,8 +151,8 @@ export class HttpKernel<TContext extends IContext = IContext>
|
||||
*/
|
||||
private async executePipeline(
|
||||
ctx: TContext,
|
||||
middleware: IMiddleware<TContext>[],
|
||||
handler: IHandler<TContext>,
|
||||
middleware: Middleware<TContext>[],
|
||||
handler: Handler<TContext>,
|
||||
): Promise<Response> {
|
||||
const handleInternalError = (ctx: TContext, err?: unknown) =>
|
||||
this.cfg.httpErrorHandlers[HTTP_500_INTERNAL_SERVER_ERROR](
|
||||
|
Reference in New Issue
Block a user