config

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package config provides configuration management for minimaldoc-server. Configuration is loaded from environment variables and optional config file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AIConfig

type AIConfig struct {
	Enabled   bool
	APIKey    string
	Model     string // claude-3-sonnet, claude-3-opus, etc.
	MaxTokens int
}

AIConfig holds Claude API settings.

type AuthConfig

type AuthConfig struct {
	JWTSecret            string
	JWTExpiry            time.Duration
	RefreshExpiry        time.Duration
	BCryptCost           int
	SessionCookieKey     string
	EnableLocal          bool   // Enable email/password auth
	EnableOAuth          bool   // Enable OAuth providers
	AllowNewsletterOAuth bool   // Allow OAuth subscribe for newsletter
	BootstrapToken       string // Optional token required to call /api/bootstrap
	SecureCookies        bool   // Set Secure flag on cookies (requires HTTPS)
}

AuthConfig holds authentication settings.

type Config

type Config struct {
	// Server settings
	Server ServerConfig

	// Database settings
	Database DatabaseConfig

	// Authentication settings
	Auth AuthConfig

	// OAuth providers
	OAuth OAuthConfig

	// Email settings
	Email EmailConfig

	// AI settings (Claude)
	AI AIConfig

	// Storage settings
	Storage StorageConfig

	// Rate limiting settings
	RateLimit RateLimitConfig

	// OpenTelemetry settings
	Telemetry TelemetryConfig

	// Forum settings
	Forum ForumConfig

	// Docs config (loaded from docs/config.yaml)
	Docs *DocsConfig
}

Config holds all server configuration.

func Load

func Load() (*Config, error)

Load loads configuration from environment variables.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks that required configuration is present and logs warnings for production misconfigurations.

type DatabaseConfig

type DatabaseConfig struct {
	Driver          string // "postgres" or "sqlite"
	URL             string // Connection URL
	MaxOpenConns    int
	MaxIdleConns    int
	ConnMaxLifetime time.Duration
	MigrationsPath  string
}

DatabaseConfig holds database connection settings.

type DocsConfig

type DocsConfig struct {
	Title   string `yaml:"title"`
	BaseURL string `yaml:"base_url"`
	SiteID  string `yaml:"site_id"`
}

DocsConfig holds configuration loaded from the static site's config.yaml.

func LoadDocsConfig

func LoadDocsConfig(path string) (*DocsConfig, error)

LoadDocsConfig loads the docs config.yaml from the specified path.

type EmailConfig

type EmailConfig struct {
	Provider    string // smtp, mock (ses/sendgrid: add when needed)
	SMTPHost    string
	SMTPPort    int
	SMTPUser    string
	SMTPPass    string
	FromAddress string
	FromName    string
	BaseURL     string // Base URL for verification links (e.g., https://api.example.com)
}

EmailConfig holds email sending settings.

type ForumConfig

type ForumConfig struct {
	Enabled           bool          // Enable forum feature
	AllowAnonymous    bool          // Allow viewing without auth
	RequireAuth       bool          // Require auth to post
	MaxTopicsPerDay   int           // Rate limit for topic creation
	MaxPostsPerDay    int           // Rate limit for post creation
	EditWindow        time.Duration // Time window for editing posts
	ModerationMode    string        // none, first_post, all
	EmailEnabled      bool          // Enable email notifications
	EmailDigest       string        // daily, weekly, none
	EmailOnReply      bool          // Send email on reply
	EmailOnMention    bool          // Send email on @mention
	ReputationEnabled bool          // Enable reputation system
	RepTopicCreate    int           // Points for creating topic
	RepPostCreate     int           // Points for posting reply
	RepLikeReceived   int           // Points when liked
	RepSolutionMarked int           // Points for accepted solution
}

ForumConfig holds forum feature settings.

type OAuthConfig

type OAuthConfig struct {
	Providers []OAuthProvider
}

OAuthConfig holds OAuth 2.0 / OIDC provider settings.

type OAuthProvider

type OAuthProvider struct {
	Name         string // cognito, auth0, google, github, oidc
	ClientID     string
	ClientSecret string
	RedirectURL  string
	Scopes       []string

	// OIDC-specific (for generic OIDC or Cognito)
	Issuer      string // OIDC issuer URL
	AuthURL     string // Authorization endpoint (if not using discovery)
	TokenURL    string // Token endpoint (if not using discovery)
	UserInfoURL string // UserInfo endpoint (if not using discovery)
}

OAuthProvider represents a single OAuth provider configuration.

type RateLimitConfig

type RateLimitConfig struct {
	Enabled      bool          // Enable rate limiting
	LoginLimit   int           // Max login attempts per window
	LoginWindow  time.Duration // Login rate limit window
	APILimit     int           // Max API requests per window
	APIWindow    time.Duration // API rate limit window
	SubmitLimit  int           // Max submissions per window (comments, feedback, newsletter)
	SubmitWindow time.Duration // Submit rate limit window
}

RateLimitConfig holds rate limiting settings.

type ServerConfig

type ServerConfig struct {
	Host           string
	Port           int // Public API port (tracking, feedback, newsletter)
	AdminPort      int // Admin UI and management API port
	ReadTimeout    time.Duration
	WriteTimeout   time.Duration
	AdminPath      string // Path prefix for admin UI (default: /admin)
	APIPath        string // Path prefix for API (default: /api)
	CORSOrigins    []string
	DocsDir        string // Directory containing static docs (default: public)
	DocsConfigPath string // Path to docs config.yaml (default: docs/config.yaml)
	Environment    string // "production" or "development" (default: development)
}

ServerConfig holds HTTP server settings.

type StorageConfig

type StorageConfig struct {
	Provider     string   // local or s3
	LocalPath    string   // Local filesystem path for uploads
	S3Bucket     string   // S3 bucket name
	S3Region     string   // S3 region
	S3AccessKey  string   // S3 access key
	S3SecretKey  string   // S3 secret key
	S3Endpoint   string   // Custom S3 endpoint (for MinIO, R2)
	S3PublicURL  string   // Public URL prefix for S3 objects
	MaxFileSize  int64    // Max upload size in bytes
	AllowedTypes []string // Allowed MIME types
}

StorageConfig holds file storage settings.

type TelemetryConfig

type TelemetryConfig struct {
	Enabled     bool   // Enable OpenTelemetry tracing
	Endpoint    string // OTLP HTTP endpoint (e.g. "localhost:4318")
	ServiceName string // Service name for traces (default: minimaldoc-server)
}

TelemetryConfig holds OpenTelemetry settings.

Jump to

Keyboard shortcuts

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