Dox class

Constructors

Dox()
factory

Properties

allGlobalMiddleware → List
the middleware that packages added, then config.globalMiddleware. the same list is given until one of them changes.
no setter
cache ↔ CacheManager
cache stores from config.cache, made on first use in each isolate. Cache() uses it. replace it in tests.
getter/setter pair
config ↔ AppConfig
get app config
getter/setter pair
doxProviders ↔ List<DoxProvider>
providers that run in every isolate when it starts
getter/setter pair
dtos → DtoRegistry
the DTOs of the app, from config.dtos. Empty before initialize.
no setter
flags → CoreFlags
The CoreFlags of this isolate, from config.flags. All off before initialize.
no setter
hashCode → int
The hash code for this object.
no setterinherited
ioc ↔ IocContainer
global dox ioc containers
getter/setter pair
isolateCount ↔ int
The number of isolates that really run the app. It is the same in every isolate. Dox sets it when the server starts: from totalIsolate or config.totalIsolate, and 1 on Windows. It is 1 before that, and in DoxTestClient. Do not change it.
getter/setter pair
isolateId ↔ int
isolate Id
getter/setter pair
isPrimary ↔ bool
True in the first isolate, the one that runs main() and starts the server. False in the isolates it starts. It is the same as isolateId == 1.
getter/setter pair
isWebServer ↔ bool
True only in the web server process (startServer() and its isolates). It is false in bin/queue.dart, the scheduler and tests that only start providers. A provider can use it to do work only when the app really serves requests.
getter/setter pair
messages → MessageResolver
validation messages, from config.validationMessages.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
server → DoxServer
get dox http server
no setter
validator ↔ RequestValidator
checks DTOs and schemas for req.validate<T>() and controller parameters.
getter/setter pair

Methods

addGlobalMiddleware(Object middleware) → void
Add a global middleware from a package. Call it in the setup() of a DoxProvider. It runs on every route, before the app's own globalMiddleware. A second add of the same one is skipped. It takes the same kinds as globalMiddleware. Use a top-level function or a const instance, so a restart does not add it twice. The list is cleared at each start, before the providers run. Add it from a provider's setup(), which runs on every start. Anything added before the app starts is cleared.
addProvider(DoxProvider provider) → void
add a provider that runs in every isolate when it starts
addProviders(List<DoxProvider> providers) → void
####### functions need to run on isolate ####### add providers that run in every isolate when it starts
checkAppKey() → void
stop at startup when APP_KEY is missing, not exactly 32 characters, or a public sample key. a short or public key is easy to guess, so anyone can sign tokens and cookies. in development, local, test and testing it only logs a warning.
compute<R>(FutureOr<R> task()) → Future<R>
Run task on a worker isolate and give its result, so the server can answer other requests while it runs. Use it for heavy CPU work: a PDF, an image, a big JSON file. Tasks run on a small pool of workers (AppConfig.computeWorkers). More tasks wait in line, first come first served. An error of the task is thrown here, with its stack trace.
initialize(AppConfig appConfig) → void
initialize dox application it load env and set config
loadRoutes() → AppRoutes
register the routes of the app routers and give them, without a server and without providers. dox route:list uses this. When config.openApi is on, the docs routes are in it too. Providers do not run, because their setup() may connect to a database or start a worker. So a route that a provider adds in setup() is not in the list.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
startProviders() → Future<void>
run setup() of every provider, register the routes, then run boot() of every provider this is internal core use only your app do not need to call this function
startServer() → Future<void>
start dox server
stop() → Future<void>
Stop the server gracefully, in every isolate:
stopIsolate() → Future<void>
stop for this isolate only. Internal: each isolate runs it.
toString() → String
A string representation of this object.
inherited
totalIsolate(int value) → void
override total isolate from config default is one per CPU the process may use
warnCorsCredentials() → void
print one warning when the CORS config allows every origin with credentials. Browsers do not accept this. It does not change the headers Dox sends.
warnIsolateSlots(int isolates, int slots) → void
print one warning when the app has more isolates than the Dart VM runs at the same time (slots).
warnWebSocketOrigin() → void
print one warning to stderr when a Route.websocket route checks no Origin. Any site can then open a socket with the cookies of the user.
writeOpenApi(String dir) → Future<List<File>>
write openapi.json and openapi.yaml of the app routes into dir. bin/openapi.dart calls this for dox openapi:generate.

Operators

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

Static Methods

isolateGroupsWarning(String why) → String
the text of the warning when CoreFlags.isolateGroups can not run
isolateSlotsWarning(int isolates, int slots) → String
the text of the warning of warnIsolateSlots
serverUrl(HttpServer server) → String
the real address of server, like http://127.0.0.1:3000 or http://[::]:3000 (all interfaces). https:// for a TLS server.

Constants

corsCredentialsWarning → const String
the text of the warning of warnCorsCredentials
webSocketOriginWarning → const String
the text of the warning of warnWebSocketOrigin