settings

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2026 License: MIT Imports: 10 Imported by: 23

Documentation

Index

Constants

View Source
const (
	MySqlDbType    string = "mysql"
	PostgresDbType string = "postgres"
	Sqlite3DbType  string = "sqlite3"
)

Database types

View Source
const (
	LocalFileSystemObjectStorageType string = "local_filesystem"
	MinIOStorageType                 string = "minio"
	WebDAVStorageType                string = "webdav"
)

Object Storage types

View Source
const (
	OpenAILLMProvider           string = "openai"
	OpenAICompatibleLLMProvider string = "openai_compatible"
	OpenRouterLLMProvider       string = "openrouter"
	OllamaLLMProvider           string = "ollama"
	GoogleAILLMProvider         string = "google_ai"
)
View Source
const (
	OAuth2UserIdentifierEmail    string = "email"
	OAuth2UserIdentifierUsername string = "username"
)

OAuth 2.0 user identifier types

View Source
const (
	OAuth2ProviderOIDC      string = "oidc"
	OAuth2ProviderNextcloud string = "nextcloud"
	OAuth2ProviderGitea     string = "gitea"
	OAuth2ProviderGithub    string = "github"
)

OAuth 2.0 provider types

View Source
const (
	OpenStreetMapProvider                  string = "openstreetmap"
	OpenStreetMapHumanitarianStyleProvider string = "openstreetmap_humanitarian"
	OpenTopoMapProvider                    string = "opentopomap"
	OPNVKarteMapProvider                   string = "opnvkarte"
	CyclOSMMapProvider                     string = "cyclosm"
	CartoDBMapProvider                     string = "cartodb"
	TomTomMapProvider                      string = "tomtom"
	TianDiTuProvider                       string = "tianditu"
	GoogleMapProvider                      string = "googlemap"
	BaiduMapProvider                       string = "baidumap"
	AmapProvider                           string = "amap"
	CustomProvider                         string = "custom"
)

Map provider types

View Source
const (
	AmapSecurityVerificationInternalProxyMethod string = "internal_proxy"
	AmapSecurityVerificationExternalProxyMethod string = "external_proxy"
	AmapSecurityVerificationPlainTextMethod     string = "plain_text"
)

Amap security verification method

View Source
const (
	ReserveBankOfAustraliaDataSource    string = "reserve_bank_of_australia"
	BankOfCanadaDataSource              string = "bank_of_canada"
	CzechNationalBankDataSource         string = "czech_national_bank"
	DanmarksNationalbankDataSource      string = "danmarks_national_bank"
	EuroCentralBankDataSource           string = "euro_central_bank"
	NationalBankOfGeorgiaDataSource     string = "national_bank_of_georgia"
	CentralBankOfHungaryDataSource      string = "central_bank_of_hungary"
	BankOfIsraelDataSource              string = "bank_of_israel"
	CentralBankOfMyanmarDataSource      string = "central_bank_of_myanmar"
	NorgesBankDataSource                string = "norges_bank"
	NationalBankOfPolandDataSource      string = "national_bank_of_poland"
	NationalBankOfRomaniaDataSource     string = "national_bank_of_romania"
	BankOfRussiaDataSource              string = "bank_of_russia"
	SwissNationalBankDataSource         string = "swiss_national_bank"
	NationalBankOfUkraineDataSource     string = "national_bank_of_ukraine"
	CentralBankOfUzbekistanDataSource   string = "central_bank_of_uzbekistan"
	InternationalMonetaryFundDataSource string = "international_monetary_fund"
	UserCustomExchangeRatesDataSource   string = "user_custom"
)

Exchange rates data source types

View Source
const (
	InMemoryDuplicateCheckerType string = "in_memory"
)

Duplicate checker types

View Source
const (
	InternalUuidGeneratorType string = "internal"
)

Uuid generator types

Variables

View Source
var (
	Version    string
	CommitHash string
	BuildTime  string
	Container  = &ConfigContainer{}
)

Initialize a config container singleton instance

Functions

func GetDefaultConfigFilePath

func GetDefaultConfigFilePath() (string, error)

GetDefaultConfigFilePath returns the defaule config file path

func GetUserAgent added in v1.1.0

func GetUserAgent() string

func SetCurrentConfig

func SetCurrentConfig(config *Config)

SetCurrentConfig sets the current config by a given config

Types

type Config

