This commit is contained in:
Morten Olsen
2025-07-28 22:24:51 +02:00
commit b35782a7d8
28 changed files with 3186 additions and 0 deletions

3
src/utils/consts.ts Normal file
View File

@@ -0,0 +1,3 @@
const GROUP = 'homelab.mortenolsen.pro';
export { GROUP };

23
src/utils/service.ts Normal file
View File

@@ -0,0 +1,23 @@
import { LogService } from "../services/log/log.ts";
type Dependency<T> = new (services: Services) => T;
class Services {
#instances: Map<Dependency<unknown>, unknown> = new Map();
constructor() {
console.log('Constructor', 'bar');
}
public get log() {
return this.get(LogService);
}
get = <T>(dependency: Dependency<T>): T => {
if (!this.#instances.has(dependency)) {
this.#instances.set(dependency, new dependency(this));
}
return this.#instances.get(dependency) as T;
}
}
export { Services };