31 lines
931 B
TypeScript
31 lines
931 B
TypeScript
import { ContainerModule } from 'inversify';
|
|
import { AuthService } from '../../services/auth/AuthService';
|
|
import { SessionService } from '../../services/auth/SessionService';
|
|
import { AuthApiClient } from '../../api/auth/AuthApiClient';
|
|
|
|
import {
|
|
AUTH_SERVICE_TOKEN,
|
|
SESSION_SERVICE_TOKEN,
|
|
AUTH_API_CLIENT_TOKEN
|
|
} from '../tokens';
|
|
|
|
export const AuthModule = new ContainerModule((options) => {
|
|
const bind = options.bind;
|
|
|
|
// Session Service
|
|
bind<SessionService>(SESSION_SERVICE_TOKEN)
|
|
.toDynamicValue((ctx) => {
|
|
const authApiClient = ctx.get<AuthApiClient>(AUTH_API_CLIENT_TOKEN);
|
|
return new SessionService(authApiClient);
|
|
})
|
|
.inSingletonScope();
|
|
|
|
// Auth Service
|
|
bind<AuthService>(AUTH_SERVICE_TOKEN)
|
|
.toDynamicValue((ctx) => {
|
|
const authApiClient = ctx.get<AuthApiClient>(AUTH_API_CLIENT_TOKEN);
|
|
return new AuthService(authApiClient);
|
|
})
|
|
.inSingletonScope();
|
|
});
|