import {Config, Inject, ORMUser, Singleton, Unit} from '@extollo/lib'
import {User} from './models/User.model'
import {Gotify} from 'gotify'

@Singleton()
export class AppUnit extends Unit {
    @Inject()
    protected readonly config!: Config

    async up(): Promise<void> {
        this.container().registerStaticOverride(ORMUser, User)

        const gotify = new Gotify({
            server: this.config.safe('gotify.server').string(),
        })

        this.container().registerSingletonInstance(Gotify, gotify)
    }
}
