mirror of
https://github.com/morten-olsen/homelab-operator.git
synced 2026-02-08 01:36:28 +01:00
init
This commit is contained in:
3
src/utils/consts.ts
Normal file
3
src/utils/consts.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
const GROUP = 'homelab.mortenolsen.pro';
|
||||
|
||||
export { GROUP };
|
||||
23
src/utils/service.ts
Normal file
23
src/utils/service.ts
Normal 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 };
|
||||
Reference in New Issue
Block a user