Skip to content

Commit

Permalink
Api gateway middleware (#95)
Browse files Browse the repository at this point in the history
* Adds API Gateway Middleware. Adds method to define custom middleware. Adds support for MiddlewareDefinitions
  • Loading branch information
chrisradek authored and srchase committed Jun 16, 2023
1 parent 38975a6 commit 2ee20c7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/middleware-stack/src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ describe('MiddlewareStack', () => {
const stack = new MiddlewareStack<input, output>();
stack.add(
concatMiddleware.bind(null, 'not removed'),
{tags: new Set(['foo', 'bar'])}
{tags: {foo: true, bar: true}}
);
stack.add(
concatMiddleware.bind(null, 'remove me!'),
{tags: new Set(['foo', 'bar', 'baz'])}
{tags: {foo: true, bar: true, baz: true}}
);

await stack.resolve(
Expand Down
4 changes: 2 additions & 2 deletions packages/middleware-stack/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface HandlerListEntry<
step: Step;
priority: number;
middleware: Middleware<Input, Output>;
tags?: Set<string>;
tags?: {[tag: string]: any};
}

export class MiddlewareStack<
Expand Down Expand Up @@ -101,7 +101,7 @@ export class MiddlewareStack<
private removeByTag(toRemove: string) {
for (let i = this.entries.length - 1; i >= 0; i--) {
const {tags} = this.entries[i];
if (tags && tags.has(toRemove)) {
if (tags && toRemove in tags) {
this.entries.splice(i, 1);
}
}
Expand Down

0 comments on commit 2ee20c7

Please sign in to comment.