Skip to content

Configuration ​

Momobase Server reads environment variables. The Go package reads none: set the matching field on a momobase.Config instead.

The defaults are for development: SQLite in ./data and placeholder secrets. Before going live, follow Going to production.

Server ​

When a setting comes from several places, the first one wins:

text
flags  >  environment  >  .env file  >  defaults

Put a .env file in the working directory. The server repository has an .env.example to start from. momobase serve has four flags: --addr, --dashboard, --dashboard-path, and --public-dir.

Booleans accept true, false, 1, or 0. An invalid value stops the server at start-up.

Go package ​

Start from DefaultConfig(), change what you need, and pass it with WithConfig:

go
cfg := momobase.DefaultConfig()
cfg.App.Env = "production"
cfg.Security.EncryptionMasterKeyBase64 = secrets.EncryptionKey

instance, err := momobase.New(momobase.WithConfig(cfg), momobase.WithProvider("dummy", dummy.New))

Don't start from a momobase.Config{} literal: its zero values mean no database type, no migrations, and no workers. Durations are time.Duration values, such as 15 * time.Minute.

Application ​

VariableConfig fieldDefaultDescription
APP_ENVApp.Envdevelopmentstaging or production turns on the start-up safety checks
APP_ADDRApp.Addr:9090Listen address
APP_PUBLIC_URLApp.PublicURLhttp://localhost:9090URL callers use to reach Momobase
CORS_ALLOWED_ORIGINSApp.CORSAllowedOriginshttp://localhost:9090Browser origins allowed to call the API, comma-separated
TRUSTED_PROXY_CIDRSApp.TrustedProxyCIDRsemptyAddresses or CIDRs of proxies in front, comma-separated
PUBLIC_DIRApp.PublicDirmb_publicStatic files served at /, if the directory exists
APP_NAMEApp.NamemomobaseName reported in runtime metadata
LOG_LEVELLog.Levelinfodebug, info, warn, or error

In the container, the working directory is /home/momobase, so mount static files at /home/momobase/mb_public.

Secrets ​

VariableConfig fieldRequirement
ENCRYPTION_MASTER_KEY_BASE64Security.EncryptionMasterKeyBase64Decodes to exactly 32 bytes
ADMIN_OAUTH_SECRETSecurity.AdminOAuthSecretAt least 32 characters
APP_OAUTH_SECRETSecurity.AppOAuthSecretAt least 32 characters, unlike the admin secret

To generate them, see Replace the secrets. Changing an OAuth secret signs everyone out.

Database ​

VariableConfig fieldDefaultDescription
DB_TYPEDB.Typesqlitesqlite, postgres, or mysql
DB_PATHDB.Path./data/momobase.dbSQLite file. In the container, /data/momobase.db
DB_HOSTDB.HostlocalhostPostgreSQL or MySQL host
DB_PORTDB.Port5432PostgreSQL or MySQL port. Set 3306 for MySQL
DB_USERDB.UsermomobasePostgreSQL or MySQL user
DB_PASSWORDDB.PasswordemptyPostgreSQL or MySQL password
DB_NAMEDB.NamemomobasePostgreSQL or MySQL database
DB_SSLMODEDB.SSLModedisablePostgreSQL TLS mode. Use require across a network

Tokens ​

VariableConfig fieldDefault
ADMIN_ACCESS_TTL_MINUTESSecurity.AdminAccessTTL15
ADMIN_REFRESH_TTL_HOURSSecurity.AdminRefreshTTL24
APP_ACCESS_TTL_MINUTESSecurity.AppAccessTTL30
APP_REFRESH_TTL_HOURSSecurity.AppRefreshTTL24
APP_CLIENT_ID_PREFIXSecurity.AppClientIDPrefixapp_client
APP_CLIENT_SECRET_PREFIXSecurity.AppClientSecretPrefixmb_test

Workers ​

Workers check provider health, follow up on unfinished payments, and remove expired sessions.

VariableConfig fieldDefault
WORKERS_ENABLEDWorkers.Enabledtrue
HEALTH_WORKER_ENABLEDWorkers.HealthEnabledtrue
HEALTH_CHECK_INTERVAL_SECONDSWorkers.HealthInterval30
RECONCILIATION_WORKER_ENABLEDWorkers.ReconciliationEnabledtrue
RECONCILIATION_INTERVAL_SECONDSWorkers.ReconciliationInterval60
CLEANUP_WORKER_ENABLEDWorkers.CleanupEnabledtrue
CLEANUP_INTERVAL_SECONDSWorkers.CleanupInterval300

With WORKERS_ENABLED=false, no worker runs.

Migrations and dashboard ​

VariableConfig fieldDefaultDescription
AUTO_MIGRATEFeatures.AutoMigratetrueApply database migrations at start-up
DASHBOARD_ENABLEDServer onlytrueServe the dashboard
DASHBOARD_PATHServer only/_URL path of the dashboard

With AUTO_MIGRATE=false, Momobase logs pending migrations and starts without them. In Go, apply them with instance.Migrate(ctx).