---
title: Configuration
project: Total.js V5
version: 0.0.20
section: reference
language: en
license: MIT
url: https://totaljs.es/docs/total-js-v5/0-0-20/reference/configuration/
updated: 2026-11-18T16:57:29.576Z
---

# Configuration

> CONF, LOADCONFIG(), DEBUG and every $ key of the framework with its default.

Every key the framework reads from `CONF`, with its type and default, plus `CONF`, `LOADCONFIG()`, `DEBUG` and the `$reconfigure` event. The guide [Configuration](../../guides/configuration/) explains the format of the `config` file, the types, `.env` and the loading order.

## API

### CONF

Type: `property`

The global object with the configuration of the application.

Returns: `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.

Example: Read values
```js
exports.install = function() {
	ROUTE('GET /about/', function($) {
		$.json({ name: CONF.name, version: CONF.version });
	});
};
```

### LOADCONFIG(value)

Type: `method`

Applies configuration values at runtime.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `value` | `String|Object|Array` | yes |  | 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.

Example: Text
```js
LOADCONFIG('$httptimeout (number) : 15\nmaintenance : true');
```

Example: Array with types
```js
LOADCONFIG([
	{ id: 'limit', type: 'number', value: '25' },
	{ id: 'tags', type: 'array', value: 'a, b, c' }
]);
```

Example: Object
```js
LOADCONFIG({ name: 'Shop', $cors: 'https://shop.example.com' });
```

### DEBUG

Type: `property`

true in debug mode, false in release mode.

Returns: `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).

Example: Conditional code
```js
if (DEBUG)
	console.log('Debug mode');
```

### ON('$reconfigure', function() {})

Type: `event`

Emitted after LOADCONFIG() applies new values.

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.

Example: Refresh a client
```js
ON('$reconfigure', function() {
	MAIN.client = createclient(CONF.service_url);
});
```

### totalapi : String|Boolean

Type: `config` · Since: `0.0.16`

Sets the Total API token or turns Total API on or off.

Returns: `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`.

Example: In the config file
```text
totalapi : your-total-api-token
```

### $root : String

Type: `config`

A URL prefix for the whole application.

Returns: `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: `''`.

Example: In the config file
```text
$root : /app/
```

### $api : String

Type: `config`

The default API endpoint.

Returns: `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/'`.

Example: In the config file
```text
$api : /v1/
```

### $mcp : Boolean

Type: `config`

Turns on the MCP server.

