/[sudobot]/trunk/src/api/Route.ts
ViewVC logotype

Annotation of /trunk/src/api/Route.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 323 - (hide annotations)
Mon Jul 29 17:29:32 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: application/typescript
File size: 525 byte(s)
feat: add basic server and routing
1 rakin 323 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     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26