Migrate test/index.ts to use dynamic database imports

Replace static databaseUtil import with dynamic import pattern for test context.
Add comprehensive JSDoc documentation and improve code formatting.
Maintains functionality while removing static dependency.
This commit is contained in:
Matthew Raymer
2025-07-09 10:07:49 +00:00
parent f79454c8b5
commit 190b6c7f03
8 changed files with 491 additions and 18 deletions

View File

@@ -50,8 +50,9 @@ import {
routeSchema,
DeepLinkRoute,
} from "../interfaces/deepLinks";
import { logConsoleAndDb } from "../db/databaseUtil";
// Legacy databaseUtil import removed - using logger instead
import type { DeepLinkError } from "../interfaces/deepLinks";
import { logger } from "../utils/logger";
/**
* Handles processing and routing of deep links in the application.
@@ -173,7 +174,7 @@ export class DeepLinkHandler {
routeName = this.ROUTE_MAP[validRoute].name;
} catch (error) {
// Log the invalid route attempt
logConsoleAndDb(`[DeepLink] Invalid route path: ${path}`, true);
logger.error(`[DeepLink] Invalid route path: ${path}`);
// Redirect to error page with information about the invalid link
await this.router.replace({
@@ -235,7 +236,7 @@ export class DeepLinkHandler {
*/
async handleDeepLink(url: string): Promise<void> {
try {
logConsoleAndDb("[DeepLink] Processing URL: " + url, false);
logger.info("[DeepLink] Processing URL: " + url);
const { path, params, query } = this.parseDeepLink(url);
// Ensure params is always a Record<string,string> by converting undefined to empty string
const sanitizedParams = Object.fromEntries(
@@ -244,9 +245,8 @@ export class DeepLinkHandler {
await this.validateAndRoute(path, sanitizedParams, query);
} catch (error) {
const deepLinkError = error as DeepLinkError;
logConsoleAndDb(
logger.error(
`[DeepLink] Error (${deepLinkError.code}): ${deepLinkError.message}`,
true,
);
throw {