type Config struct {
	// Global
	Mode        SystemMode
	WorkingPath string

	// Server
	Protocol Scheme
	HttpAddr string
	HttpPort uint16

	Domain  string
	RootUrl string

	CertFile    string
	CertKeyFile string

	UnixSocketPath string

	StaticRootPath string

	EnableGZip            bool
	EnableRequestLog      bool
	EnableRequestIdHeader bool

	// MCP
	EnableMCPServer     bool
	MCPAllowedRemoteIPs []*core.IPPattern

	// Database
	DatabaseConfig     *DatabaseConfig
	EnableQueryLog     bool
	AutoUpdateDatabase bool

	// Mail
	EnableSMTP bool
	SMTPConfig *SMTPConfig

	// Log
	LogModes         []string
	EnableConsoleLog bool
	EnableFileLog    bool

	EnableDebugLog     bool
	LogLevel           Level
	FileLogPath        string
	RequestFileLogPath string
	QueryFileLogPath   string
	LogFileRotate      bool
	LogFileMaxSize     uint32
	LogFileMaxDays     uint32

	// Storage
	StorageType         string
	LocalFileSystemPath string
	MinIOConfig         *MinIOConfig
	WebDAVConfig        *WebDAVConfig

	// Large Language Model
	TransactionFromAIImageRecognition bool
	MaxAIRecognitionPictureFileSize   uint32

	// Large Language Model for Receipt Image Recognition
	ReceiptImageRecognitionLLMConfig *LLMConfig

	// Uuid
	UuidGeneratorType string
	UuidServerId      uint8

	// Duplicate Checker
	DuplicateCheckerType                            string
	InMemoryDuplicateCheckerCleanupInterval         uint32
	InMemoryDuplicateCheckerCleanupIntervalDuration time.Duration
	EnableDuplicateSubmissionsCheck                 bool
	DuplicateSubmissionsInterval                    uint32
	DuplicateSubmissionsIntervalDuration            time.Duration

	// Cron
	EnableRemoveExpiredTokens        bool
	EnableCreateScheduledTransaction bool

	// Secret
	SecretKeyNoSet                        bool
	SecretKey                             string
	TokenExpiredTime                      uint32
	TokenExpiredTimeDuration              time.Duration
	TokenMinRefreshInterval               uint32
	TemporaryTokenExpiredTime             uint32
	TemporaryTokenExpiredTimeDuration     time.Duration
	EmailVerifyTokenExpiredTime           uint32
	EmailVerifyTokenExpiredTimeDuration   time.Duration
	PasswordResetTokenExpiredTime         uint32
	PasswordResetTokenExpiredTimeDuration time.Duration
	EnableAPIToken                        bool
	MaxFailuresPerIpPerMinute             uint32
	MaxFailuresPerUserPerMinute           uint32

	// Auth
	EnableInternalAuth                bool
	EnableOAuth2Login                 bool
	EnableTwoFactor                   bool
	EnableUserForgetPassword          bool
	ForgetPasswordRequireVerifyEmail  bool
	OAuth2ClientID                    string
	OAuth2ClientSecret                string
	OAuth2UsePKCE                     bool
	OAuth2UserIdentifier              string
	OAuth2AutoRegister                bool
	OAuth2Provider                    string
	OAuth2StateExpiredTime            uint32
	OAuth2StateExpiredTimeDuration    time.Duration
	OAuth2RequestTimeout              uint32
	OAuth2Proxy                       string
	OAuth2SkipTLSVerify               bool
	OAuth2OIDCProviderIssuerURL       string
	OAuth2OIDCProviderCheckIssuerURL  bool
	OAuth2OIDCCustomDisplayNameConfig MultiLanguageContentConfig
	OAuth2NextcloudBaseUrl            string
	OAuth2GiteaBaseUrl                string

	// User
	EnableUserRegister            bool
	EnableUserVerifyEmail         bool
	EnableUserForceVerifyEmail    bool
	EnableTransactionPictures     bool
	MaxTransactionPictureFileSize uint32
	EnableScheduledTransaction    bool
	AvatarProvider                core.UserAvatarProviderType
	MaxAvatarFileSize             uint32
	DefaultFeatureRestrictions    core.UserFeatureRestrictions

	// Data
	EnableDataExport  bool
	EnableDataImport  bool
	MaxImportFileSize uint32

	// Tip
	LoginPageTips MultiLanguageContentConfig

	// Notification
	AfterRegisterNotification MultiLanguageContentConfig
	AfterLoginNotification    MultiLanguageContentConfig
	AfterOpenNotification     MultiLanguageContentConfig

	// Map
	MapProvider                           string
	EnableMapDataFetchProxy               bool
	MapProxy                              string
	TomTomMapAPIKey                       string
	TianDiTuAPIKey                        string
	GoogleMapAPIKey                       string
	BaiduMapAK                            string
	AmapApplicationKey                    string
	AmapSecurityVerificationMethod        string
	AmapApplicationSecret                 string
	AmapApiExternalProxyUrl               string
	CustomMapTileServerTileLayerUrl       string
	CustomMapTileServerAnnotationLayerUrl string
	CustomMapTileServerMinZoomLevel       uint8
	CustomMapTileServerMaxZoomLevel       uint8
	CustomMapTileServerDefaultZoomLevel   uint8

	// Exchange Rates
	ExchangeRatesDataSource                       string
	ExchangeRatesRequestTimeout                   uint32
	ExchangeRatesRequestTimeoutExceedDefaultValue bool
	ExchangeRatesProxy                            string
	ExchangeRatesSkipTLSVerify                    bool
}

