Documentation
¶
Overview ¶
Package appconfig serves public and admin configuration endpoints.
Package appconfig holds admin-editable application settings (branding, sign-up policy, session lifetimes, email toggles) stored in the database and overlaid on internal/config env defaults.
Index ¶
- Constants
- func CIMDAllowlist(values map[string]string) []string
- func EnvDefaults(cfg *config.Config) map[string]string
- type MailSender
- type Module
- func (m *Module) APIRoutes(r chi.Router)
- func (m *Module) MergedValues(ctx context.Context) (map[string]string, error)
- func (*Module) Name() string
- func (m *Module) WithCipher(cipher *crypto.Cipher) *Module
- func (m *Module) WithEnvDefaults(defaults map[string]string) *Module
- func (m *Module) WithStore(store Store) *Module
- type Option
- type PostgresStore
- type Store
Constants ¶
const ModuleName = "appconfig"
ModuleName identifies the appconfig module in the registry.
Variables ¶
This section is empty.
Functions ¶
func CIMDAllowlist ¶
CIMDAllowlist reads the operator-managed CIMD URL allowlist from the merged values (JSON array; default deny when unset).
Types ¶
type MailSender ¶
MailSender queues transactional email; internal/jobs implements it.
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module mounts the configuration endpoints.
func New ¶
func New(mailer MailSender, opts ...Option) *Module
New builds the module. A nil mailer leaves the test-email route unmounted (fail closed); the config CRUD needs WithStore.
func (*Module) MergedValues ¶
MergedValues folds env defaults with stored overrides — the cross-module read path (the registry wires the CIMD allowlist from it).
func (*Module) WithCipher ¶
WithCipher wires the seal for sensitive settings; without one the module rejects writes to sensitive keys and returns stored ciphertext untouched on reads (fail closed).
func (*Module) WithEnvDefaults ¶
WithEnvDefaults seeds the env-backed defaults (MAILER_* values from the koanf config). Catalog defaults stay the bottom layer; DB overrides stay the top.
type PostgresStore ¶
type PostgresStore struct {
// contains filtered or unexported fields
}
PostgresStore persists overrides in public.app_config.
func NewPostgresStore ¶
func NewPostgresStore(store datastore.Store) *PostgresStore
NewPostgresStore builds the production config store. The store supplies both the read/write executor and transactions.
func (*PostgresStore) Delete ¶
func (s *PostgresStore) Delete(ctx context.Context, keys []string) error
Delete removes the rows for the given keys; missing keys are not an error.
type Store ¶
type Store interface {
List(ctx context.Context) (map[string]string, error)
Upsert(ctx context.Context, values map[string]string) error
// Delete removes rows by key; clearing a sensitive setting must
// delete its row because the enc: check rejects empty values.
Delete(ctx context.Context, keys []string) error
}
Store persists configuration overrides. Defaults live in env-backed config; rows here win.