homebox/backend/app/api/app.go
Hayden cd82fe0d89
refactor: remove empty services (#116)
* remove empty services

* remove old factory

* remove old static files

* cleanup more duplicate service code

* file/folder reorg
2022-10-29 20:05:38 -08:00

44 lines
930 B
Go

package main
import (
"time"
"github.com/hay-kot/homebox/backend/internal/core/services"
"github.com/hay-kot/homebox/backend/internal/data/ent"
"github.com/hay-kot/homebox/backend/internal/data/repo"
"github.com/hay-kot/homebox/backend/internal/sys/config"
"github.com/hay-kot/homebox/backend/pkgs/mailer"
"github.com/hay-kot/homebox/backend/pkgs/server"
)
type app struct {
conf *config.Config
mailer mailer.Mailer
db *ent.Client
server *server.Server
repos *repo.AllRepos
services *services.AllServices
}
func new(conf *config.Config) *app {
s := &app{
conf: conf,
}
s.mailer = mailer.Mailer{
Host: s.conf.Mailer.Host,
Port: s.conf.Mailer.Port,
Username: s.conf.Mailer.Username,
Password: s.conf.Mailer.Password,
From: s.conf.Mailer.From,
}
return s
}
func (a *app) startBgTask(t time.Duration, fn func()) {
for {
a.server.Background(fn)
time.Sleep(t)
}
}