Config represents the global setting config

func LoadConfiguration

func LoadConfiguration(configFilePath string) (*Config, error)

LoadConfiguration loads setting config from given config file path

type ConfigContainer

type ConfigContainer struct {
	// contains filtered or unexported fields
}

ConfigContainer contains the current setting config

func (*ConfigContainer) GetCurrentConfig added in v1.0.0

func (c *ConfigContainer) GetCurrentConfig() *Config

GetCurrentConfig returns the current config

type DatabaseConfig

type DatabaseConfig struct {
	DatabaseType     string
	DatabaseHost     string
	DatabaseName     string
	DatabaseUser     string
	DatabasePassword string

	DatabaseSSLMode string

	DatabasePath string

	MaxIdleConnection     uint16
	MaxOpenConnection     uint16
	ConnectionMaxLifeTime uint32
}

DatabaseConfig represents the database setting config

type LLMConfig added in v1.1.0

type LLMConfig struct {
	LLMProvider                         string
	OpenAIAPIKey                        string
	OpenAIModelID                       string
	OpenAICompatibleBaseURL             string
	OpenAICompatibleAPIKey              string
	OpenAICompatibleModelID             string
	OpenRouterAPIKey                    string
	OpenRouterModelID                   string
	OllamaServerURL                     string
	OllamaModelID                       string
	GoogleAIAPIKey                      string
	GoogleAIModelID                     string
	LargeLanguageModelAPIRequestTimeout uint32
	LargeLanguageModelAPIProxy          string
	LargeLanguageModelAPISkipTLSVerify  bool
}

LLMConfig represents the Large Language Model setting config

type Level

type Level string

Level represents log level

const (
	LOGLEVEL_DEBUG Level = "debug"
	LOGLEVEL_INFO  Level = "info"
	LOGLEVEL_WARN  Level = "warn"
	LOGLEVEL_ERROR Level = "error"
)

Log levels

type MinIOConfig added in v0.5.0

type MinIOConfig struct {
	Endpoint        string
	Location        string
	AccessKeyID     string
	SecretAccessKey string
	UseSSL          bool
	SkipTLSVerify   bool
	Bucket          string
	RootPath        string
}

MinIOConfig represents the MinIO setting config

type MultiLanguageContentConfig added in v1.2.0

type MultiLanguageContentConfig struct {
	Enabled              bool
	DefaultContent       string
	MultiLanguageContent map[string]string
}

MultiLanguageContentConfig represents a multi-language content setting config

type SMTPConfig added in v0.4.0

type SMTPConfig struct {
	SMTPHost          string
	SMTPUser          string
	SMTPPasswd        string
	SMTPSkipTLSVerify bool
	FromAddress       string
}

SMTPConfig represents the SMTP setting config

type Scheme

type Scheme string

Scheme represents how the web backend service exposes

const (
	SCHEME_HTTP   Scheme = "http"
	SCHEME_HTTPS  Scheme = "https"
	SCHEME_SOCKET Scheme = "socket"
)

Scheme types

type SystemMode

type SystemMode string

SystemMode represents running mode of system

const (
	MODE_DEVELOPMENT SystemMode = "development"
	MODE_PRODUCTION  SystemMode = "production"
)

System running modes

type WebDAVConfig added in v1.0.0

type WebDAVConfig struct {
	Url            string
	Username       string
	Password       string
	RootPath       string
	RequestTimeout uint32
	Proxy          string
	SkipTLSVerify  bool
}

WebDAVConfig represents the WebDAV setting config

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL