diff --git a/.woodpecker/playwright.yaml b/.woodpecker/playwright.yaml index ba450cb..e47e5de 100644 --- a/.woodpecker/playwright.yaml +++ b/.woodpecker/playwright.yaml @@ -11,8 +11,8 @@ services: ports: - 8080 environment: + DUMMY_DATABASE: 1 WEB_PUBLIC_REGISTRATION: 1 - USERSTORE_SQLITE_PATH: file:/tmp/miniauth.db steps: - name: playwright diff --git a/Readme.md b/Readme.md index 5c234c2..fd80947 100644 --- a/Readme.md +++ b/Readme.md @@ -5,6 +5,7 @@ | Name | Description | Default | |------|-------------|---------| +| DUMMY_DATABASE | Setup a new sqlite with the struct but no data for dev and test only | false | | USERSTORE_SQLITE_PATH | Path to the Sqlite Database | `none` | | PORT | Port for the Webserver | 8080 | | SMTP_SERVER | SMTP Server to send mails | `none` | diff --git a/main.go b/main.go index 9d46c55..2e37203 100644 --- a/main.go +++ b/main.go @@ -29,6 +29,7 @@ type gloableConfig struct { Port int `env:"PORT, default=8080"` SMTPConfig smtpclient.SMTPConfig `env:", prefix=SMTP_"` WebConfig web.WebConfig `env:", prefix=WEB_"` + DummyDatabase bool `env:"DUMMY_DATABASE"` } func config() gloableConfig { @@ -53,9 +54,19 @@ func setupRouter(cfg gloableConfig) *gin.Engine { router.SetHTMLTemplate(loadTemplates()) routesWeb := router.Group("/web") - us, err := userstore.NewStore(cfg.UserStoreConfig) - if err != nil { - log.Fatal().Err(err).Msg("cant init userstore") + var us userstore.Store + var err error + if cfg.DummyDatabase { + log.Warn().Msg("Use dummy store") + us, err = userstore.NewDummyStore() + if err != nil { + log.Fatal().Err(err).Msg("cant init dummy store") + } + } else { + us, err = userstore.NewStore(cfg.UserStoreConfig) + if err != nil { + log.Fatal().Err(err).Msg("cant init userstore") + } } sc := smtpclient.NewSMTPClient(cfg.SMTPConfig)