1 |
export default class Route { |
2 |
constructor(public readonly method: string, public readonly path: string, public readonly callback: [Object, string], public middlewareList: Array<Object> = []) { |
3 |
|
4 |
} |
5 |
|
6 |
middleware(...middleware: Object[]) { |
7 |
this.middlewareList = [...this.middlewareList, ...middleware]; |
8 |
} |
9 |
|
10 |
getCallbackFunction(...args: any[]) { |
11 |
const [controller, method] = this.callback; |
12 |
return () => (controller as { [key: string]: Function })[method].call(controller, ...args); |
13 |
} |
14 |
} |