> ## Documentation Index
> Fetch the complete documentation index at: https://docs.plato.ae/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuration

> Configure server, HTTPS, Redis, and queue behavior.

# Configuration

The driver reads `config.json` from the application root:

* Bundled executable: next to `plato-printer.exe`.
* Development: current working directory.

If `config.json` is missing, the driver creates one with sanitized defaults.

## Example Config

```json theme={null}
{
  "server": {
    "port": 8080
  },
  "features": {
    "meshEnabled": true,
    "httpsEnabled": true
  },
  "caddy": {
    "enabled": true,
    "domain": "plato-printer.local",
    "httpsPort": 443,
    "version": "2.6.4"
  },
  "redis": {
    "mode": "embedded",
    "version": "6.2.14",
    "host": "127.0.0.1",
    "port": 6379,
    "db": 0,
    "username": "",
    "password": "",
    "diskSync": true,
    "snapshotIntervalSec": 30
  },
  "queue": {
    "retryDelayMs": 5000,
    "maxAttempts": 2147483647
  }
}
```

## Server

| Field         | Default | Notes                            |
| ------------- | ------- | -------------------------------- |
| `server.port` | `8080`  | HTTP port for all API endpoints. |

The Express app enables permissive CORS and `Access-Control-Allow-Private-Network: true` so browser POS clients can call the driver from local/private networks.

## Features

| Field                   | Default | Notes                                          |
| ----------------------- | ------- | ---------------------------------------------- |
| `features.meshEnabled`  | `true`  | Enables PeerJS signaling on `/mesh`.           |
| `features.httpsEnabled` | `true`  | Allows HTTPS setup when Caddy is also enabled. |

HTTPS only starts when both `features.httpsEnabled` and `caddy.enabled` are true.

## Caddy

| Field             | Default               | Notes                                 |
| ----------------- | --------------------- | ------------------------------------- |
| `caddy.enabled`   | `true`                | Enables the Caddy reverse proxy path. |
| `caddy.domain`    | `plato-printer.local` | Hostname used for HTTPS.              |
| `caddy.httpsPort` | `443`                 | HTTPS listener port.                  |
| `caddy.version`   | `2.6.4`               | Pinned for Windows 7 compatibility.   |

On Windows 7 or older, the driver rejects HTTPS configs that use a Caddy version other than `2.6.4`.

## Redis

| Field                       | Default                   | Notes                                                                                                |
| --------------------------- | ------------------------- | ---------------------------------------------------------------------------------------------------- |
| `redis.mode`                | `embedded`                | `embedded` starts Redis from the driver; `external` uses an existing Redis server.                   |
| `redis.version`             | `6.2.14`                  | Required embedded Redis version.                                                                     |
| `redis.host`                | `127.0.0.1`               | Redis bind/connect host.                                                                             |
| `redis.port`                | `6379`                    | Redis port.                                                                                          |
| `redis.db`                  | `0`                       | Redis database number.                                                                               |
| `redis.username`            | empty                     | Used for external Redis auth when set.                                                               |
| `redis.password`            | empty                     | Used for external Redis auth when set.                                                               |
| `redis.diskSync`            | `false` generated default | Writes Redis snapshots to `dump.rdb` when true. The committed production config sets this to `true`. |
| `redis.snapshotIntervalSec` | `30`                      | Snapshot interval used when disk sync is enabled.                                                    |

Embedded Redis startup aborts the whole driver if Redis cannot start or if the actual Redis version does not match `redis.version`.

## Queue

| Field                | Default      | Notes                                                                     |
| -------------------- | ------------ | ------------------------------------------------------------------------- |
| `queue.retryDelayMs` | `5000`       | Fixed retry backoff for failed print jobs.                                |
| `queue.maxAttempts`  | `2147483647` | Maximum attempts per job. The current config effectively retries forever. |

## Sanitization

The config reader sanitizes values:

* Ports and numeric settings must be positive integers.
* Booleans can be booleans or strings `"true"` / `"false"`.
* `redis.mode` must be `embedded` or `external`.
* Empty strings fall back to defaults for domain/version/host-like fields.
