HttpHandler.ts 578 B

12345678910111213141516171819202122232425262728
  1. abstract class HttpHandler {
  2. protected abstract route: string | null;
  3. protected abstract action: (...any: any[]) => any;
  4. protected context: any;
  5. public constructor(context: Record<string, any>) {
  6. this.context = context ?? null;
  7. }
  8. public setContext(context: Record<string, any>): HttpHandler {
  9. this.context = context;
  10. return this;
  11. }
  12. public getContext(): Record<string, any> {
  13. return this.context;
  14. }
  15. public getRoute(): string | null {
  16. return this.route;
  17. }
  18. public getAction(): (...any: any[]) => any {
  19. return this.action;
  20. }
  21. }
  22. export { HttpHandler };