Skip to content

Commit 1dc1a25

Browse files
docs: add JSDoc documentation across the project
Co-authored-by: Junie <junie@jetbrains.com>
1 parent 0dbd1a9 commit 1dc1a25

13 files changed

Lines changed: 86 additions & 0 deletions

File tree

src/controller/BootApplicationFactory.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { ApplicationConfig } from "../domain/types";
22
import { BootApplication } from "../controller";
33

4+
/**
5+
* Factory for creating BootApplication instances.
6+
*/
47
export class BootApplicationFactory {
58
/**
69
* Creates an instance of BootApplication.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import { AppsScriptEventType } from "../../../domain/enums";
22
import { createAppsScriptDecorator } from "../../../repository";
33

4+
/**
5+
* Decorator for handling Google Apps Script onChange events.
6+
*/
47
export const OnChange = createAppsScriptDecorator(AppsScriptEventType.CHANGE);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import { AppsScriptEventType } from "../../../domain/enums";
22
import { createAppsScriptDecorator } from "../../../repository";
33

4+
/**
5+
* Decorator for handling Google Apps Script onEdit events.
6+
*/
47
export const OnEdit = createAppsScriptDecorator(AppsScriptEventType.EDIT);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import { AppsScriptEventType } from "../../../domain/enums";
22
import { createAppsScriptDecorator } from "../../../repository";
33

4+
/**
5+
* Decorator for handling Google Apps Script onFormSubmit events.
6+
*/
47
export const OnFormSubmit = createAppsScriptDecorator(AppsScriptEventType.FORM_SUBMIT);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import { AppsScriptEventType } from "../../../domain/enums";
22
import { createAppsScriptDecorator } from "../../../repository";
33

4+
/**
5+
* Decorator for handling Google Apps Script onInstall events.
6+
*/
47
export const OnInstall = createAppsScriptDecorator(AppsScriptEventType.INSTALL);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import { AppsScriptEventType } from "../../../domain/enums";
22
import { createAppsScriptDecorator } from "../../../repository";
33

4+
/**
5+
* Decorator for handling Google Apps Script onOpen events.
6+
*/
47
export const OnOpen = createAppsScriptDecorator(AppsScriptEventType.OPEN);

src/service/RequestFactory.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import { isString, normalize } from "apps-script-utils";
22
import { HttpHeaders, HttpRequest, ParsedUrl } from "../domain/types";
33
import { RequestMethod } from "../domain/enums";
44

5+
/**
6+
* Factory for creating structured HttpRequest objects.
7+
*/
58
export class RequestFactory {
69
/**
710
* Creates a structured HttpRequest object from a raw Apps Script DoGet or DoPost event.

src/service/Resolver.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,28 @@ import { PARAMTYPES_METADATA } from "../domain/constants";
55
import { getInjectionTokens } from "../repository";
66
import { isController, isInjectable } from "../shared/utils";
77

8+
/**
9+
* Dependency injection resolver.
10+
*/
811
export class Resolver {
12+
/**
13+
* Creates a new instance of Resolver.
14+
*
15+
* @param {Map<InjectionToken, unknown>} _controllers Registered controllers.
16+
* @param {Map<InjectionToken, unknown>} _providers Registered providers.
17+
*/
918
constructor(
1019
private readonly _controllers: Map<InjectionToken, unknown>,
1120
private readonly _providers: Map<InjectionToken, unknown>
1221
) {}
1322

23+
/**
24+
* Resolves a dependency by its injection token.
25+
*
26+
* @param {InjectionToken<T>} token The injection token.
27+
* @returns {T} The resolved instance.
28+
* @throws {Error} If the dependency cannot be resolved.
29+
*/
1430
public resolve<T>(token: InjectionToken<T>): T {
1531
if (this._controllers.has(token)) {
1632
const instance = this._controllers.get(token);

src/service/ResponseBuilder.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { HeaderAcceptMimeType, HttpStatus, RequestMethod } from "../domain/enums";
22
import { HttpHeaders, HttpRequest, HttpResponse } from "../domain/types";
33

4+
/**
5+
* Service for building and wrapping HTTP responses.
6+
*/
47
export class ResponseBuilder {
58
/**
69
* Creates a structured HttpResponse object.

src/service/Router.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,31 @@ import { RouteExecutionContext } from "../domain/entities";
1414
import { getInjectionTokens } from "../repository";
1515
import { PathMatcher, Resolver } from "../service";
1616

17+
/**
18+
* Router service for handling HTTP requests and dispatching them to controllers.
19+
*/
1720
export 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

Comments
 (0)