@@ -2,138 +2,117 @@ import { IMiddleware } from "../Middleware/IMiddleware";
22import { IView } from "../View/View" ;
33
44export default class Route {
5- // /**
6- // @param {string } verb
7- // @param {string } pattern
8- // @param {function|[function, string] } action
9- // */
10- // static addRoute(verb: string, pattern: string, action: Function | [Function, string]): typeof Route;
115 /**
12- * Check if route exists.
13- */
14- /**
15- *
166 * Check if route exists.
17- * @param {string } name
7+ * @param name - The route name to check
8+ * @returns True if the route exists, false otherwise
189 */
1910 static has ( name : string ) : boolean ;
20- /**
21- * Add a get route that renders a view.
22- */
23- /**
24- *
25- * Add a get route that renders a view.
2611
27- @param {string } path
28- @param {View } view
29- @param {object } data
30- @param {number|null } statusCode
31- */
32- static view ( path : string , view : IView , data ?: object , statusCode ?: number | null ) : typeof Route ;
33- /**
34- * Add a delete route.
35- */
3612 /**
37- *
38- * Add a delete route.
13+ * Add a GET route that renders a view.
14+ * @param path - The route path
15+ * @param view - The view to render
16+ * @param data - Optional data to pass to the view
17+ * @param statusCode - Optional HTTP status code
18+ * @returns The Route class for method chaining
19+ */
20+ static view ( path : string , view : IView , data ?: object , statusCode ?: number | null ) : typeof Route ;
3921
40- @param {string } path
41- @param {function|[function, string] } action
42- */
43- static delete ( path : string , action : Function | [ Function , string ] ) : typeof Route ;
44- /**
45- * Add a get route.
46- */
4722 /**
48- *
49- * Add a get route.
23+ * Add a DELETE route.
24+ * @param path - The route path
25+ * @param action - The route handler function or [function, method] tuple
26+ * @returns The Route class for method chaining
27+ */
28+ static delete ( path : string , action : Function | [ Function , string ] ) : typeof Route ;
5029
51- @param {string } path
52- @param {function|[function, string] } action
53- */
54- static get ( path : string , action : Function | [ Function , string ] ) : typeof Route ;
5530 /**
56- * Add a options route.
57- */
58- /**
59- *
60- * Add a options route.
31+ * Add a GET route.
32+ * @param path - The route path
33+ * @param action - The route handler function or [function, method] tuple
34+ * @returns The Route class for method chaining
35+ */
36+ static get ( path : string , action : Function | [ Function , string ] ) : typeof Route ;
6137
62- @param {string } path
63- @param {function|[function, string] } action
64- */
65- static options ( path : string , action : Function | [ Function , string ] ) : typeof Route ;
66- /**
67- * Add a patch route.
68- */
6938 /**
70- *
71- * Add a patch route.
39+ * Add an OPTIONS route.
40+ * @param path - The route path
41+ * @param action - The route handler function or [function, method] tuple
42+ * @returns The Route class for method chaining
43+ */
44+ static options ( path : string , action : Function | [ Function , string ] ) : typeof Route ;
7245
73- @param {string } path
74- @param {function|[function, string] } action
75- */
76- static patch ( path : string , action : Function | [ Function , string ] ) : typeof Route ;
77- /**
78- * Add a post route.
79- */
8046 /**
81- *
82- * Add a post route.
47+ * Add a PATCH route.
48+ * @param path - The route path
49+ * @param action - The route handler function or [function, method] tuple
50+ * @returns The Route class for method chaining
51+ */
52+ static patch ( path : string , action : Function | [ Function , string ] ) : typeof Route ;
8353
84- @param {string } path
85- @param {function|[function, string] } action
86- */
87- static post ( path : string , action : Function | [ Function , string ] ) : typeof Route ;
88- /**
89- * Add a put route.
90- */
9154 /**
92- *
93- * Add a put route.
55+ * Add a POST route.
56+ * @param path - The route path
57+ * @param action - The route handler function or [function, method] tuple
58+ * @returns The Route class for method chaining
59+ */
60+ static post ( path : string , action : Function | [ Function , string ] ) : typeof Route ;
9461
95- @param {string } path
96- @param {function|[function, string] } action
97- */
98- static put ( path : string , action : Function | [ Function , string ] ) : typeof Route ;
99- /**
100- * Set route name.
101- */
10262 /**
103- *
104- * Set route name.
63+ * Add a PUT route.
64+ * @param path - The route path
65+ * @param action - The route handler function or [function, method] tuple
66+ * @returns The Route class for method chaining
67+ */
68+ static put ( path : string , action : Function | [ Function , string ] ) : typeof Route ;
10569
106- @param {string } name
107- */
108- static name ( name : string ) : typeof Route ;
10970 /**
110- * Add middleware to route.
111- */
112- /**
113- *
114- * Add middleware to route.
71+ * Add a route that matches any HTTP method.
72+ * @param path - The route path
73+ * @param action - The route handler function or [function, method] tuple
74+ * @returns The Route class for method chaining
75+ */
76+ static any ( path : string , action : Function | [ Function , string ] ) : typeof Route ;
11577
116- @param {string | IMiddleware | Array<string|IMiddleware> } name
117- */
118- static middleware ( name : string | IMiddleware | Array < string | IMiddleware > ) : typeof Route ;
11978 /**
120- * Add grouped routes.
121- */
79+ * Set route name.
80+ * @param name - The name to assign to the route
81+ * @returns The Route class for method chaining
82+ */
83+ static name ( name : string ) : typeof Route ;
84+
12285 /**
123- *
124- * Add grouped routes.
86+ * Add middleware to route.
87+ * @param name - The middleware name, instance, or array of middleware
88+ * @returns The Route class for method chaining
89+ */
90+ static middleware ( name : string | IMiddleware | Array < string | IMiddleware > ) : typeof Route ;
12591
126- @param {function } callable
127- */
92+ /**
93+ * Add grouped routes.
94+ * @param options - Group configuration options
95+ * @param callable - Function containing the grouped routes
96+ */
12897 static group ( options : GroupOptions , callable : Function ) : void ;
98+
99+ /**
100+ * Get all registered routes.
101+ * @returns Array of all registered routes
102+ */
129103 static all ( ) : any [ ] ;
130104}
131105
132106export type GroupOptions = {
133- prefix : string ;
134- middleware : IMiddleware | string | Array < IMiddleware | string > ;
107+ prefix : string ;
108+ middleware : IMiddleware | string | Array < IMiddleware | string > ;
109+ domain ?: string ;
110+ } | {
111+ prefix : string ;
112+ domain ?: string ;
135113} | {
136- prefix : string ;
114+ middleware : IMiddleware | string | Array < IMiddleware | string > ;
115+ domain ?: string ;
137116} | {
138- middleware : IMiddleware | string | Array < IMiddleware | string > ;
117+ domain : string ;
139118}
0 commit comments