DOCUMENTATION / API & OPERATIONS

Application configuration

Configuration keeps environment-specific values out of your application source. You should not edit Mojo code each time the port, database or secret changes.

1. Choose development values

For a local application, start with:

export MOJARA_PORT=8000
export MOJARA_ENV=development
export DATABASE_URL="postgresql://localhost/mojara_dev"
mojara dev

These values affect only this terminal session. The application must read the values through its configuration layer.

2. Separate development and production

Setting Development example Production guidance
Port 8000 Local port behind a reverse proxy
Environment development production
Database URL Local test database Managed private database
Session key Disposable key Long random secret in environment
Logging Detailed Structured, without secrets

3. Use one configuration value

def home(req: Request) -> Response:
    return Response.html("<h1>Configured Mojara application</h1>")

Route handlers should focus on the request; configuration belongs in application setup and services. For example, a database service should read its connection string from configuration once, not on every request.

4. Keep sensitive values private

Do not commit passwords, session keys or production database addresses to Git. Use your deployment environment's secret manager or protected environment files. Review logs so secrets never appear in errors.

5. Diagnose missing configuration

If the application cannot connect to a database, confirm the configured host, port, username and database exist. If a required secret is missing, stop startup with a clear configuration error rather than running with insecure defaults.