♻️ Refactor config

Make it easier to setup stores
This commit is contained in:
Dan Jones 2025-01-26 20:07:45 -06:00
commit 6f06adc37d
12 changed files with 623 additions and 81 deletions

10
app.go
View file

@ -27,7 +27,7 @@ type App struct {
}
func NewApp(ver string, conf config.Config, db store.Store) (*App, error) {
if conf.BaseURL == "" {
if conf.BaseURL() == "" {
return nil, errors.New("missing BaseURL")
}
app := App{
@ -35,7 +35,7 @@ func NewApp(ver string, conf config.Config, db store.Store) (*App, error) {
conf: conf,
}
selfIRI := boxap.DefaultServiceIRI(conf.BaseURL)
selfIRI := boxap.DefaultServiceIRI(conf.BaseURL())
self := boxap.Self(selfIRI)
self.Name = vocab.DefaultNaturalLanguageValue(app.Name())
self.AttributedTo = vocab.IRI(config.DevUrl)
@ -54,7 +54,7 @@ func (l *App) Config() config.Config {
}
func (l *App) Environment() config.Env {
return l.conf.Environment()
return l.conf.Env()
}
func (l *App) Storage() store.Store {
@ -78,10 +78,10 @@ func (l *App) Version() string {
}
func (l *App) Name() string {
if l.conf.Name == "" {
if l.conf.Name() == "" {
return "Lenore"
}
return l.conf.Name
return l.conf.Name()
}
func (l *App) String() string {