@@ -14,14 +14,31 @@ import { RouteExecutionContext } from "../domain/entities";
1414import { getInjectionTokens } from "../repository" ;
1515import { PathMatcher , Resolver } from "../service" ;
1616
17+ /**
18+ * Router service for handling HTTP requests and dispatching them to controllers.
19+ */
1720export class Router {
1821 private readonly pathMatcher = new PathMatcher ( ) ;
1922
23+ /**
24+ * Creates a new instance of Router.
25+ *
26+ * @param {Resolver } _resolver The dependency resolver.
27+ * @param {RouteMetadata[] } _routes The registered routes.
28+ */
2029 constructor (
2130 private readonly _resolver : Resolver ,
2231 private readonly _routes : RouteMetadata [ ]
2332 ) { }
2433
34+ /**
35+ * Handles an incoming HTTP request.
36+ *
37+ * @param {HttpRequest } request The HTTP request object.
38+ * @param {GoogleAppsScript.Events.DoGet | GoogleAppsScript.Events.DoPost } event The Apps Script event object.
39+ * @param {Function } responseBuilder A function to build an HTTP response.
40+ * @returns {Promise<HttpResponse> } A promise that resolves to the HTTP response.
41+ */
2542 public async handle (
2643 request : HttpRequest ,
2744 event : GoogleAppsScript . Events . DoGet | GoogleAppsScript . Events . DoPost ,
@@ -79,6 +96,14 @@ export class Router {
7996 }
8097 }
8198
99+ /**
100+ * Builds the parameters for a controller method based on the route execution context.
101+ *
102+ * @param {object } target The target object.
103+ * @param {string | symbol } propertyKey The name of the property.
104+ * @param {RouteExecutionContext } ctx The route execution context.
105+ * @returns {unknown[] } An array of parameters for the method.
106+ */
82107 private buildMethodParams (
83108 target : object ,
84109 propertyKey : string | symbol ,
0 commit comments