feat: init project

This commit is contained in:
M1000fr
2026-01-10 17:27:30 +01:00
parent d02e52aed5
commit 00fb21c558
22 changed files with 957 additions and 5 deletions

View File

@@ -0,0 +1,36 @@
import type { Container } from "../container/Container";
import type { ProviderToken } from "../container/types";
/**
* AlveoApplication is the main class representing an Alveo application instance.
* It provides methods to interact with the dependency injection container and manage the application lifecycle.
*/
export class AlveoApplication {
constructor(private readonly container: Container) {}
/**
* Retrieves an instance of a provider from the application container.
*
* @param token The provider token (Class, String, or Symbol)
* @returns A promise resolving to the instance of the provider
*/
public async get<T>(token: ProviderToken<T>): Promise<T> {
return this.container.get(token);
}
/**
* Initializes the application by calling onModuleInit hooks on all providers.
* This is called automatically by AlveoFactory.create().
*/
public async init(): Promise<this> {
await this.container.callLifecycleHook("onModuleInit");
return this;
}
/**
* Gracefully shuts down the application by calling onModuleDestroy hooks.
*/
public async close(): Promise<void> {
await this.container.callLifecycleHook("onModuleDestroy");
}
}