config

package
v0.1.97 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package config loads runtime configuration from the environment.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RedactSecret

func RedactSecret(s string) string

RedactSecret masks a bare secret, keeping only enough to confirm which value is loaded. Short secrets are masked wholesale — revealing a prefix of a 6-character password gives away most of it.

func RedactURL

func RedactURL(raw string) string

RedactURL strips credentials from a connection string so it can be printed. On a parse failure it returns a fixed placeholder rather than the original: an unparseable DSN is exactly the case where a password is most likely to be sitting in a weird position, and leaking it into a terminal someone screen- shares is worse than an unhelpful log line.

Types

type Config

type Config struct {
	// Postgres. api/src/db.ts falls back to a local socket URL; we keep the
	// same default so `doctor` behaves identically to the TS services.
	DatabaseURL                string
	DatabaseMaxConnections     int
	DatabaseReadURL            string
	DatabaseReadMaxConnections int

	// Shared Valkey. River stores jobs in Postgres, so one Valkey now owns the
	// disposable response caches, coordination state, and pub/sub channels.
	RedisHost     string
	RedisPort     int
	RedisPassword string
	RedisDB       int

	// Memgraph, over Bolt.
	MemgraphURL string

	// EVE SSO / ESI. The client credentials are the production application's
	// even locally: refresh tokens in user_esi_tokens are bound to the issuing
	// client_id and cannot be exchanged by a different application.
	EVEClientID     string
	EVEClientSecret string
	EVECallbackURL  string

	// ESIUserAgent identifies us to CCP. Required by their acceptable-use
	// policy, and the static-data endpoints may throttle requests without it.
	ESIUserAgent string

	// Optional third-party API keys used by the comments surface. The NUXT_*
	// aliases are accepted during migration, but Go owns these integrations.
	OpenAIAPIKey string
	KlipyAPIKey  string

	// S3-compatible Backblaze B2 storage used for custom-domain images.
	// Names match frontend/server/utils/storage.ts so the Go process can take
	// over without changing deployment secrets.
	B2Endpoint     string
	B2MediaBucket  string
	B2ImagesBucket string
	B2KeyID        string
	B2AppKey       string
	// ImageStoragePath selects durable local filesystem storage for images.
	// When set it takes precedence over the legacy B2 image bucket.
	ImageStoragePath string

	// ImageCacheBytes bounds the encoded-response LRU owned by `shrike serve`.
	// It is a ceiling, not a reservation, and is deliberately not used by
	// workers or import commands.
	ImageCacheBytes int64

	// APICacheBytes bounds the process-local L1 for API responses. Valkey is
	// the shared L2 and remains authoritative across instances.
	APICacheBytes int64

	// HTTP listener for whatever `serve` subcommand is running.
	Port int

	// NuxtEntrypoint is the built Nitro server module supervised by `serve`.
	// Empty auto-discovers web/.output/server/index.mjs in a source checkout.
	NuxtEntrypoint string

	// NuxtSocket is where the supervised Nitro renderer listens. Every request
	// matching no Go-owned surface is proxied there.
	NuxtSocket string

	// APISocket is the private HTTP listener used by Nuxt SSR. Browser requests
	// still use relative same-origin requests through Caddy.
	APISocket string

	// DataDir is where the ingress keeps its own state, including the local
	// development CA and localhost certificate.
	DataDir string

	// Observability / environment.
	NodeEnv  string
	GitSHA   string
	LogLevel string
	LogJSON  bool
	// contains filtered or unexported fields
}

func Load

func Load(explicitPath string) (*Config, error)

Load reads .env files (nearest first, walking up from cwd) and then the process environment, which always wins. Missing values fall back to the same defaults the TS services use.

func (*Config) B2Configured

func (c *Config) B2Configured() bool

B2Configured reports whether the complete existing frontend storage contract is available. B2PartiallyConfigured distinguishes a deliberately disabled local setup from a deployment typo that should fail loudly.

func (*Config) B2ImagesConfigured

func (c *Config) B2ImagesConfigured() bool

B2ImagesConfigured reports whether the dedicated image bucket and shared B2 credentials are complete.

func (*Config) B2ImagesPartiallyConfigured

func (c *Config) B2ImagesPartiallyConfigured() bool

func (*Config) B2MediaPartiallyConfigured

func (c *Config) B2MediaPartiallyConfigured() bool

B2MediaPartiallyConfigured and B2ImagesPartiallyConfigured distinguish a deliberately omitted bucket from incomplete shared credentials. Once the endpoint and credentials are complete, either bucket may independently be disabled by leaving its name empty.

func (*Config) B2PartiallyConfigured

func (c *Config) B2PartiallyConfigured() bool

func (*Config) DotenvPath

func (c *Config) DotenvPath() string

DotenvPath returns the .env file that was loaded, or "" if none was found.

func (*Config) IsProduction

func (c *Config) IsProduction() bool

IsProduction reports whether we are running with production semantics. NODE_ENV is checked rather than a Go-specific variable because the whole deployment already keys off it.

func (*Config) RedisAddr

func (c *Config) RedisAddr() string

RedisAddr builds the shared Valkey host:port pair.

func (*Config) SourceOf

func (c *Config) SourceOf(field string) Source

SourceOf reports where a field's value came from.

type Source

type Source string

Source records where a value came from, so `config show` can explain itself. Debugging "why is it connecting to localhost" is otherwise guesswork.

const (
	SourceEnv     Source = "env"
	SourceDotenv  Source = ".env"
	SourceDefault Source = "default"
)

Jump to

Keyboard shortcuts

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