Returns: `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](../../guides/mcp-server/).

Default: `false`.

Example: In the config file
```text
$mcp : true
```

### $cors : String

Type: `config`

Origins allowed for cross-origin requests.

Returns: `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](../../guides/routing/#cors).

Default: `''`.

Example: In the config file
```text
$cors : https://app.example.com, *example.org
```

### $port : Number

Type: `config`

The port of the HTTP server.

Returns: `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'`.

Example: In the config file
```text
$port : 8000
```

### $ip : String

Type: `config`

The IP address the HTTP server listens on.

Returns: `String`

The `ip` option of `F.http()` overrides it. Use `127.0.0.1` to accept only local connections.

Default: `'0.0.0.0'`.

Example: In the config file
```text
$ip : 127.0.0.1
```

### $unixsocket : String

Type: `config`

A Unix socket path for the HTTP server.

Returns: `String`

When set (or when `F.http()` gets the `unixsocket` option), the server listens on the socket instead of a port.

Default: `''`.

Example: In the config file
```text
$unixsocket : /var/run/app.sock
```

### $timezone : String

Type: `config`

The time zone of the process.

Returns: `String`

Copied into `process.env.TZ`, so all `Date` values of the process use it.

Default: `'utc'`.

Example: In the config file
```text
$timezone : Europe/Bratislava
```

### $insecure : Boolean

Type: `config`

Accepts invalid TLS certificates in outgoing requests.

Returns: `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`.

Example: In the config file
```text
$insecure : true
```

### $performance : Boolean

Type: `config`

Tunes the HTTP sockets for many connections.

Returns: `Boolean`

Sets `maxSockets` of the global HTTP agent to 9999 and turns on `setNoDelay` and keep-alive for incoming connections.

Default: `false`.

Example: In the config file
```text
$performance : true
```

### $httpreqlimit : Number

Type: `config`

The maximum number of requests per IP address per minute.

Returns: `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`.

Example: In the config file
```text
$httpreqlimit (number) : 300
```

### $blacklist : String

Type: `config`

Blocked IP addresses.

Returns: `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: `''`.

Example: In the config file
```text
$blacklist : 10.0.0.5, 10.0.0.6
```

### $httpcompress : Boolean

Type: `config`

Compresses responses with gzip.

Returns: `Boolean`

When the client accepts gzip, text responses larger than 256 bytes and compressible static files are compressed.

Default: `true`.

Example: In the config file
```text
$httpcompress : false
```

### $httpetag : String

Type: `config`

A value added to the ETag of static files and cached responses.

Returns: `String`

When empty, it is created from `CONF.version` without dots and spaces, so a new version invalidates browser caches.

Default: `''`.

Example: In the config file
```text
$httpetag : build42
```

### $httpmaxsize : Number

Type: `config`

The maximum size of a request body in kB.

Returns: `Number`

The default limit of every HTTP route without its own limit.

Default: `256`.

Example: In the config file
```text
$httpmaxsize (number) : 1024
```

### $httprangebuffer : Number

Type: `config`

The size of one chunk of a range response in kB.

Returns: `Number`

Used for `Range` requests of static files (video, audio) when the client does not give the end.

Default: `5120`.

Example: In the config file
```text
$httprangebuffer (number) : 2048
```

### $httptimeout : Number

Type: `config`

The request timeout in seconds.

Returns: `Number`

A route can set its own timeout. Requests are checked every five seconds.

Default: `5`.

Example: In the config file
```text
$httptimeout (number) : 10
```

### $httpfiles : String

Type: `config`

File extensions served as static files.

Returns: `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`.

Example: In the config file
```text
$httpfiles : glb, gltf
```

### $httpchecktypes : Boolean

Type: `config`

Checks the content type of uploaded files.

Returns: `Boolean`

For `multipart/form-data` only. `false` skips the check.

Default: `true`.

Example: In the config file
```text
$httpchecktypes : false
```

### $httpmaxage : Number

Type: `config`

The max-age of cached responses in seconds.

Returns: `Number`

Used in the `Cache-Control` header of static files and of responses cached with `controller.httpcache()`.

Default: `60`.

Example: In the config file
```text
$httpmaxage (number) : 300
```

### $httpmaxkeys : Number

Type: `config`

Limits of URL-encoded data.

Returns: `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`.

Example: In the config file
```text
$httpmaxkeys (number) : 100
$httpmaxkey (number)  : 50
```

### $httpcacheoffset : String

Type: `config` · Since: `0.0.16`

Moves the Last-Modified date of static files.

Returns: `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: `''`.

Example: In the config file
```text
$httpcacheoffset : 1 minute
```

### $xpoweredby : String

Type: `config`

The value of the X-Powered-By header.

Returns: `String`

An empty value removes the header.

Default: `'Total.js'`.

Example: In the config file
```text
$xpoweredby :
```

### $minify* : Boolean

Type: `config`

Minification of JavaScript, CSS and HTML.

Returns: `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.

Example: In the config file
```text
$minifyhtml : false
$minifyjs   : true
$minifycss  : true
```

### $filtererrors : Boolean

Type: `config`

Ignores harmless uncaught errors.

Returns: `Boolean`

Uncaught `EPIPE`, `invalid distance` and `ERR_IPC_CHANNEL_CLOSED` errors are not logged.

Default: `true`.

Example: In the config file
```text
$filtererrors : false
```

### $cleartemp : Boolean

Type: `config`

Clears the tmp directory at start.

Returns: `Boolean`

Deletes the `.js`, `.css`, `.html`, `.htm`, `.tmp` and `.upload` files of the `tmp` directory when the application loads.

Default: `true`.

Example: In the config file
```text
$cleartemp : false
```

### $customtitles : Boolean

Type: `config`

Turns off the automatic suffix of page titles.

Returns: `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`.

Example: In the config file
```text
$customtitles : true
```

### $clearcache : Number

Type: `config`

How often internal caches are cleared, in minutes.

Returns: `Number`

Clears the caches of actions, paths, views, images, templates, query builders and file storages.

Default: `10`.

Example: In the config file
```text
$clearcache (number) : 30
```

### $imageconverter : String

Type: `config`

The program used by the image module.

Returns: `String`

`gm` for GraphicsMagick, `im` for the ImageMagick `convert` command or `magick` for ImageMagick 7. See [Images](../../guides/images/).

Default: `'gm'`.

Example: In the config file
```text
$imageconverter : magick
```

### $stats : Boolean

Type: `config`

Writes the statistics file of the application.

Returns: `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`.

Example: In the config file
```text
$stats : false
```

### $sourcemap : Boolean

Type: `config`

Writes the source map of the application.

Returns: `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`.

Example: Turn off
```text
$sourcemap : false
```

### $npmcache : String

Type: `config`

The npm cache directory for NPMINSTALL().

Returns: `String`

Passed to npm as `NPM_CONFIG_CACHE`.

Default: `'/var/www/.npm'`.

Example: In the config file
```text
$npmcache : /tmp/.npm
```

### $nodemodules : String

Type: `config`

The directory of installed npm modules.

Returns: `String`

`NPMINSTALL()` installs into it and `REQUIRE()` loads from it when a normal `require()` fails.

Default: `'<root>/node_modules'`.

Example: In the config file
```text
$nodemodules : /www/shared/node_modules
```

### $python : String

Type: `config`

The Python command.

Returns: `String`

Used by `F.python()` and `F.pipinstall()`. `PYPELINE()` always runs `python3`.

Default: `'python3'`.

Example: In the config file
```text
$python : /usr/bin/python3.12
```

### $shell : String

Type: `config`

The shell for SHELL().

Returns: `String`

When set, `SHELL()` runs commands in this shell instead of the default one.

Default: `''`.

Example: In the config file
```text
$shell : /bin/bash
```

### $wsmaxsize : Number

Type: `config`

The maximum size of a WebSocket message in kB.

Returns: `Number`

The default limit of every WebSocket route without its own limit.

Default: `256`.

Example: In the config file
```text
$wsmaxsize (number) : 1024
```

### $wscompress : Boolean

Type: `config`

Compresses WebSocket messages.

Returns: `Boolean`

Uses `permessage-deflate` when the client supports it.

Default: `true`.

Example: In the config file
```text
$wscompress : false
```

### $wsencodedecode : Boolean

Type: `config`

URL-encodes WebSocket messages.

Returns: `Boolean`

`true` encodes outgoing messages with `encodeURIComponent` and decodes incoming ones.

Default: `false`.

Example: In the config file
```text
$wsencodedecode : true
```

### $wsmaxlatency : Number

Type: `config`

The maximum ping latency of a WebSocket client in milliseconds.

Returns: `Number`

When the framework pings the connections, clients without an answer or with a higher latency are closed.

Default: `2000`.

Example: In the config file
```text
$wsmaxlatency (number) : 5000
```

### $proxytimeout : Number

Type: `config`

The timeout of proxied requests in seconds.

Returns: `Number`

Used by `PROXY()` routes without their own timeout.

Default: `5`.

Example: In the config file
```text
$proxytimeout (number) : 30
```

### $proxyrequest : String

Type: `config`

A proxy server for outgoing requests.

Returns: `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`.

Example: In the config file
```text
$proxyrequest : http://proxy.local:3128
```

### $cookie* : String|Boolean

Type: `config`

Defaults of cookies.

Returns: `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`.

Example: In the config file
```text
$cookiesamesite : Strict
$cookiesecure   : true
```

### $csrfexpiration : String

Type: `config`

The lifetime of CSRF tokens.

Returns: `String`

A time in the format of `Date.add()`. Tokens are created only when `secret_csrf` is set.

Default: `'30 minutes'`.

Example: In the config file
```text
$csrfexpiration : 2 hours
```

### $crypto : String

Type: `config`

A Node.js cipher for ENCRYPT() and DECRYPT().

Returns: `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`.

Example: In the config file
```text
$crypto   : aes-256-cbc
$cryptoiv : 000102030405060708090a0b0c0d0e0f
```

### $tapi* : Boolean|String

Type: `config`

Total API settings.

Returns: `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](../../guides/mail/)) and `$tapilogger : true` sends the audit records there (see [Audit logs](../../guides/audit-logs/)); both are `false` by default.

Example: In the config file
```text
secret_totalapi : your-token
$tapiurl        : eu
```

### $tms* : Boolean|String|Number

Type: `config`

Total.js Message Service settings.

Returns: `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)](../../guides/message-service-and-apis/).

Example: In the config file
```text
$tms       : true
secret_tms : my-secret
```

### $imprint : Boolean

Type: `config`

Prints the start screen.

Returns: `Boolean`

`false` hides the information block (name, version, Node.js, URL) printed when the application starts.

Default: `true`.

Example: In the config file
```text
$imprint : false
```

### $logger : Boolean

Type: `config`

Writes console output to logs/debug.log.

Returns: `Boolean`

`true` redirects `console.log`, `console.warn`, `console.error`, `console.time` and `console.timeEnd` to the file `logs/debug.log`.

Default: `false`.

Example: In the config file
```text
$logger : true
```

### $dir* : String

Type: `config`

Custom paths of the application directories.

Returns: `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.

Example: In the config file
```text
$dirpublic    : /www/cdn/public
$dirdatabases : /data/app
```
