Tina4

Environment Variables#

⚠️ BREAKING CHANGE: Tina4 v3.12.0

Every framework env var now requires the TINA4_ prefix. The legacy un-prefixed names (DATABASE_URL, SECRET, SMTP_HOST, HOST_NAME, etc.) no longer work. Setting them at startup makes the framework refuse to boot with a list of renames.

Run tina4 env --migrate to rewrite your existing .env automatically, or rename manually using the table below. The runtime guard prints the same mapping if it detects legacy names.

Conventional names stay un-prefixed: PORT, HOST, NODE_ENV, RACK_ENV, RUBY_ENV, ENVIRONMENT. These are runtime/PaaS conventions, not framework config.

Tina4 Node.js is configured through environment variables, read from .env at the project root. Every variable has a sensible default; most projects set three or four values and leave the rest alone.

This chapter lists every variable the Node.js framework reads, grouped by subsystem. Start with the minimum-config examples at the end, then come back here when you need to tune something specific.


Core Server#

VariableDefaultDescription
HOST0.0.0.0Bind address. 0.0.0.0 listens on every interface. 127.0.0.1 restricts to localhost.
TINA4_HOST0.0.0.0Framework-prefixed bind address. Takes precedence over HOST when both are set.
PORT7148HTTP server port. The Rust CLI prefers TINA4_PORT but falls back to PORT.
TINA4_PORT(inherits PORT)Explicit Tina4-specific port override. Takes precedence over PORT when both are set.
TINA4_HOST_NAMElocalhost:7148Fully-qualified host used in generated absolute URLs (Swagger, OAuth redirects, emails).
TINA4_DEBUGfalseMaster debug toggle. Enables Swagger UI, dev dashboard, live reload, template dump filter, error overlay. Never set to true in production.
TINA4_SUPPRESSfalseSuppresses the boot banner on startup. Useful for clean CI logs and embedded usage.
TINA4_ENV_FILE.envPath to the dotenv file loaded at startup. Relative paths resolve from the project root.
TINA4_HEALTH_PATH/__healthPath for the built-in health endpoint. Legacy /health alias is also registered when this points at /__health.
TINA4_NO_BROWSERfalseStops tina4 serve from opening your browser on every restart.
TINA4_NO_RELOADfalseDisables the dev hot-reload signal from the Rust CLI. Use when you want a stable server for debugging.
TINA4_PRODUCTIONfalseForces production-mode startup (cluster mode, debug overlays disabled). Set automatically by tina4 serve --production.
TINA4_ALLOW_LEGACY_ENVfalseBypass the v3.12 env-prefix guard. CI / migration scripts only, never enable in production.

Secrets and Authentication#

VariableDefaultDescription
TINA4_SECRET(empty)JWT signing secret. Must be long, random, and unique per environment. Never commit.
TINA4_JWT_ALGORITHMHS256JWT signing algorithm. Supports HS256, HS384, HS512.
TINA4_TOKEN_LIMIT60JWT token lifetime in minutes.
TINA4_API_KEY(empty)Static API key used as a fallback to JWT.

Database#

VariableDefaultDescription
TINA4_DATABASE_URL(required)Connection URL. Scheme selects the driver: sqlite, postgres, mysql.
TINA4_DATABASE_USERNAME(empty)Overrides the username embedded in TINA4_DATABASE_URL.
TINA4_DATABASE_PASSWORD(empty)Overrides the password embedded in TINA4_DATABASE_URL.
TINA4_DATABASE_FIREBIRD_PATH(empty)Overrides the database path/alias parsed from TINA4_DATABASE_URL for Firebird. Useful for Windows backslash paths and split-config setups.
TINA4_AUTOCOMMITtrueStandalone writes auto-commit on their own connection (durable + visible across a pool); explicit transactions stay atomic. Set false for strict manual-commit mode.
TINA4_DB_CACHEfalseEnables in-memory query-result caching for read queries.
TINA4_DB_CACHE_TTL30Query cache TTL in seconds when TINA4_DB_CACHE=true.
TINA4_DB_POOL0Connection-pool size override. Applied to the database adapter's pool config when not set explicitly in code. 0 leaves the adapter default in place.
TINA4_ORM_PLURAL_TABLE_NAMEStrueWhen true, the ORM pluralises class names into table names (Userusers).

CORS#

VariableDefaultDescription
TINA4_CORS_ORIGINS*Comma-separated allowed origins. Lock down to real domains in production.
TINA4_CORS_METHODSGET,POST,PUT,PATCH,DELETE,OPTIONSComma-separated list of allowed methods on preflight responses.
TINA4_CORS_HEADERSContent-Type,AuthorizationComma-separated list of allowed request headers on preflight responses.
TINA4_CORS_MAX_AGE86400Preflight cache lifetime in seconds.
TINA4_CORS_CREDENTIALStrueSets Access-Control-Allow-Credentials.

