di usage in website
This commit is contained in:
34
apps/website/lib/di/modules/core.module.ts
Normal file
34
apps/website/lib/di/modules/core.module.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
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());
|
||||
});
|
||||
Reference in New Issue
Block a user