website refactor

This commit is contained in:
2026-01-14 02:02:24 +01:00
parent 8d7c709e0c
commit 4522d41aef
291 changed files with 12763 additions and 9309 deletions

View File

@@ -1,5 +1,3 @@
import { ContainerManager } from '@/lib/di/container';
export interface FetchResult<T> {
data: T | null;
errors: Record<string, Error>;
@@ -7,31 +5,10 @@ export interface FetchResult<T> {
}
export class PageDataFetcher {
/**
* Fetch data using DI container
* Use for: Simple SSR pages with single service
* WARNING: Container is singleton - avoid stateful services
*/
static async fetch<TService, TMethod extends keyof TService>(
ServiceToken: string | symbol,
method: TMethod,
...args: TService[TMethod] extends (...params: infer P) => Promise<infer R> ? P : never
): Promise<(TService[TMethod] extends (...params: any[]) => Promise<infer R> ? R : never) | null> {
try {
const container = ContainerManager.getInstance().getContainer();
const service = container.get<TService>(ServiceToken);
const result = await (service[method] as Function)(...args);
return result;
} catch (error) {
console.error(`Failed to fetch: ${String(ServiceToken)}.${String(method)}`, error);
return null;
}
}
/**
* Fetch using manual service instantiation
* Use for: Multiple dependencies, request-scoped services, or auth context
* RECOMMENDED for SSR over fetch() with DI
* RECOMMENDED for SSR
*/
static async fetchManual<TData>(
serviceFactory: () => Promise<TData> | TData
@@ -84,4 +61,4 @@ export class PageDataFetcher {
hasErrors: Object.keys(errors).length > 0
};
}
}
}