alist/conf/config.go

55 lines
1.6 KiB
Go
Raw Normal View History

2021-10-25 10:53:59 +00:00
package conf
type Database struct {
2022-03-13 09:01:45 +00:00
Type string `json:"type" env:"DB_TYPE"`
Host string `json:"host" env:"DB_HOST"`
Port int `json:"port" env:"DB_PORT"`
User string `json:"user" env:"DB_USER"`
Password string `json:"password" env:"DB_PASS"`
Name string `json:"name" env:"DB_NAME"`
DBFile string `json:"db_file" env:"DB_FILE"`
TablePrefix string `json:"table_prefix" env:"DB_TABLE_PREFIX"`
SslMode string `json:"ssl_mode" env:"DB_SLL_MODE"`
2021-10-25 10:53:59 +00:00
}
2021-12-30 12:42:37 +00:00
type Scheme struct {
2022-03-13 09:01:45 +00:00
Https bool `json:"https" env:"HTTPS"`
CertFile string `json:"cert_file" env:"CERT_FILE"`
KeyFile string `json:"key_file" env:"KEY_FILE"`
2021-12-30 12:42:37 +00:00
}
type CacheConfig struct {
2022-03-13 09:01:45 +00:00
Expiration int64 `json:"expiration" env:"CACHE_EXPIRATION"`
CleanupInterval int64 `json:"cleanup_interval" env:"CLEANUP_INTERVAL"`
2021-12-30 12:42:37 +00:00
}
2021-10-25 10:53:59 +00:00
type Config struct {
2022-03-12 12:38:22 +00:00
Force bool `json:"force"`
2022-03-13 09:01:45 +00:00
Address string `json:"address" env:"ADDR"`
Port int `json:"port" env:"PORT"`
Assets string `json:"assets" env:"ASSETS"`
2021-12-30 12:42:37 +00:00
Database Database `json:"database"`
Scheme Scheme `json:"scheme"`
Cache CacheConfig `json:"cache"`
2022-03-13 09:01:45 +00:00
TempDir string `json:"temp_dir" env:"TEMP_DIR"`
2021-10-25 10:53:59 +00:00
}
func DefaultConfig() *Config {
return &Config{
Address: "0.0.0.0",
Port: 5244,
2022-02-25 14:08:12 +00:00
Assets: "https://npm.elemecdn.com/alist-web@$version/dist",
2022-02-14 07:06:57 +00:00
TempDir: "data/temp",
2021-10-25 10:53:59 +00:00
Database: Database{
Type: "sqlite3",
Port: 0,
TablePrefix: "x_",
2021-11-13 06:23:41 +00:00
DBFile: "data/data.db",
2021-10-25 10:53:59 +00:00
},
2021-12-30 12:42:37 +00:00
Cache: CacheConfig{
Expiration: 60,
CleanupInterval: 120,
},
2021-10-25 10:53:59 +00:00
}
}