Security Headers#

VariableDefaultDescription
TINA4_CSPdefault-src 'self'Content-Security-Policy header.
TINA4_CSRFfalseCSRF token validation on POST/PUT/PATCH/DELETE.
TINA4_HSTS(empty/off)Strict-Transport-Security max-age in seconds. Set 31536000 in production with HTTPS.
TINA4_FRAME_OPTIONSSAMEORIGINX-Frame-Options header.
TINA4_REFERRER_POLICYstrict-origin-when-cross-originReferrer-Policy header.
TINA4_PERMISSIONS_POLICYcamera=(), microphone=(), geolocation=()Permissions-Policy header.

Rate Limiting#

VariableDefaultDescription
TINA4_RATE_LIMIT100Maximum requests per window per IP. Set 0 to disable.
TINA4_RATE_WINDOW60Rate-limit window in seconds.

Sessions#

VariableDefaultDescription
TINA4_SESSION_BACKENDfileStorage backend. Options: file, redis, valkey, mongo, database.
TINA4_SESSION_NAMEtina4_sessionSession cookie name.
TINA4_SESSION_TTL1800Session expiry in seconds (30 minutes).
TINA4_SESSION_SAMESITELaxSameSite cookie attribute. Options: Strict, Lax, None.
TINA4_SESSION_HTTPONLYtrueEmit the HttpOnly flag on the session cookie.
TINA4_SESSION_SECUREfalseEmit the Secure flag on the session cookie. Enable behind HTTPS.
TINA4_SESSION_PATHdata/sessionsFilesystem path for the file backend.

Redis/Valkey session backend#

VariableDefaultDescription
TINA4_SESSION_REDIS_URL(none)Full redis:// URL. Overrides host/port when set.
TINA4_SESSION_REDIS_HOST127.0.0.1Redis host.
TINA4_SESSION_REDIS_PORT6379Redis port.
TINA4_SESSION_REDIS_PASSWORD(none)Redis auth password.
TINA4_SESSION_REDIS_DB0Redis database number.
TINA4_SESSION_REDIS_PREFIXtina4:session:Key prefix for stored sessions.
TINA4_SESSION_VALKEY_HOST127.0.0.1Valkey host.
TINA4_SESSION_VALKEY_PORT6379Valkey port.
TINA4_SESSION_VALKEY_PASSWORD(none)Valkey auth password.
TINA4_SESSION_VALKEY_DB0Valkey database number.
TINA4_SESSION_VALKEY_PREFIXtina4:session:Key prefix for stored sessions.

MongoDB session backend#

VariableDefaultDescription
TINA4_SESSION_MONGO_URI(none)Full MongoDB connection string. Overrides host/port when set.
TINA4_SESSION_MONGO_HOST127.0.0.1MongoDB host.
TINA4_SESSION_MONGO_PORT27017MongoDB port.
TINA4_SESSION_MONGO_USERNAME(none)MongoDB username.
TINA4_SESSION_MONGO_PASSWORD(none)MongoDB password.
TINA4_SESSION_MONGO_DBtina4_sessionsMongoDB database name.
TINA4_SESSION_MONGO_COLLECTIONsessionsMongoDB collection name.

Cache#

