[feature] migrate to monorepo
This commit is contained in:
commit
05ddc1f783
267 changed files with 75165 additions and 0 deletions
74
backend/internal/config/config.go
Normal file
74
backend/internal/config/config.go
Normal file
|
@ -0,0 +1,74 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
"tss-rocks-be/internal/types"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Database DatabaseConfig `yaml:"database"`
|
||||
Server ServerConfig `yaml:"server"`
|
||||
JWT JWTConfig `yaml:"jwt"`
|
||||
Storage StorageConfig `yaml:"storage"`
|
||||
Logging LoggingConfig `yaml:"logging"`
|
||||
RateLimit types.RateLimitConfig `yaml:"rate_limit"`
|
||||
AccessLog types.AccessLogConfig `yaml:"access_log"`
|
||||
}
|
||||
|
||||
type DatabaseConfig struct {
|
||||
Driver string `yaml:"driver"`
|
||||
DSN string `yaml:"dsn"`
|
||||
}
|
||||
|
||||
type ServerConfig struct {
|
||||
Port int `yaml:"port"`
|
||||
Host string `yaml:"host"`
|
||||
}
|
||||
|
||||
type JWTConfig struct {
|
||||
Secret string `yaml:"secret"`
|
||||
Expiration string `yaml:"expiration"`
|
||||
}
|
||||
|
||||
type LoggingConfig struct {
|
||||
Level string `yaml:"level"`
|
||||
Format string `yaml:"format"`
|
||||
}
|
||||
|
||||
type StorageConfig struct {
|
||||
Type string `yaml:"type"`
|
||||
Local LocalStorage `yaml:"local"`
|
||||
S3 S3Storage `yaml:"s3"`
|
||||
Upload types.UploadConfig `yaml:"upload"`
|
||||
}
|
||||
|
||||
type LocalStorage struct {
|
||||
RootDir string `yaml:"root_dir"`
|
||||
}
|
||||
|
||||
type S3Storage struct {
|
||||
Region string `yaml:"region"`
|
||||
Bucket string `yaml:"bucket"`
|
||||
AccessKeyID string `yaml:"access_key_id"`
|
||||
SecretAccessKey string `yaml:"secret_access_key"`
|
||||
Endpoint string `yaml:"endpoint"`
|
||||
CustomURL string `yaml:"custom_url"`
|
||||
ProxyS3 bool `yaml:"proxy_s3"`
|
||||
}
|
||||
|
||||
// Load loads configuration from a YAML file
|
||||
func Load(path string) (*Config, error) {
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var cfg Config
|
||||
if err := yaml.Unmarshal(data, &cfg); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &cfg, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue