Skip to content

Commit

Permalink
chore: updates
Browse files Browse the repository at this point in the history
  • Loading branch information
tianyingchun committed Jul 1, 2024
1 parent cee171a commit c0010da
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/Pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Middleware } from './types.js';
* A middleware container and invoker
*/
export class Pipeline<T> {
middlewares: Middleware<T>[];
private middlewares: Middleware<T>[];

constructor(...middlewares: Middleware<T>[]) {
this.middlewares = middlewares;
Expand All @@ -14,15 +14,16 @@ export class Pipeline<T> {
/**
* Add a middleware function.
*/
use(...mw: Middleware<T>[]): void {
use(...mw: Middleware<T>[]): Pipeline<T> {
this.middlewares.push(...mw);
return this;
}

/**
* Execute the chain of middlewares, in the order they were added on a
* given Context.
*/
execute(context: T): Promise<void> {
return invokeMiddlewares(context, this.middlewares);
return invokeMiddlewares<T>(context, this.middlewares);
}
}
1 change: 0 additions & 1 deletion tests/pipeline.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ describe('Pipeline tests', () => {
ctx.foobar = 'baz';
next();
});

engine.use(
async () => {
throw new Error('This is an error');
Expand Down

0 comments on commit c0010da

Please sign in to comment.