VariableDefaultDescription
TINA4_CACHE_BACKENDmemoryResponse cache backend. Options: memory, file, redis, valkey, memcached, mongodb, database. Falls back to file if the configured backend is unreachable.
TINA4_CACHE_DIRdata/cacheCache directory for the file backend.
TINA4_CACHE_TTL60Default cache TTL in seconds.
TINA4_CACHE_MAX_ENTRIES1000Maximum cache entries.
TINA4_CACHE_URLredis://localhost:6379Connection URL for remote cache backends. For database, falls back to TINA4_DATABASE_URL when unset.
TINA4_CACHE_USERNAME(none)Username for the cache backend. May also be embedded in TINA4_CACHE_URL.
TINA4_CACHE_PASSWORD(none)Password for the cache backend. May also be embedded in TINA4_CACHE_URL (e.g. redis://:pass@host). Memcached is unauthenticated.

Queues#

VariableDefaultDescription
TINA4_QUEUE_BACKENDfileQueue backend. Options: file, rabbitmq, kafka, mongodb.
TINA4_QUEUE_PATHdata/queueFilesystem path for the file backend.
TINA4_QUEUE_URL(none)Connection URL for remote backends (rabbitmq/kafka).

Kafka queue backend#

VariableDefaultDescription
TINA4_KAFKA_BROKERSlocalhost:9092Comma-separated broker list.
TINA4_KAFKA_GROUP_IDtina4_consumer_groupKafka consumer group ID.

RabbitMQ queue backend#

VariableDefaultDescription
TINA4_RABBITMQ_HOSTlocalhostRabbitMQ host.
TINA4_RABBITMQ_PORT5672RabbitMQ port.
TINA4_RABBITMQ_USERNAMEguestRabbitMQ username.
TINA4_RABBITMQ_PASSWORDguestRabbitMQ password.
TINA4_RABBITMQ_VHOST/RabbitMQ virtual host.

MongoDB queue backend#

VariableDefaultDescription
TINA4_MONGO_URI(none)Full MongoDB connection string. Overrides host/port when set.
TINA4_MONGO_HOSTlocalhostMongoDB host.
TINA4_MONGO_PORT27017MongoDB port.
TINA4_MONGO_USERNAME(none)MongoDB username.
TINA4_MONGO_PASSWORD(none)MongoDB password.
TINA4_MONGO_DBtina4MongoDB database name.
TINA4_MONGO_COLLECTIONtina4_queueMongoDB collection name for jobs.

WebSocket#

VariableDefaultDescription
TINA4_WS_PORT8080Default WebSocket server port when one isn't passed to the constructor.
TINA4_WS_BACKPLANE(none)Backplane type for multi-instance broadcasts. Options: redis, nats.
TINA4_WS_BACKPLANE_URLredis://localhost:6379 (redis) / nats://localhost:4222 (nats)Connection URL for the chosen backplane.

Email#

VariableDefaultDescription
TINA4_MAIL_HOST(none)SMTP server hostname.
TINA4_MAIL_PORT587SMTP server port.
TINA4_MAIL_USERNAME(none)SMTP authentication username.
TINA4_MAIL_PASSWORD(none)SMTP authentication password.
TINA4_MAIL_FROM(none)Default sender email address.
TINA4_MAIL_FROM_NAME(none)Default sender display name.
TINA4_MAIL_ENCRYPTIONtlsConnection encryption. Options: tls, ssl, none.
TINA4_MAIL_IMAP_HOST(none)IMAP server for inbound mail.
TINA4_MAIL_IMAP_PORT993IMAP server port.
TINA4_MAIL_IMAP_ENCRYPTIONtlsIMAP transport security. Options: tls, starttls, none. Node also accepts ssl as an alias for tls for back-compat.
TINA4_MAILBOX_DIRdata/mailboxDev mailbox directory. All outbound mail lands here when TINA4_DEBUG=true.

TINA4_MAIL_HOST, TINA4_MAIL_PORT, TINA4_MAIL_USERNAME, TINA4_MAIL_PASSWORD, TINA4_MAIL_FROM, TINA4_MAIL_FROM_NAME, TINA4_MAIL_IMAP_HOST, TINA4_MAIL_IMAP_PORT, TINA4_MAIL_IMAP_USERNAME, TINA4_MAIL_IMAP_PASSWORD are accepted as legacy aliases. New projects should use the TINA4_MAIL_* names.


Logging#

Logs default to stdout. Set TINA4_LOG_OUTPUT=file plus TINA4_LOG_FILE=app.log to write to disk; the framework rotates at TINA4_LOG_ROTATE_SIZE bytes and keeps TINA4_LOG_ROTATE_KEEP backups using stdlib fs calls.

VariableDefaultDescription
TINA4_LOG_LEVELDEBUGMinimum log level written to console and files. Options: DEBUG, INFO, WARNING, ERROR, ALL.
TINA4_LOG_MAX_SIZE10Per-file log size limit in megabytes. Rotated when exceeded.
TINA4_LOG_KEEP5Number of rotated log files to retain.

File logging#

VariableDefaultDescription
TINA4_LOG_FILE(empty = stdout only)Explicit log file path. Absolute paths are used as-is; relative paths resolve against TINA4_LOG_DIR.
TINA4_LOG_DIRlogsDirectory for log files when TINA4_LOG_FILE is relative or unset.
TINA4_LOG_FORMATtextFile log format. Options: text, json.
TINA4_LOG_OUTPUTstdoutWhere to write logs. Options: stdout, file, both.
TINA4_LOG_CRITICALfalseEnable the CRITICAL level shortcut. Off by default to keep the log surface compact.
TINA4_LOG_ROTATE_SIZE10485760Rotate the file when it reaches this many bytes (10 MB). 0 disables rotation. Node uses an atomic fs.renameSync shift on each write.
TINA4_LOG_ROTATE_KEEP5Number of rotated historical files to retain.

Localisation#

VariableDefaultDescription
TINA4_LOCALEenDefault locale for the I18n module.
TINA4_LOCALE_DIRsrc/localesDirectory containing locale JSON files.

Uploads#

VariableDefaultDescription
TINA4_MAX_UPLOAD_SIZE10485760Maximum multipart upload size in bytes (10 MB).

Services (background tasks)#

VariableDefaultDescription
TINA4_SERVICE_DIRsrc/servicesDirectory scanned for service classes.
TINA4_SERVICE_SLEEP5Seconds the service runner sleeps between empty polls.

Routing#

VariableDefaultDescription
TINA4_TEMPLATE_ROUTINGonAuto-route any request without a matching handler to a same-named Frond template. Set to off, false, 0, no, or disabled for explicit-only routing.
TINA4_TRAILING_SLASH_REDIRECTfalseWhen true, requests with a trailing slash are 301-redirected to the canonical no-trailing-slash form.

Templates#

VariableDefaultDescription
TINA4_TEMPLATE_CACHE_TTL0Frond template cache TTL in seconds. 0 (the default) caches permanently for the process lifetime.

GraphQL#

VariableDefaultDescription
TINA4_GRAPHQL_AUTO_SCHEMAtrueAuto-build a schema from registered ORM models when the dev server starts. Set false to require an explicit schema.
TINA4_GRAPHQL_ENDPOINT/graphqlPath the GraphQL handler is mounted on.

Application AI Client and Developer AI Tools#

The app-facing Ai client and the developer dashboard share the TINA4_AI_* namespace. The client supports local OpenAI-compatible servers, OpenAI, and Anthropic. See Chapter 39: AI Client for code examples.

VariableDefaultDescription
TINA4_AI_PROVIDERlocalProvider used by the app-facing client: local, openai, or anthropic.
TINA4_AI_URLProvider-specificBase URL or full endpoint. Local defaults to http://localhost:11437; OpenAI and Anthropic use their public API bases.
TINA4_AI_MODELProvider-specificDefault model. Local uses llama3.2, OpenAI uses gpt-4o-mini, and Anthropic uses claude-3-5-haiku-latest.
TINA4_AI_KEY(none)Required before an OpenAI or Anthropic request. Local requests need no key.
TINA4_AI_TIMEOUT60Total request deadline in seconds, including retries and response reads.
TINA4_AI_CONNECT_TIMEOUT10Connection-establishment deadline in seconds.
TINA4_AI_MAX_RETRIES2Retries before output for connection failures, HTTP 429, and HTTP 5xx.
TINA4_EMBED_URL(inherits TINA4_AI_URL)Optional embedding base URL or full endpoint.
TINA4_RAG_URLhttp://localhost:11438RAG service used by the developer dashboard.
TINA4_RAG_TOPK4Number of RAG matches returned per query.
TINA4_VISION_URLhttp://localhost:11437/api/chatVision endpoint used by developer tools, not the app-facing AI client.
TINA4_IMAGE_URLhttp://localhost:11437/api/generateImage endpoint used by developer tools, not the app-facing AI client.
TINA4_SUPERVISOR_URLhttp://localhost:9999Rust supervisor URL used by developer tools.
TINA4_MCP_REMOTEfalseAllows MCP to bind beyond localhost. Do not enable it on a public production interface.
TINA4_NO_AI_PORTfalseDisables the developer AI port listener.
TINA4_OVERRIDE_CLIENTfalseLets the framework start without the Rust client in containers and CI.

MCP#

VariableDefaultDescription
TINA4_MCP(inherits TINA4_DEBUG)Enables the MCP server. Defaults to true when TINA4_DEBUG=true, false otherwise.
TINA4_MCP_PORT(main port + 2000)Port the MCP server listens on. Defaults to the framework HTTP port plus 2000.

Swagger / OpenAPI#

VariableDefaultDescription
TINA4_SWAGGER_TITLETina4 APIOpenAPI spec title.
TINA4_SWAGGER_DESCRIPTIONAuto-generated API documentationOpenAPI spec description.
TINA4_SWAGGER_VERSION0.0.1OpenAPI spec version.
TINA4_SWAGGER_CONTACT_EMAIL(empty)Contact email written into the generated OpenAPI info.contact block.
TINA4_SWAGGER_LICENSE(empty)License name written into the generated OpenAPI info.license block.
TINA4_SWAGGER_ENABLED(inherits TINA4_DEBUG)Mount the Swagger UI. Defaults to enabled when TINA4_DEBUG=true. Force true/false to override.

Configuration Recipes#

The tables above list every knob. These are the setups most apps actually reach for, ready to paste into .env. Each block sets only what the feature needs. Everything else keeps its default.

PostgreSQL in production#

One URL points the ORM, the migrations, and the query builder at Postgres. Credentials can ride in the URL or sit in their own variables, which keeps the password out of your shell history.

bash
TINA4_DATABASE_URL=postgresql://localhost:5432/myappTINA4_DATABASE_USERNAME=myappTINA4_DATABASE_PASSWORD=changemeTINA4_DB_POOL=4

TINA4_DB_POOL=4 opens four connections and rotates across them. Leave it at 0 for a single connection on a small app.

A shared cache on Redis#

The response cache and the cross-request query cache both speak to the same Redis. Point them at it and every instance shares one cache, invalidated globally on every write.

bash
TINA4_CACHE_BACKEND=redisTINA4_CACHE_URL=redis://localhost:6379TINA4_DB_CACHE=trueTINA4_DB_CACHE_BACKEND=redisTINA4_DB_CACHE_URL=redis://localhost:6379

If Redis is down or the driver is missing, the cache logs a warning and falls back to the file backend. It never silently stops caching.

Sessions that survive more than one box#

The file backend is fine for a single server. Move sessions to Redis the moment you run more than one instance, so a user stays logged in whichever instance answers the next request.

bash
TINA4_SESSION_BACKEND=redisTINA4_SESSION_REDIS_HOST=localhostTINA4_SESSION_REDIS_PORT=6379TINA4_SESSION_SECURE=trueTINA4_SESSION_SAMESITE=Strict

TINA4_SESSION_SECURE=true keeps the cookie off plain HTTP. Turn it on once you have TLS.

A queue on RabbitMQ or Kafka#

One URL is enough for RabbitMQ; the per-field variables only exist for split configs. The queue API stays identical whichever backend you pick.

bash
TINA4_QUEUE_BACKEND=rabbitmqTINA4_QUEUE_URL=amqp://guest:guest@localhost:5672/

Kafka reads a broker list instead:

bash
TINA4_QUEUE_BACKEND=kafkaTINA4_KAFKA_BROKERS=localhost:9092TINA4_KAFKA_GROUP_ID=myapp_workers

WebSocket broadcasts across instances#

A single server broadcasts in memory. Add a backplane and a message sent on one instance reaches clients connected to every other instance.

bash
TINA4_WS_BACKPLANE=redisTINA4_WS_BACKPLANE_URL=redis://localhost:6379TINA4_WS_ALLOWED_ORIGINS=https://myapp.com

Set the origin allow-list in production. Empty allows every origin, which is fine in dev and risky on the public internet.

Locked-down production headers#

The defaults are already safe. These four tighten the screws for a public site on HTTPS.

bash
TINA4_CORS_ORIGINS=https://myapp.com,https://www.myapp.comTINA4_HSTS=31536000TINA4_FRAME_OPTIONS=DENYTINA4_SESSION_SECURE=true

Never pair TINA4_CORS_CREDENTIALS=true with TINA4_CORS_ORIGINS=*. Name your real origins instead.

The dev dashboard AI, kept local#

The dashboard AI talks to a local model through Ollama by default, so nothing leaves your machine. Point the URLs elsewhere only when you run the hosted Tina4 AI services.

bash
TINA4_AI_URL=http://localhost:11437/api/chatTINA4_AI_MODEL=qwen2.5-coder:14bTINA4_RAG_URL=http://localhost:11438

Minimal .env for Development#

bash
TINA4_DEBUG=trueTINA4_LOG_LEVEL=DEBUGTINA4_NO_BROWSER=true

Debug mode lights up the Swagger UI, the dev dashboard, detailed error pages, and live reload. Keeping the browser flag on stops a new tab opening every time you save a file.


Minimal .env for Production#

bash
TINA4_SECRET=your-long-random-secret-hereTINA4_DATABASE_URL=postgresql://user:password@db-host:5432/myappTINA4_CORS_ORIGINS=https://myapp.com,https://www.myapp.comTINA4_HSTS=31536000TINA4_MAIL_HOST=smtp.example.comTINA4_MAIL_PORT=587TINA4_MAIL_USERNAME=noreply@myapp.comTINA4_MAIL_PASSWORD=your-smtp-passwordTINA4_MAIL_FROM=noreply@myapp.com

No TINA4_DEBUG. It defaults to false, which is what you want in production. Set a real secret, a real database, locked-down CORS origins, HSTS, and SMTP credentials if you send email. Everything else has a production-appropriate default.