14 lines
521 B
TypeScript
14 lines
521 B
TypeScript
import type { AuthService } from './AuthService';
|
|
import { InMemoryAuthService } from './InMemoryAuthService';
|
|
import { getDIContainer } from '../di-container';
|
|
import { DI_TOKENS } from '../di-tokens';
|
|
|
|
export function getAuthService(): AuthService {
|
|
const container = getDIContainer();
|
|
if (!container.isRegistered(DI_TOKENS.AuthService)) {
|
|
throw new Error(
|
|
`${DI_TOKENS.AuthService.description} not registered in DI container.`,
|
|
);
|
|
}
|
|
return container.resolve<AuthService>(DI_TOKENS.AuthService);
|
|
} |