generated from curium-rocks/kube-starter-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
inversify.config.ts
34 lines (28 loc) · 1014 Bytes
/
inversify.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import "reflect-metadata"
import { Container, interfaces } from "inversify"
import { TYPES } from "./types"
import { Echo, IEcho } from "./services/echo"
import { IEchoConfig } from "./models/echoConfig"
import config from "config"
import { Logger, LoggerOptions } from "pino"
import { ILoggerFactory, LoggerFactory } from "./logger/logger"
const appContainer = new Container()
appContainer.bind<IEcho>(TYPES.Services.Echo).to(Echo)
appContainer
.bind<IEchoConfig>(TYPES.Configurations.Echo)
.toConstantValue(config.get<IEchoConfig>("echo"))
appContainer
.bind<LoggerOptions>(TYPES.Configurations.Logger)
.toConstantValue(config.get<LoggerOptions>("logger"))
appContainer
.bind<ILoggerFactory>(TYPES.Factories.LoggerFactory)
.to(LoggerFactory)
appContainer
.bind<Logger>(TYPES.Logger)
.toDynamicValue((ctx: interfaces.Context) => {
const factory = ctx.container.get<ILoggerFactory>(
TYPES.Factories.LoggerFactory
)
return factory.createLogger()
})
export { appContainer }