configuration

package
v0.0.0-...-5d49e15 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CLIArgs

func CLIArgs(cfg AppConfig) []string

CLIArgs generates CLI arguments for PocketBase based on the loaded configuration. It returns a slice of arguments that can be appended to os.Args.

func DebugPrint

func DebugPrint(w io.Writer) error

DebugPrint prints the current configuration and environment variables to the given writer. If w is nil, it prints to os.Stdout.

func DebugPrintIfEnabled

func DebugPrintIfEnabled(w io.Writer) (bool, error)

DebugPrintIfEnabled prints debug information only if debug mode is enabled in the config. Returns true if debug output was printed.

func EnvironmentMap

func EnvironmentMap() (map[string]MetaNode, error)

func HTMLMap

func HTMLMap() (map[string]string, error)

func InjectCLIArgs

func InjectCLIArgs(osArgs []string, cfg AppConfig) []string

InjectCLIArgs modifies os.Args to include the configuration-based CLI arguments. It intelligently merges with existing arguments, ensuring the "serve" command is present. Returns the modified args slice (also modifies os.Args in place).

func WalkMeta

func WalkMeta(f func(node MetaNode) error) error

Types

type AppConfig

type AppConfig struct {
	General GeneralConfig `json:"general"`
	Server  ServerConfig  `json:"server"`
}

AppConfig mirrors the structure of app.config.jsonc at the project root.

func Get

func Get() (AppConfig, error)

func ParseAppConfig

func ParseAppConfig(data []byte) (AppConfig, error)

type DatabaseConfig

type DatabaseConfig struct {
	QueryTimeoutSeconds int `` /* 156-byte string literal not displayed */
}

DatabaseConfig holds database-specific settings.

type EmailConfig

type EmailConfig struct {
	SenderName    string `` /* 158-byte string literal not displayed */
	SenderAddress string `` /* 162-byte string literal not displayed */
}

EmailConfig holds email sender settings.

type GeneralConfig

type GeneralConfig struct {
	Name                     string `json:"name" env:"APP_GENERAL_NAME" env-description:"The application name."`
	Description              string `json:"description" env:"APP_GENERAL_DESCRIPTION" env-description:"A brief description of the application."`
	Version                  string `json:"version" env:"APP_GENERAL_VERSION" env-description:"The current version of the application."`
	URL                      string `json:"url" env:"APP_GENERAL_URL" env-description:"The URL this application is hosted at."`
	InitialAdminRegistration bool   `` /* 163-byte string literal not displayed */
	Debug                    bool   `` /* 153-byte string literal not displayed */
}

GeneralConfig holds general application metadata.

type HTTPConfig

type HTTPConfig struct {
	Address string `` /* 127-byte string literal not displayed */
	Port    int    `json:"port" env:"APP_SERVER_HTTP_PORT" env-default:"8161" env-description:"TCP port to listen for the HTTP server."`
	Enabled bool   `json:"enabled" env:"APP_SERVER_HTTP_ENABLED" env-default:"true" env-description:"Enable or disable the HTTP server."`
}

HTTPConfig holds HTTP server settings.

type HTTPSConfig

type HTTPSConfig struct {
	Address string `` /* 129-byte string literal not displayed */
	Port    int    `json:"port" env:"APP_SERVER_HTTPS_PORT" env-default:"8443" env-description:"TCP port to listen for the HTTPS server."`
	Enabled bool   `json:"enabled" env:"APP_SERVER_HTTPS_ENABLED" env-default:"false" env-description:"Enable or disable the HTTPS server."`
}

HTTPSConfig holds HTTPS server settings.

type MetaNode

type MetaNode struct {
	Name         string
	AbsolutePath []string

	Value    any
	Children []MetaNode

	Env          string
	Description  string
	EnvDefault   string
	EnvSeparator string
}

func Meta

func Meta() (MetaNode, error)

func (MetaNode) Walk

func (n MetaNode) Walk(f func(node MetaNode) error) error

type ServerConfig

type ServerConfig struct {
	HTTP     HTTPConfig     `json:"http"`
	HTTPS    HTTPSConfig    `json:"https"`
	Email    EmailConfig    `json:"email"`
	Database DatabaseConfig `json:"database"`

	EncryptionKey             *string  `` /* 149-byte string literal not displayed */
	Domains                   []string `` /* 147-byte string literal not displayed */
	AllowedOrigins            []string `` /* 159-byte string literal not displayed */
	ForceDevMode              bool     `` /* 139-byte string literal not displayed */
	IndexFallback             bool     `` /* 135-byte string literal not displayed */
	StaticFileServerImmutable bool     `` /* 164-byte string literal not displayed */
	ReplaceHTMLVars           bool     `` /* 148-byte string literal not displayed */
}

ServerConfig groups server-specific settings.

Jump to

Keyboard shortcuts

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