Configuration
CONF, LOADCONFIG(), DEBUG and every $ key of the framework with its default.
On this page
Every key the framework reads from CONF, with its type and default, plus CONF, LOADCONFIG(), DEBUG and the $reconfigure event. The guide Configuration explains the format of the config file, the types, .env and the loading order.
API
property
CONF
The global object with the configuration of the application.
CONFReturns Object
Holds the defaults of the framework and every key loaded from the options of F.http(), the config file, plugin config files and LOADCONFIG(). F.config is the same object. Read it anywhere; write to it with LOADCONFIG() when the change must refresh derived settings.
exports.install = function() {
ROUTE('GET /about/', function($) {
$.json({ name: CONF.name, version: CONF.version });
});
};
method
LOADCONFIG(value)
Applies configuration values at runtime.
LOADCONFIG(value)| Parameter | Type | Description |
|---|---|---|
value |
String|Object|Array |
The text of a config file, an object of keys and values, or an array of { id, type, value } items (key/name and val/body are accepted too). |
Parses value like the config file and copies the keys into CONF. In an object or an array, the values false, 0 and '' are stored as undefined. Special keys are processed: $root is normalized and prefixes $api, $timezone sets process.env.TZ, $port becomes a number, $httpfiles adds extensions, $cryptoiv becomes a Buffer, smtp/mail/mail_smtp/mail_smtp_options build CONF.smtp, totalapi sets the Total API token. Then it refreshes the directories, the logger ($logger), the CORS list and TMS, and emits $reconfigure. The framework calls it for the config file itself.
LOADCONFIG('$httptimeout (number) : 15\nmaintenance : true');
LOADCONFIG([
{ id: 'limit', type: 'number', value: '25' },
{ id: 'tags', type: 'array', value: 'a, b, c' }
]);
LOADCONFIG({ name: 'Shop', $cors: 'https://shop.example.com' });
property
DEBUG
true in debug mode, false in release mode.
DEBUGReturns Boolean
A global boolean. It starts as process.env.NODE_ENV !== 'production'. The debug runner sets it to true and the release runner sets it to false before the application loads, so NODE_ENV decides the mode when the application calls F.http() or F.load() without a runner. The framework uses it for caching of views and static files, minification and the source map ($sourcemap follows it).
if (DEBUG)
console.log('Debug mode');
event
ON('$reconfigure', function() {})
Emitted after LOADCONFIG() applies new values.
ON('$reconfigure', function() {})Emitted at the end of every LOADCONFIG() call, including the load of the config file at start. Use it to refresh your own objects that depend on configuration values.
ON('$reconfigure', function() {
MAIN.client = createclient(CONF.service_url);
});
config
totalapi : String|Boolean
since 0.0.16
Sets the Total API token or turns Total API on or off.
totalapi : String|BooleanReturns String|Boolean
A string longer than five characters is stored as CONF.secret_totalapi, the token for API('TAPI', ...) and TotalAPI() calls. Any other value is stored as $tapi.
totalapi : your-total-api-token
config
$root : String
A URL prefix for the whole application.
$root : StringReturns String
Normalized to start and end with /. Route URLs get the prefix (API routes through $api), static files are served under it and F.virtualpath() adds it. Use it when the application runs under a sub-path behind a proxy.
Default: ''.
$root : /app/
config
$api : String
The default API endpoint.
$api : StringReturns String
A ? in a route URL is replaced with this value, so ROUTE('API ?/users/ ...') listens on /api/users/. With $root, the prefix is added to it.
Default: '/api/'.
$api : /v1/
config
$mcp : Boolean
Turns on the MCP server.
$mcp : BooleanReturns Boolean
true creates the route POST /$mcp/, where AI clients list and call the actions that have mcp: true. The route is created when the application is ready, so set the key in the config file or before the start. See MCP server.
Default: false.
$mcp : true
config
$cors : String
Origins allowed for cross-origin requests.
$cors : StringReturns String
* allows every origin. Otherwise a list of origins separated by ,, ; or |, compared with the Origin header (for example https://app.example.com). An item that starts with * matches every origin that contains the rest (*example.com). Requests from the same host are always allowed; other origins get the error 400. CORS() changes the value in code; see Routing.
Default: ''.
$cors : https://app.example.com, *example.org
config
$port : Number
The port of the HTTP server.
$port : NumberReturns Number
The value is converted to a number. Leave the key out for the automatic port: the port option of F.http(), the PORT environment variable, the first 3-5 digit number in the command line arguments, or 8000.
Default: 'auto'.
$port : 8000
config
$ip : String
The IP address the HTTP server listens on.
$ip : StringReturns String
The ip option of F.http() overrides it. Use 127.0.0.1 to accept only local connections.
Default: '0.0.0.0'.
$ip : 127.0.0.1
config
$unixsocket : String
A Unix socket path for the HTTP server.
$unixsocket : StringReturns String
When set (or when F.http() gets the unixsocket option), the server listens on the socket instead of a port.
Default: ''.
$unixsocket : /var/run/app.sock
config
$timezone : String
The time zone of the process.
$timezone : StringReturns String
Copied into process.env.TZ, so all Date values of the process use it.
Default: 'utc'.
$timezone : Europe/Bratislava
config
$insecure : Boolean
Accepts invalid TLS certificates in outgoing requests.
$insecure : BooleanReturns Boolean
Sets process.env.NODE_TLS_REJECT_UNAUTHORIZED to 0 when true and 1 otherwise. Use it only for development against self-signed servers.
Default: false.
$insecure : true
config
$performance : Boolean
Tunes the HTTP sockets for many connections.
$performance : BooleanReturns Boolean
Sets maxSockets of the global HTTP agent to 9999 and turns on setNoDelay and keep-alive for incoming connections.
Default: false.
$performance : true
config
$httpreqlimit : Number
The maximum number of requests per IP address per minute.
$httpreqlimit : NumberReturns Number
0 turns the limit off. Above the limit, requests get the error 503 until the counters are cleared at the next minute.
Default: 0.
$httpreqlimit (number) : 300
config
$blacklist : String
Blocked IP addresses.
$blacklist : StringReturns String
A string of IP addresses, for example separated by commas. HTTP requests from an IP address found in it get the error 400, and WebSocket connections from it are closed.
Default: ''.
$blacklist : 10.0.0.5, 10.0.0.6
config
$httpcompress : Boolean
Compresses responses with gzip.
$httpcompress : BooleanReturns Boolean
When the client accepts gzip, text responses larger than 256 bytes and compressible static files are compressed.
Default: true.
$httpcompress : false
config
$httpetag : String
A value added to the ETag of static files and cached responses.
$httpetag : StringReturns String
When empty, it is created from CONF.version without dots and spaces, so a new version invalidates browser caches.
Default: ''.
$httpetag : build42
config
$httpmaxsize : Number
The maximum size of a request body in kB.
$httpmaxsize : NumberReturns Number
The default limit of every HTTP route without its own limit.
Default: 256.
$httpmaxsize (number) : 1024
config
$httprangebuffer : Number
The size of one chunk of a range response in kB.
$httprangebuffer : NumberReturns Number
Used for Range requests of static files (video, audio) when the client does not give the end.
Default: 5120.
$httprangebuffer (number) : 2048
config
$httptimeout : Number
The request timeout in seconds.
$httptimeout : NumberReturns Number
A route can set its own timeout. Requests are checked every five seconds.
Default: 5.
$httptimeout (number) : 10
config
$httpfiles : String
File extensions served as static files.
$httpfiles : StringReturns String
In the config file, a comma-separated list of extensions that are added to the defaults (jpg, png, css, js, json, pdf, mp4 and many more). In code it is an object with true for every allowed extension.
Default: common web extensions.
$httpfiles : glb, gltf
config
$httpchecktypes : Boolean
Checks the content type of uploaded files.
$httpchecktypes : BooleanReturns Boolean
For multipart/form-data only. false skips the check.
Default: true.
$httpchecktypes : false
config
$httpmaxage : Number
The max-age of cached responses in seconds.
$httpmaxage : NumberReturns Number
Used in the Cache-Control header of static files and of responses cached with controller.httpcache().
Default: 60.
$httpmaxage (number) : 300
config
$httpmaxkeys : Number
Limits of URL-encoded data.
$httpmaxkeys : NumberReturns Number
$httpmaxkeys is the maximum number of keys parsed from a query string or URL-encoded body. $httpmaxkey (default 25) is the maximum length of one key; longer keys are dropped.
Default: 33.
$httpmaxkeys (number) : 100
$httpmaxkey (number) : 50
config
$httpcacheoffset : String
since 0.0.16
Moves the Last-Modified date of static files.
$httpcacheoffset : StringReturns String
A time offset in the format of Date.add(), for example 1 minute or -5 minutes. It is added to the modification time of the file in the Last-Modified header.
Default: ''.
$httpcacheoffset : 1 minute
config
$xpoweredby : String
The value of the X-Powered-By header.
$xpoweredby : StringReturns String
An empty value removes the header.
Default: 'Total.js'.
$xpoweredby :
config
$minify* : Boolean
Minification of JavaScript, CSS and HTML.
$minify* : BooleanReturns Boolean
$minifyjs, $minifycss and $minifyhtml (all true by default) turn the minification of static .js and .css files, inline code and rendered HTML on or off.
$minifyhtml : false
$minifyjs : true
$minifycss : true
config
$filtererrors : Boolean
Ignores harmless uncaught errors.
$filtererrors : BooleanReturns Boolean
Uncaught EPIPE, invalid distance and ERR_IPC_CHANNEL_CLOSED errors are not logged.
Default: true.
$filtererrors : false
config
$cleartemp : Boolean
Clears the tmp directory at start.
$cleartemp : BooleanReturns Boolean
Deletes the .js, .css, .html, .htm, .tmp and .upload files of the tmp directory when the application loads.
Default: true.
$cleartemp : false
config
$customtitles : Boolean
Turns off the automatic suffix of page titles.
$customtitles : BooleanReturns Boolean
By default a view title on pages other than / gets - and CONF.name appended. true keeps the title as you set it.
Default: false.
$customtitles : true
config
$clearcache : Number
How often internal caches are cleared, in minutes.
$clearcache : NumberReturns Number
Clears the caches of actions, paths, views, images, templates, query builders and file storages.
Default: 10.
$clearcache (number) : 30
config
$imageconverter : String
The program used by the image module.
$imageconverter : StringReturns String
gm for GraphicsMagick, im for the ImageMagick convert command or magick for ImageMagick 7. See Images.
Default: 'gm'.
$imageconverter : magick
config
$stats : Boolean
Writes the statistics file of the application.
$stats : BooleanReturns Boolean
Every minute the framework writes the usage statistics to <main script>.json (for example index.js.json). F.load() with a list of types without stats turns it off.
Default: true.
$stats : false
config
$sourcemap : Boolean
Writes the source map of the application.
$sourcemap : BooleanReturns Boolean
Writes routes, actions, schemas and plugins to <main script>.map for tools. The framework sets it to the value of DEBUG when it loads all parts, and to false when F.load() gets a list of types without stats.
$sourcemap : false
config
$npmcache : String
The npm cache directory for NPMINSTALL().
$npmcache : StringReturns String
Passed to npm as NPM_CONFIG_CACHE.
Default: '/var/www/.npm'.
$npmcache : /tmp/.npm
config
$nodemodules : String
The directory of installed npm modules.
$nodemodules : StringReturns String
NPMINSTALL() installs into it and REQUIRE() loads from it when a normal require() fails.
Default: '<root>/node_modules'.
$nodemodules : /www/shared/node_modules
config
$python : String
The Python command.
$python : StringReturns String
Used by F.python() and F.pipinstall(). PYPELINE() always runs python3.
Default: 'python3'.
$python : /usr/bin/python3.12
config
$shell : String
The shell for SHELL().
$shell : StringReturns String
When set, SHELL() runs commands in this shell instead of the default one.
Default: ''.
$shell : /bin/bash
config
$wsmaxsize : Number
The maximum size of a WebSocket message in kB.
$wsmaxsize : NumberReturns Number
The default limit of every WebSocket route without its own limit.
Default: 256.
$wsmaxsize (number) : 1024
config
$wscompress : Boolean
Compresses WebSocket messages.
$wscompress : BooleanReturns Boolean
Uses permessage-deflate when the client supports it.
Default: true.
$wscompress : false
config
$wsencodedecode : Boolean
URL-encodes WebSocket messages.
$wsencodedecode : BooleanReturns Boolean
true encodes outgoing messages with encodeURIComponent and decodes incoming ones.
Default: false.
$wsencodedecode : true
config
$wsmaxlatency : Number
The maximum ping latency of a WebSocket client in milliseconds.
$wsmaxlatency : NumberReturns Number
When the framework pings the connections, clients without an answer or with a higher latency are closed.
Default: 2000.
$wsmaxlatency (number) : 5000
config
$proxytimeout : Number
The timeout of proxied requests in seconds.
$proxytimeout : NumberReturns Number
Used by PROXY() routes without their own timeout.
Default: 5.
$proxytimeout (number) : 30
config
$proxyrequest : String
A proxy server for outgoing requests.
$proxyrequest : StringReturns String
REQUEST() and the builders that use it send requests through this proxy (host:port, http://host:port). Requests to localhost and 127.0.0.1 go directly.
Default: not set.
$proxyrequest : http://proxy.local:3128
config
$cookie* : String|Boolean
Defaults of cookies.
$cookie* : String|BooleanReturns String|Boolean
$cookiesamesite (default Lax) is the SameSite value of cookies without their own. $cookiesecure (default false) adds Secure to cookies that do not set secure.
$cookiesamesite : Strict
$cookiesecure : true
config
$csrfexpiration : String
The lifetime of CSRF tokens.
$csrfexpiration : StringReturns String
A time in the format of Date.add(). Tokens are created only when secret_csrf is set.
Default: '30 minutes'.
$csrfexpiration : 2 hours
config
$crypto : String
A Node.js cipher for ENCRYPT() and DECRYPT().
$crypto : StringReturns String
When set (for example aes-256-cbc), ENCRYPT() and DECRYPT() use crypto.createCipheriv() with the key you pass and $cryptoiv as the IV; the key must have the length the cipher needs. $cryptoiv is created from a hash of the system; in the config file give it as hex or base64 and it becomes a Buffer.
Default: not set.
$crypto : aes-256-cbc
$cryptoiv : 000102030405060708090a0b0c0d0e0f
config
$tapi* : Boolean|String
Total API settings.
$tapi* : Boolean|StringReturns Boolean|String
$tapi (default true) allows API('TAPI', ...) calls; with false every operation except check fails with totalapi_inactive. $tapiurl (default eu) is the region in https://<region>.api.totaljs.com/. The token is secret_totalapi; $tapisecret is read as a fallback. $tapimail : true sends the e-mails through the Total API instead of SMTP (see Sending email) and $tapilogger : true sends the audit records there (see Audit logs); both are false by default.
secret_totalapi : your-token
$tapiurl : eu
config
$tms* : Boolean|String|Number
Total.js Message Service settings.
$tms* : Boolean|String|NumberReturns Boolean|String|Number
$tms (default false) opens the TMS WebSocket endpoint $tmsurl (default /$tms/). $tmsmaxsize (default 256) is the message limit in kB, $tmsclearblocked (default 60) clears blocked clients every N minutes, and secret_tms is the token clients must send. See Message Service (TMS).
$tms : true
secret_tms : my-secret
config
$imprint : Boolean
Prints the start screen.
$imprint : BooleanReturns Boolean
false hides the information block (name, version, Node.js, URL) printed when the application starts.
Default: true.
$imprint : false
config
$logger : Boolean
Writes console output to logs/debug.log.
$logger : BooleanReturns Boolean
true redirects console.log, console.warn, console.error, console.time and console.timeEnd to the file logs/debug.log.
Default: false.
$logger : true
config
$dir* : String
Custom paths of the application directories.
$dir* : StringReturns String
$dir + the name of a directory sets its absolute path: $dirpublic, $dirtmp, $dirlogs, $dirdatabases, $dirviews, $dirplugins, $dirmodules, $dirresources, $dirtemplates, $dirprivate and the others. PATH.public(), PATH.databases() and the loaders use them.
$dirpublic : /www/cdn/public
$dirdatabases : /data/app