wip
This commit is contained in:
27
server/config/config.go
Normal file
27
server/config/config.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"github.com/caarlos0/env/v11"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Environment string `env:"ENVIRONMENT" envDefault:"production"`
|
||||
DbDataDir string `env:"CCTV_PB_DATA_DIR" envDefault:"./pb_data"`
|
||||
DbEncryptionKey string `env:"CCTV_PB_ENCRYPTION_KEY" envDefault:""`
|
||||
RecordingsDir string `env:"CCTV_REC_DIR" envDefault:"./recordings"`
|
||||
ExternalWebApp string `env:"CCTV_EXTERNAL_WEB_APP" envDefault:""`
|
||||
}
|
||||
|
||||
func Load() (*Config, error) {
|
||||
var cfg Config
|
||||
if err := env.ParseWithOptions(&cfg, env.Options{
|
||||
RequiredIfNoDef: true,
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &cfg, nil
|
||||
}
|
||||
|
||||
func (c *Config) IsDev() bool {
|
||||
return c.Environment == "development"
|
||||
}
|
||||
Reference in New Issue
Block a user