36 lines
827 B
TypeScript
36 lines
827 B
TypeScript
|
|
import {
|
||
|
|
IRepositoryManager,
|
||
|
|
RepositoryManager,
|
||
|
|
} from "@/contexts/common/domain";
|
||
|
|
import {
|
||
|
|
ISequelizeAdapter,
|
||
|
|
createSequelizeAdapter,
|
||
|
|
} from "@/contexts/common/infrastructure/sequelize";
|
||
|
|
|
||
|
|
export interface IUserContext {
|
||
|
|
adapter: ISequelizeAdapter;
|
||
|
|
repositoryManager: IRepositoryManager;
|
||
|
|
//services: IApplicationService;
|
||
|
|
}
|
||
|
|
|
||
|
|
export class UserContext {
|
||
|
|
private static instance: UserContext | null = null;
|
||
|
|
|
||
|
|
public static getInstance(): IUserContext {
|
||
|
|
if (!UserContext.instance) {
|
||
|
|
UserContext.instance = new UserContext({
|
||
|
|
adapter: createSequelizeAdapter(),
|
||
|
|
repositoryManager: RepositoryManager.getInstance(),
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
return UserContext.instance.context;
|
||
|
|
}
|
||
|
|
|
||
|
|
private context: IUserContext;
|
||
|
|
|
||
|
|
private constructor(context: IUserContext) {
|
||
|
|
this.context = context;
|
||
|
|
}
|
||
|
|
}
|