config

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package config holds application configuration loaded from environment variables.

Index

Constants

View Source
const APIEnabled = true

APIEnabled controls whether the JSON API (/api/v1/...) routes are registered. Build-time only, no env var override — see flag_api_disabled.go for the opt-in restricted build (-tags noapi or -tags personal).

View Source
const SingleOwnerMode = false

SingleOwnerMode controls whether the system is capped to one owner account total (registration closes once the first owner exists). Build-time only, no env var override — see flag_singleowner_enabled.go for the opt-in restricted build (-tags singleowner or -tags personal).

View Source
const SwaggerEnabled = true

SwaggerEnabled controls whether /swagger/* is registered. Build-time only, no env var override — see flag_swagger_disabled.go for the opt-in restricted build (-tags noswagger or -tags personal). Replaces the old runtime "AppEnv != production" gate as the single source of truth.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Logger *slog.Logger

	// AppEnv is the runtime environment ("development", "production", "testing").
	AppEnv string

	// IsDemo marks this instance as a public demo deployment. When true, the
	// UI shows a persistent notice warning that data resets periodically.
	IsDemo bool

	// DBPath is the file path to the SQLite database (use ":memory:" for tests).
	DBPath string

	// Port is the TCP port the HTTP server listens on.
	Port int

	// CORSAllowedOrigins is a list of allowed CORS origins.
	CORSAllowedOrigins []string

	// CORSAllowedMethods is a list of allowed HTTP methods for CORS.
	CORSAllowedMethods []string

	// JWTSecret is the HMAC-SHA256 signing key for JWT tokens.
	JWTSecret string

	// JWTExpiryHours is the access token lifetime in hours (default 24).
	JWTExpiryHours int

	// PluginDir is the directory scanned for *.js plugin scripts at startup.
	// Empty (default) disables the plugin system.
	PluginDir string

	// StorageDriver selects the file storage backend: "local" (default,
	// self-host friendly) or "s3".
	StorageDriver string

	// StorageLocalPath is the base directory for local file storage, used
	// when StorageDriver is "local". Defaults to an OS-appropriate data
	// directory (see repo.DefaultStorageDir) when empty.
	StorageLocalPath string

	// FileAccessTTL is how long a local-storage presigned download URL
	// (and the file-access JWT backing it) remains valid.
	FileAccessTTL time.Duration

	// S3Bucket, S3Region, S3Endpoint, S3AccessKeyID, S3SecretAccessKey, and
	// S3UseSSL configure the S3-compatible storage backend, used when
	// StorageDriver is "s3". S3Endpoint accepts any S3-compatible host
	// (AWS S3, MinIO, R2, Spaces, ...).
	S3Bucket          string
	S3Region          string
	S3Endpoint        string
	S3AccessKeyID     string
	S3SecretAccessKey string
	S3UseSSL          bool
}

Config holds all runtime configuration for the application.

func Load

func Load(envFiles ...string) *Config

Load reads configuration from environment variables. Optional envFiles are loaded first via godotenv; later files take lower precedence.

func (*Config) IsDevelopment

func (c *Config) IsDevelopment() bool

IsDevelopment returns true when running in the development environment.

func (*Config) IsLocalStorage

func (c *Config) IsLocalStorage() bool

IsLocalStorage returns true when the local filesystem storage driver is selected.

func (*Config) IsProduction

func (c *Config) IsProduction() bool

IsProduction returns true when running in the production environment.

func (*Config) IsTesting

func (c *Config) IsTesting() bool

IsTesting returns true when running in the testing environment.

Jump to

Keyboard shortcuts

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