AppConfig class

Constructors

AppConfig({required String appKey, int serverPort = 3000, String? host, int? totalIsolate, List<DoxService> services = const <DoxService>[], List<DtoSchema<Object>> dtos = const <DtoSchema<Object>>[], MessageResolver? validationMessages, List globalMiddleware = const <dynamic>[], List<Router> routers = const <Router>[], void container(IocContainer c)?, CORSConfig cors = const CORSConfig(), LoggerConfig logger = const LoggerConfig(), CacheConfig cache = const CacheConfig(defaultStore: 'file', stores: <String, Map<String, dynamic>>{'file' : <String, dynamic>{'driver' : 'file', 'path' : 'storage/cache'}, 'memory' : <String, dynamic>{'driver' : 'memory'}}), SessionConfig session = const SessionConfig(), OpenApiConfig openApi = const OpenApiConfig(), ExceptionHandler exceptionHandler = const ExceptionHandler(), ResponseHandlerInterface? responseHandler, int maxBodySize = 10 * 1024 * 1024, int maxMultipartSize = 100 * 1024 * 1024, Duration bodyTimeout = const Duration(seconds: 120), List<String> trustedProxies = const <String>[], bool compress = false, Duration shutdownTimeout = const Duration(seconds: 8)})

Properties

appKey → String
final
bodyTimeout → Duration
Idle time with no body bytes. A client that sends no request body bytes for this long gets 408 Request Timeout. A slow but steady upload is fine. It stops clients that hold a connection open. Native server only. Default 120 seconds.
final
cache → CacheConfig
cache stores for Cache(), see dox_cache
final
compress → bool
gzip responses on a Rust thread of the native server. Off by default. Streamed responses are not compressed. It costs CPU on every response. Let the proxy do it when you have one.
final
container → void Function(IocContainer c)?
Fills the container: registerContainer from lib/generated/container.g.dart. Every isolate runs it, so each one has its own instances. It also gives the routers, services and model binders that dox_builder found.
final
cors → CORSConfig
final
dtos → List<DtoSchema<Object>>
Every DTO of the app: dtos from lib/generated/dtos.g.dart. Dox finds the DTO of a controller parameter and of req.validate<T>() with it.
final
exceptionHandler → ExceptionHandler
Reports every error and turns it into a response. Extend ExceptionHandler to log to a tracker or change the answer.
final
globalMiddleware → List
final
hashCode → int
The hash code for this object.
no setterinherited
host → String?
The host (network interface) to listen on, like 127.0.0.1. Default: the env var APP_HOST, else all interfaces (IPv6 and IPv4).
final
logger → LoggerConfig
final
maxBodySize → int
Max size in bytes of a JSON or urlencoded body. Bigger bodies get 413 Payload Too Large. Default 10 MB.
final
maxMultipartSize → int
Max size in bytes of a multipart/form-data body (file uploads). Bigger bodies get 413 Payload Too Large. Default 100 MB.
final
openApi → OpenApiConfig
/docs, /openapi.json and /openapi.yaml, see dox_openapi
final
responseHandler → ResponseHandlerInterface?
final
routers → List<Router>
Routers to register. You can leave it empty: every class that extends Router is in lib/generated/container.g.dart. A router listed here comes first, in this order.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
serverPort → int
The port to listen on. Default 3000. When the env has no APP_PORT but has PORT (Cloud Run, Fly, Render, Heroku set it), Dox listens on PORT instead.
final
services → List<DoxService>
Services to run at start, in every isolate. You can leave it empty: every class that implements DoxService is in lib/generated/container.g.dart. A service listed here runs first.
final
session → SessionConfig
session settings for SessionMiddleware. Cookie driver by default.
final
shutdownTimeout → Duration
On SIGTERM or SIGINT the server stops taking new connections, and waits this long for open requests to finish. Then it closes the rest, runs DoxShutdown services and exits. Default 8 seconds. Keep it below the kill timeout of your platform (docker stop: 10 seconds).
final
totalIsolate → int
final
trustedProxies → List<String>
IPs or CIDR ranges of reverse proxies (nginx, Caddy, load balancer) that Dox trusts. Only when the direct client is in this list does Dox read X-Forwarded-For for req.ip() and X-Forwarded-Proto for req.scheme(). Use ['*'] to trust any direct client, but only the last X-Forwarded-For hop (only safe when the app port is not reachable from outside). Empty by default.
final
validationMessages → MessageResolver?
Messages for validation errors, for example in other languages. Default: the English messages.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited