Skip to content

Commit de36d4c

Browse files
feat(interface): add MiddlewareShape.`
1 parent 1a56bbb commit de36d4c

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/interface/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type { MiddlewareShape } from './middleware.shape';

src/interface/middleware.shape.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @description The shape of a middleware system.
3+
* @export
4+
* @interface MiddlewareShape
5+
* @typedef {MiddlewareShape}
6+
* @template [Input=any] The type of the arguments passed to middleware functions.
7+
* @template [Output=any] The type of the output returned by middleware functions.
8+
* @template [Middleware=any] The type of the middleware.
9+
*/
10+
export interface MiddlewareShape<Input = any, Output = any, Middleware = any> {
11+
execute(context: Input): void;
12+
execute(...args: Input[]): void;
13+
use(middleware: Middleware): this;
14+
executeAsync(context: Input): Promise<Output>; // Or Promise<Output> if defined
15+
executeAsync(...args: Input[]): Promise<Output>; // Or Promise<Output> if defined
16+
}

0 commit comments

Comments
 (0)