staticbackendhq / core

Backend server API handling user mgmt, database, storage and real-time component
https://staticbackend.com
MIT License
700 stars 66 forks source link

review quick start for backend client library (go doc) #98

Closed c-nv-s closed 1 year ago

c-nv-s commented 1 year ago

Describe the bug When following the quick-start for the importing and using as a client library, I noticed that when calling backend.Setup(cfg) it wasn't picking up the RedisURL I had set. https://github.com/staticbackendhq/core/blob/5482c6957dcf54f79bb298a99aabd91d42484f30/backend/backend.go#L16

Turns out that backend.Setup(cfg) eventually sets up the cache by looking at config.Current https://github.com/staticbackendhq/core/blob/5482c6957dcf54f79bb298a99aabd91d42484f30/cache/cache.go#L30

as a workaround I refactored the getting started code to pass backend.Setup(config.Current) instead, something like this:

config.Current := config.LoadConfig() // first get from environment and then override as needed
config.Current.AppEnv = "dev"
config.Current.DataStore = "PostgreSQL"
config.Current.DatabaseURL = "postgres://user:password@localhost:5432/postgres?sslmode=disabled"
config.Current.RedisURL = "redis://localhost:6379"
config.Current.LocalStorageURL = "http://localhost:8099"
backend.Setup(config.Current)
dstpierre commented 1 year ago

Thanks @c-nv-s good catch, will be updated on Go doc once v1.5.0 is released.