import { createContainer } from "iti"
interface Logger { info: (msg: string) => void }
class ConsoleLogger implements Logger { info(msg: string): void { console.log("[Console]:", msg) } }
class PinoLogger implements Logger { info(msg: string): void { console.log("[Pino]:" , msg) } }
async getUserData(): Promise<UserData> {
return { name: "Big Lebowski" }
constructor(private data: UserData) {}
name = () => this.data.name
constructor(private readonly logger: Logger, private readonly user: User) {}
this.logger.info(`Sending monery to the: ${this.user.name()} `)
export async function runMyApp() {
const root = createContainer()
process.env.NODE_ENV === "production"
.add({ auth: new AuthService() })
user: async () => new User(await ctx.auth.getUserData()),
paymentService: async () =>
new PaymentService(ctx.logger, await ctx.user),
const ps = await root.items.paymentService
console.log(" ---- My App START \n\n")
console.log("\n\n ---- My App END")