Skip to content
manual

Configuration ​

Baseline uses a hierarchical configuration system. You can set options by passing an object to the initializer or by using environment variables.

Resolution Priority ​

If a setting is defined in multiple places, Baseline follows this priority (highest to lowest):

  1. Direct Options: The object passed to the baseline() initializer.
js
//server/baseline.js
const app = baseline({
    port: 1234
});
  1. Environment Variables: Variables prefixed with APP_.
bash
APP_PORT=5000

See Advanced: Environment Variables for detailed information

  1. Defaults: Built-in fallback values.

Available Options ​

Server Settings ​

  • root (APP_ROOT)
    • Type: string | Required
    • The absolute or relative path to the application root directory.
  • port (APP_PORT)
    • Type: number | Default: 3000
    • The port number the server listens on.
  • host (APP_HOST)
    • Type: string | Default: "0.0.0.0"
    • The network interface/host the server binds to.
  • url (APP_URL)
    • Type: string (URL) | Default: undefined
    • The base URL for the application. Must be a valid URL format.
  • routing_mode
    • Type: "api" | "html5" | Default: "api"
    • Determines the routing behavior of the framework. See Advanced: Routing
  • max_upload_size
    • Type: number | Default: 1048576
    • The maximum size of allowed file uploads in bytes (Default: 1MB).

Security & Auth ​

  • cors (APP_CORS)
    • Type: boolean | Default: true
    • Enables or disables Cross-Origin Resource Sharing.
  • trust_proxies
    • Type: any | Default: null
    • Configures whether to trust the proxy headers (e.g., X-Forwarded-For).
  • bcrypt_rounds (APP_BCRYPT_ROUNDS)
    • Type: number | Default: 12
    • The cost factor for bcrypt password hashing.
  • token_ttl (APP_TOKEN_TTL)
    • Type: number | Default: 604800
    • Token Time-To-Live in seconds (Default: 7 days). See Authentication.
  • token_autorefresh (APP_TOKEN_AUTOREFRESH)
    • Type: boolean | Default: true
    • Whether the token expiry time resets after every authenticated request. See Authentication.
  • token_permanent_enabled (APP_TOKEN_PERMANENT_ENABLED)
    • Type: boolean | Default: true
    • Whether permanent tokens are enabled. See Authentication.

Rate Limiting ​

  • ratelimit_login_time
    • Type: number | Default: 600000
    • The time window for login rate limiting in milliseconds (Default: 10 minutes).
  • ratelimit_login_count
    • Type: number | Default: 10
    • The maximum number of allowed login attempts within the time window.
  • ratelimit_files_time
    • Type: number | Default: 600000
    • The time window for file upload rate limiting in milliseconds (Default: 10 minutes).
  • ratelimit_files_count
    • Type: number | Default: 10
    • The maximum number of allowed file uploads within the time window.

Database ​

  • database_url (DATABASE_URL)
    • Type: string | Required
    • The connection string for the database.

App Metadata ​

Metadata Resolution

If name or version are not explicitly defined in the configuration or your .env file, Baseline reads them from the package.json located in the root directory.

  • name (APP_NAME)
    • Type: string | Default: "Baseline"
    • The name of the application.
  • version
    • Type: string | Default: See Metadata Resolution above
    • The application version.
  • mode (NODE_ENV)
    • Type: string | Required
    • The current runtime mode (e.g., development, production).

Development ​

  • vite
    • Type: boolean | Default: true
    • Enables or disables Vite integration.
  • api_docs
    • Type: boolean | Default: true
    • Enables or disables serving the api docs under /api/docs.

Advanced ​

  • init
    • Type: Function
    • A callback function executed during the application initialization.