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):
- Direct Options: The object passed to the
baseline()initializer.
js
//server/baseline.js
const app = baseline({
port: 1234
});- Environment Variables: Variables prefixed with
APP_.
bash
APP_PORT=5000See Advanced: Environment Variables for detailed information
- 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.
- Type:
port(APP_PORT)- Type:
number| Default:3000 - The port number the server listens on.
- Type:
host(APP_HOST)- Type:
string| Default:"0.0.0.0" - The network interface/host the server binds to.
- Type:
url(APP_URL)- Type:
string (URL)| Default:undefined - The base URL for the application. Must be a valid URL format.
- Type:
routing_mode- Type:
"api"|"html5"| Default:"api" - Determines the routing behavior of the framework. See Advanced: Routing
- Type:
max_upload_size- Type:
number| Default:1048576 - The maximum size of allowed file uploads in bytes (Default: 1MB).
- Type:
Security & Auth
cors(APP_CORS)- Type:
boolean| Default:true - Enables or disables Cross-Origin Resource Sharing.
- Type:
trust_proxies- Type:
any| Default:null - Configures whether to trust the proxy headers (e.g.,
X-Forwarded-For).
- Type:
bcrypt_rounds(APP_BCRYPT_ROUNDS)- Type:
number| Default:12 - The cost factor for
bcryptpassword hashing.
- Type:
token_ttl(APP_TOKEN_TTL)- Type:
number| Default:604800 - Token Time-To-Live in seconds (Default: 7 days). See Authentication.
- Type:
token_autorefresh(APP_TOKEN_AUTOREFRESH)- Type:
boolean| Default:true - Whether the token expiry time resets after every authenticated request. See Authentication.
- Type:
token_permanent_enabled(APP_TOKEN_PERMANENT_ENABLED)- Type:
boolean| Default:true - Whether permanent tokens are enabled. See Authentication.
- Type:
Rate Limiting
ratelimit_login_time- Type:
number| Default:600000 - The time window for login rate limiting in milliseconds (Default: 10 minutes).
- Type:
ratelimit_login_count- Type:
number| Default:10 - The maximum number of allowed login attempts within the time window.
- Type:
ratelimit_files_time- Type:
number| Default:600000 - The time window for file upload rate limiting in milliseconds (Default: 10 minutes).
- Type:
ratelimit_files_count- Type:
number| Default:10 - The maximum number of allowed file uploads within the time window.
- Type:
Database
database_url(DATABASE_URL)- Type:
string| Required - The connection string for the database.
- Type:
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.
- Type:
version- Type:
string| Default: See Metadata Resolution above - The application version.
- Type:
mode(NODE_ENV)- Type:
string| Required - The current runtime mode (e.g.,
development,production).
- Type:
Development
vite- Type:
boolean| Default:true - Enables or disables Vite integration.
- Type:
api_docs- Type:
boolean| Default:true - Enables or disables serving the api docs under /api/docs.
- Type:
Advanced
init- Type:
Function - A callback function executed during the application initialization.
- Type: