Files
gridpilot.gg/apps/website/lib/di/modules/core.module.ts
2026-01-06 19:36:03 +01:00

34 lines
1.0 KiB
TypeScript

import { ContainerModule } from 'inversify';
import { EnhancedErrorReporter } from '../../infrastructure/EnhancedErrorReporter';
import { ConsoleLogger } from '../../infrastructure/logging/ConsoleLogger';
import { getWebsiteApiBaseUrl } from '../../config/apiBaseUrl';
import {
LOGGER_TOKEN,
ERROR_REPORTER_TOKEN,
CONFIG_TOKEN
} from '../tokens';
export const CoreModule = new ContainerModule((options) => {
const bind = options.bind;
// Logger
bind<ConsoleLogger>(LOGGER_TOKEN)
.to(ConsoleLogger)
.inSingletonScope();
// Error Reporter
bind<EnhancedErrorReporter>(ERROR_REPORTER_TOKEN)
.toDynamicValue((context) => {
const logger = context.get<ConsoleLogger>(LOGGER_TOKEN);
return new EnhancedErrorReporter(logger, {
showUserNotifications: true,
logToConsole: true,
reportToExternal: process.env.NODE_ENV === 'production',
});
})
.inSingletonScope();
// Config
bind<string>(CONFIG_TOKEN)
.toConstantValue(getWebsiteApiBaseUrl());
});