Skip to content
app.go 571 B
Newer Older
Lo^2's avatar
Lo^2 committed
package importer

import (
	"code.electrolab.fr/it/vote.electrolab.fr/service/db"
	"code.electrolab.fr/it/vote.electrolab.fr/service/email"
	"context"
)

type App struct {
	Config  AppConfig
	Service AppServices
	Context context.Context
}

func NewApp(config *AppConfig) (*App, error) {
	app := new(App)
	app.Context = context.Background()
	app.Config = *config
	app.Service.DB = db.NewDBPostgres(app.Config.Database.Connection)
	err := app.Service.DB.Start()
	if err != nil {
		return nil, err
	}

	app.Service.Email = email.NewSmtp(app.Config.Email)
	return app, nil
}