Created
January 7, 2021 21:03
-
-
Save itshaadi/395b5ee29c0cd5d4da1dc220b6c3fc7e to your computer and use it in GitHub Desktop.
Definition of an execution unit that can panic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CanPanic implements ExecutionUnit { | |
next: ExecutionUnit | null; | |
pipeline: IAPPipeline; | |
constructor(pipeline: IAPPipeline) { | |
this.next = null; | |
this.pipeline = pipeline; | |
} | |
setNext(next: ExecutionUnit): void { | |
this.next = next; | |
} | |
async exec(req: Request, res: Response): Promise<void | never> { | |
await this.pipeline(req, res); | |
if (this.next !== null) { | |
await this.next.exec(req, res); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment