dox_core 3.2.11
dox_core: ^3.2.11 copied to clipboard
A perfect solution for your web backend development with dart that offers a wide range of features to help you build powerful and scalable web applications.
3.2.11 #
- Security: Dox now starts the native server with
streamBodies: true. Thus a request body of more than 1 MiB streams, and the route runs before the server reads the body. Before, the server kept the full body in memory before routing (up tomaxMultipartSizefor a multipart body to any path). Dox reads a streamed JSON or urlencoded body withNativeRequest.readBody, which puts the parts into one buffer of native memory. Thus a big body makes no big list on the Dart heap. Dox reads a streamed multipart body from the stream.NativeRequest.bodyis empty for such a body. Now a JSON, urlencoded or multipart body of any size gives the same input as before.maxBodySizeandmaxMultipartSizegive 413 as before. This needs dox_http_native 3.2.10 (the new floor). - Security: a multipart body now keeps a maximum of
maxBodySizein memory. This limit applies to all the text fields and small files of the body together. Before, a multipart body to any route could keep up tomaxMultipartSizein memory before the middleware ran. Now a file that goes over the limit goes to a temp file, and text fields that go over the limit get 413. - Fixed: a request body that stops part way (the client went away, or the native server already answered 413 or 408) now gives a 400
BadRequestException. Before, it was anHttpException, which the exception handler reported as an app error. - Docs: the nginx example in Deployment no longer sets
proxy_request_buffering offandclient_max_body_size 100monlocation /. It keeps a small limit on/and a big limit only on an upload location.
3.2.10 #
- Faster: a route with a
.in a text part (for example the gRPC route/pkg.Service/{method}) now finds its params with no regex. A.in a route is a regex mark: it matches one character, but not a line end. The new match obeys the same rule, and a URL that it does not match goes to the regex. Thus the routes match the same URLs as before.
3.2.9 #
- Security: on Windows,
Route.staticFilesrefuses a path segment with~or:. Before,/ENV~1(the 8.3 short name of.env) could send a dot file of the folder, anda:bcould read an alternate data stream. Other systems do not change. - Faster, less memory: a file response (
Route.staticFiles, and aFilethat a controller returns) is read and sent by the native server. No file byte goes through Dart. The server reads a part of the file only when the connection can take it. On the HttpArena static test (20 files, 256 HTTP/2 connections with 32 requests each, 2 server cores), the peak memory goes from approximately 1.5 GiB to 128 MiB.Range,ETag,304and the bytes of a response with a file do not change. A file of a controller that is there but can not be read still gives a 500 and a report. A file of a controller in a folder that the app can not open now also gives a 500 (before: 404). The native server opens each file one time, withNativeFile.open, and sends that open file withNativeResponse.addOpened. The open gives the size and the change time, so Dart does no stat call. A file of a maximum of 64 KiB is read with the open, also for HEAD and conditional requests. A file that the OS does not have in memory is opened and read by the file pool of the native server. Thus a slow disk does not stop the other requests. This needsNativeFileandaddOpened, which come in the next dox_http_native release. - Faster: on the dart:io server,
Route.staticFilesasks the disk with direct calls (statSync), not with the async calls of dart:io. An async call goes to another thread and back, and three of them were most of the time of a small file. - New:
AppConfig.fileThreads(1 to 64, default 4) is the maximum number of threads that read the files of one static folder from the disk. All files of controllers are one more folder. All isolates share these threads. The server does not start with a value out of this range. Native server only. - New:
Route.staticFiles(prefix, folder, precompressed: true)sends a file that your build already compressed. For a request forapp.js, Dox looks forapp.js.br(brotli) andapp.js.gz(gzip) in the same folder. If the client accepts one of these codings inAccept-Encoding, Dox sends that file withContent-Encoding. The coding with the higherqwins, and brotli wins when the two are equal. Each file of the folder getsVary: Accept-Encoding. TheETagandLast-Modifiedcome from the file that is sent.304andRangework on that file. The default is false, so a folder that does not set it works as before.
3.2.8 #
- New:
AppConfig(ports: [PortConfig(8443, http2: true, tls: TlsOptions(...))])adds ports that have their ownhttp2andtls. One process can now serve plain HTTP and HTTPS at the same time, for example HTTPS for the public and a plain port for a health check. Each isolate listens on these ports, with the same routes.AppConfig.http2andAppConfig.tlsare not used for these ports. The limits (maxConnections,idleTimeoutand the others) are those of the app. The default is no such ports, so an app that does not set it works as before. A port that is in the list two times, or that is alsoserverPortor one ofadditionalPorts, stops the start with anArgumentError, before an isolate starts. The test client does not listen on these ports. - Changed:
req.scheme()andreq.isSecure()now come from the port of the request. A request on a port withtlsishttps, and a request on a plain port ishttp. A trusted proxy withX-Forwarded-Protowins, as before. For an app with noports, the result is the same as before. - Changed:
Dox().server.reloadCertificate()also reads the certificate files of each port ofAppConfig.portsthat hastls. It checks all the files first, so a bad file changes no port. If a file changes between the check and the reload, the reload can stop before the last port. Then call it again. It throws aStateErroronly if no port hastls. The start also checks these files before the isolates start, and a bad file throws aTlsException.
3.2.7 #
- New:
AppConfig(additionalPorts: [8082])makes each isolate also listen on these ports, with the same routes and the same settings. One process serves all of the ports, so an app that needs two ports does not need a second process. Withhttp2: true, each port takes HTTP/1.1 and HTTP/2.PORTin the env changesserverPortonly. The test client does not listen on these ports. The default is no additional ports, so an app that does not set it works as before. If an additional port is in use, the start fails and the ports that were opened close again.maxConnectionsis a limit for each port: an isolate holds up tomaxConnectionsconnections on each of its ports. - Less memory, faster: a request makes fewer objects. The common path of the router and the handler makes no closure context. A route with no params gives the same match record each time.
req.input(),req.integer()and the other input reads make no record for a key that is in the input as it is, and make no empty body map for a request with no body. On the native server, the query of a plain target is read with noUri. The input values, the query and the answers do not change. On the HttpArena tests (2 server cores), Dart allocates 1,024 bytes for each pipelined request (before: 1,297) and 3,916 bytes for each baseline request (before: 4,404). The pipelined test also needs the new dox_http_native release. - Changed:
DoxRequest.uriis now a getter and a setter, not alatefield. A read or a write works as before. - Faster: the router reads the path of a request with no
Uri. Before, each request made aUrifor its path, and the router read the path up to three times. On the HttpArena pipelined test (2 server cores), Dox does approximately 4% to 5% more requests a second. The path, the route and the 404 message do not change. This needsNativeRequest.path, which comes in the next dox_http_native release. - Faster:
DoxRequest.uriis made on first use, not for each request. Theuriparameter of theDoxRequestconstructor is now optional. If you give it, the request uses it, as before. - Faster: a
Stringbody is sent before the checks for the other body types. The route path check reads the code units directly and does not useString.contains. - New: fast JSON for
@Serialize()classes. Rundart run build_runner buildwith the new dox_builder and setAppConfig(container: registerContainer). A@Serialize()serializer writes its JSON with no map. A plain@Serialize()class can be returned from a controller. The JSON is the same with and withoutCoreFlags.sdkJsonEncoder. On the HttpArena item data (1 and 50 items), a@Serialize()serializer takes 0.22 µs and 5.9 µs, a plain@Serialize()class takes 0.19 µs and 6.3 µs, and a@Dtotakes 0.19 µs and 6.2 µs. On the same data and machine,JSON.stringifyof Bun takes 0.17 µs and 11.4 µs (with the UTF-8 bytes). - New:
IocContainer.jsonWriter()andIocContainer.jsonWriterOf()keep the JSON writers of@Serialize()classes.Serializer.listOf(),Serializer.hasItem()andSerializer.itemOf()give the data of a serializer to the generated code. - Faster: a
Serializermakes no list for one item. The JSON oftoJson()does not change. - Faster: the JSON encoder keeps the writer that it found for each class (a DTO, a
@Serialize()class, or none, like forDateTime), so each class costs one look-up. - New:
DoxResponse.contentBytes(bytes)sets a body of UTF-8 text that is already encoded. Dox sends the bytes as they are, with no second encode. It gets the same content type as aStringbody.getContent()gives the text. It decodes the bytes the first time that you call it.content()replaces the bytes. dox_view uses this forview(). - New:
DoxResponse.getContentBytes()gives the body as UTF-8 bytes. For acontentBytes()body, it gives those bytes. For aStringbody, it encodes the text. For all other bodies, it gives null. - New:
ETag.ofUtf8(bytes)gives the same tag asETag.ofof the text in the bytes, with no decode. TheETagmiddleware uses it for acontentBytes()body, so a page has the same tag as before. Exception: a page with a lone surrogate (half of a UTF-16 pair) gets a new tag one time, because its bytes have U+FFFD at that position. The bytes of the page do not change. - Fix: a query with an escape that is not UTF-8 (for example
?a=%ff) gave a 500. Nowreq.queryand a@Dtothat reads the query give a 400.ValidateSignaturegives a 403, because Dox never signs a URL like this. - Faster: the JSON encoder inlines
string(),integer()andrun()into the generated code, and three writers do not check bounds. Each of these three makes room for all its bytes first, in the same method. On the HttpArena data, a@Dtolist encodes in 2.8 µs, not 3.4 µs. On the same data and machine,JSON.stringifyof Bun takes 3.3 µs. - Faster: the JSON encoder writes a whole number two digits at a time, and it writes a
JsonRun8 bytes at a time. With the new dox_builder, the code of a@Dtoand of a@Serialize()class uses it, and a@Dtoin a response is 2.2 times faster to encode. Rundart run build_runner buildto get the new code. - Faster: a query with no
%,+or[(for example?page=2&sort=name) is split with no decoding. The map is the same asUri.queryParameters.input(),integer()and the other readers of one key look in the body, then in the query, and make no merged map. The body still wins over the query. On the HttpArena json-h2c test (2 cores), this gives 3% more requests a second. - Fix: a cookie that the native server refuses (for example a line break in its domain) made the request get no answer. The first answer failed because of the cookie, and the plain 500 that Dox then sends kept the cookie and failed the same way. The plain 500 now also removes the cookies, so the client gets the 500.
- New:
CoreFlags.sdkJsonEncoder(off by default). Dox then encodes JSON withJsonUtf8Encoderof the Dart SDK, as it did before it had its own encoder. The JSON is the same, but it is slower. Turn it on only if you think that the Dox encoder gives a wrong response. A class that only haswriteJson()then also needs atoJson().CoreFlags.all()does not turn it on. - New:
AppConfig(compressLevel:), the gzip level ofcompress, from 1 (fast) to 12 (small). The default is 1. With dox_http_native, gzip now uses libdeflate: for a 6.7 kB JSON body, it goes from 35.7 µs to 13.5 µs, and the body is 1,421 bytes, not 1,271 bytes. SetcompressLevel: 6to get about the same size as before. The server does not start with a level that is not 1 to 12. - New: a controller can return a
@Dtoobject or a list of them. Dox writes the fields as JSON, with the keys that the DTO reads (product_nameforproductName). ADateTimebecomes ISO 8601 text, an enum becomes its name, and aMaybefield with no value is left out. The DTO must be inAppConfig(dtos: dtos).JSON.bytes()andJSON.stringify()take a DTO too. Before, a DTO in a response was an error unless the class had atoJson(). A DTO class with its owntoJson()keeps it. Rundart run build_runner buildwith the new dox_builder: the schema of each DTO gets awriteObject()that writes the fields directly into the bytes of the response, with noMapin between. - New:
JsonWritableandJsonWriter(from dox_annotation). A class that implementsJsonWritablewrites its own JSON inwriteJson(JsonWriter writer), directly into the bytes of the response. Dox callswriteJson(), and nottoJson(), for a response and forJSON.bytes().JSON.stringify()still callstoJson(). - Faster: a model in a JSON response makes no
Map. With the new dox_builder and dox_orm, a model gets awriteJson()that writes its columns, relations and computed values directly into the bytes of the response. A date is written with noStringin between. For a list of 40 rows with two dates each (6.3 kB), the encode time goes from 44 µs to 8 µs. With no dates, it goes from 14 µs to 7 µs. The JSON does not change. Rundart run build_runner buildto get the new code. - Faster: Dox encodes a JSON response with its own encoder, not with
JsonUtf8Encoderof the Dart SDK. For a list of 40 rows (6.7 kB), the encode time goes from 41 µs to 16.5 µs. For a list of 10 long texts (6.9 kB), it goes from 31 µs to 6 µs. For a small body, it is 2.5 to 3 times faster. Measured on 2 server cores, a route that returns 40 items does 42% more requests a second, and 37% more with gzip. The bytes of the response do not change.JSON.bytesuses the same encoder. A JSON response of the native server also does not copy the encoded bytes before the server takes them. Until the server copied them, every other JSON encode (for example in thetoString()of a cookie) writes into a new buffer, so it can not change them. With this change, the same route does 4% to 6% more requests a second (3% with gzip), and each response makes less garbage. One error detail changes: if a map has a key that is not aStringand also a value that is not JSON, the error can name the value and not the map.
3.2.6 #
- New:
CoreFlags.isolateGroups(off by default) starts each server isolate in its own isolate group, so each one has its own heap and its own garbage collector. A GC pause in one isolate no longer stops the others. Each isolate runsmain()again, somain()must be safe to run more than once (the migrations ofMigratorare), the app key must be the same in each run (set it in.env), and the app reads its settings from the environment, not from the command line. It needs adart build clibundle (Linux), a<executable>.aotfile fromdart compile aot-snapshot, ordart run. When none is found, Dox logs one warning and runs as before.Dox().computehas one pool in each isolate. The warning about the 8 isolate limit of the VM is not shown in this mode.CoreFlags.all()does not turn it on. - New:
Dox().isPrimaryis true in the first isolate and false in the isolates it starts.Dox().isolateIdis right from the first line ofmain()in an isolate group. - Fix: a multipart body (
multipart/form-data) that is not valid made the request wait with no answer. The server then also did not stop on shutdown. Three kinds of body did this: a part header that is not valid (a space in the header name, a line with no:, bytes that are not UTF-8), text on the line of the first boundary, and a body with no parts and bytes after the end mark (--boundary--). Now the first two get a 400, and the third is an empty body. The fuzz tests found this. - Fix: a multipart part with a
Content-Dispositionthat is not valid (a param with no name or no value, a quote that does not end, text after the params) gave a 500. A multipart body that stops in the part headers gave a 500 too. Now they get a 400, and theExceptionHandlerdoes not report them. - New:
AppConfig.tls(off by default) serves HTTPS with no proxy. Give it aTlsOptionswith the certificate file and the key file (PEM). The port then accepts only TLS 1.2 and TLS 1.3. Withhttp2: true, the client selects HTTP/2 or HTTP/1.1 in the handshake (ALPN), so browsers and gRPC clients use HTTP/2 with no proxy.dox_coreexportsTlsOptions. This needsdox_http_native3.2.6 or later. - New:
Dox().server.reloadCertificate()reads the certificate and key files again, without a restart. One call is sufficient for all isolates. If a file is bad, it throws aTlsExceptionand the server keeps the old certificate. - New:
DoxTestClient.startspeaks HTTPS when the config hastls. The client accepts only the certificate of the config, so a self-signed test certificate works. - New: with
AppConfig.tls,req.scheme()ishttpsandreq.isSecure()is true. Thus cookies with nosecurevalue (also the session cookie) getSecure,SecurityHeaderssends HSTS, andreq.fullUrl()starts withhttps://. The start log showshttps://. Withouttls, nothing changes. - Fix: a bracket key with an index that is not plain digits lost its value.
k[01]=z,k[+1]=z,k[0x10]=zandk[%201]=zgave{k: [null]}inreq.body,req.queryand a DTO, andk[01]=a&k[1]=bgave{k: [b, b]}. Now only plain digits like3are a list index. Any other key is a map key and keeps its value:k[01]=zgives{k: {01: z}}. A key likek[+5000]was refused with 422 as an index past the limit. Now it is a map key too. The fuzz tests found this. - New: a warning at the start when the app has more isolates than the Dart VM runs at the same time. The VM runs 8 by default, so a server with more than 8 CPU cores used only about 8 of them. The warning gives the
DART_VM_OPTIONSvalue that lets every isolate run. It also namesCoreFlags.isolateGroups, which has no such limit. See the Deployment page.
3.2.5 #
- Fix: a route part can have text and params together, like
/v{id}/{name},/v{id}and/{a}-{b}. Before,/v{id}/{name}gave the value ofidforreq.param['name'],/v{id}matched only the text/v{id}, and/{a}-{b}was one param with the namea}-{b. Now each param has its own name and value. This changes the match of two rare routes:/v{id}now matches/v5, and/{a}-{b}matches/x-ybut not/x.Route.urlalso fills the params of such a route. - Needs
dox_http_native3.2.3 or later. It has lower tail latency when the server has idle CPU cores. - Faster: a route with params like
/users/{id}is matched without a regex, when each part of its path is plain text or one whole param. The match goes from 142 ns to 16 ns. Measured on 2 server cores,GET /user/{id}does 2% to 4% more requests a second. Routes with{id?},{path*}orRoute.whereuse the regex, as before. The matched routes and the param values do not change.
3.2.4 #
- New:
IAuthMiddlewareis an interface for a middleware that logs a user in.asOptional()gives a copy that lets guests through withreq.authnull. A package like GraphQL can use it to read the user without needing the auth package. - New:
AppConfig.http2(off by default) lets the same port also speak HTTP/2 over plain TCP (h2c), andAppConfig.maxConcurrentStreams(default 250) sets the open requests of one connection. HTTP/1.1 keeps working on the port. Addreq.protocolVersion(1.0,1.1or2.0). This needs a dox_http_native with HTTP/2. - Fix: a
:in a route path, like/books:search, is a literal char in Dox. The OpenAPI docs read it as a param and showed/books{search}. Now the path is shown as it is:/books:search. - New:
req.takeOverResponse()says that the handler sends the response itself. Then Dox sends nothing more for the request: not the returned value, not a change of anextmiddleware (likeETag), not theresponseHandler, and not an error answer. Errors are still reported. If the handler starts its response and then throws, Dox ends the response, so the client does not wait for ever. - New:
Route.fallback(controller, when: check). Withwhen, the fallback is tried for any method and answers only when the check gives true. Without it, a fallback is GET and HEAD only, as before. - New:
.withoutMiddleware<T>()on a route takes out every middleware of typeT(or a subtype), also global, router and group middleware, and in the OpenAPI docs too. For example, a long stream can skip a globalRequestTimeout. - New:
.renderErrorsWith(renderer)on a route sends its errors (also the errors of its middleware and a body that fails to read) to the renderer, not toExceptionHandler.render. The error is still reported. A null result gives the normal answer. - New:
showErrors()is public. It is true whenAPP_ENVisdevelopmentorlocal, the rule Dox uses to send error text. - Change: the OpenAPI spec no longer lists the middleware class names of a route (
x-dox-middleware). The names were internal details. Security and error answers still come from the middleware, as before.
3.2.3 #
- Fix: the default
totalIsolatewasPlatform.numberOfProcessors. In a Linux container with--cpuset-cpusor a CPU quota (--cpus, Kubernetes limits), Dart still reports all CPUs of the host. Dox then started too many isolates, and the OS paused them, so some requests waited longer. Now the default isProcessors.available. It uses the CPUs the container allows (cpuset and CPU quota, cgroup v1 and v2). Outside Linux it is stillPlatform.numberOfProcessors. - Fix: with
OpenApiConfig.includeorexclude, the docs still listed every schema of the registry, also the ones used only by hidden routes. Now they list only the schemas that the shown routes use, and the schemas used inside those. With noincludeand noexclude, all schemas are listed as before.
3.2.2 #
-
Fix: the temp files of big uploads were deleted when
response.donecompleted. A newer native server completesdonealso when the client leaves, so a slow handler (an S3 upload, image work) could lose its file while it read it. Now the files are deleted when the request is handled (after the middleware and the controller, also on an error) and the response is done. A request with no big upload pays nothing. -
Fix: when a handler had already sent the head (a flush or a stream, eg. server-sent events) and then threw, Dox cleared the headers, set status 500 and wrote
Internal Server Errorinto the middle of the stream. Now the error is reported and the response just ends. This needs a dox-http-native withNativeResponse.headSent(dox-http-native#25). -
Fix: a multipart body that ended with no closing boundary (a cut upload) kept the request open for ever, with its temp file. Now it gives 400 and the temp file is deleted.
-
Fix: a sync throw in a handler, or a raw
Route.mounthandler (nomiddleware: true), never marked the handler as ended.AfterResponsework then never ran and the upload temp files stayed on disk. Now every path ends the handler. -
Fix: a multipart body with an epilogue after the closing boundary was rejected when the epilogue was longer than about 256 bytes. Any epilogue is fine now.
-
Fix: after a
RequestTimeoutthe late handler lost its upload temp files. They now stay until it ends (a handler that never ends keeps them for ever).AfterResponsework that never ends does the same. -
Fix:
AfterResponsework could start while the handler still ran, when the client left early. Now it starts after the handler ended and the response is done. -
Perf: every request with no body (most GETs) made a new empty body map. Now the map is made on the first use of
req.body(orreq.requestBody.map,req.all(),req.input(),req.add()). A request that never reads its body makes no map. Each request still has its own map, so writes never leak between requests.DoxRequest(body:)is now optional. -
Fix: sessions with the
cachedriver on amemorystore were kept in each isolate on its own. The server runs one isolate per CPU core, so a session saved by one isolate was missing when the next request came to another one. Users were logged out at random. Now these sessions live in the memory store of the main isolate, and the other isolates read and write them there (one message per session read, one per changed session). Expired sessions are removed by the memory store as before. A server with one isolate, thecookiedriver and the other stores work as before. -
Security: the
RateLimitcounts in the main isolate (no Redis) had no limit on the number of clients. A client with many ips (an IPv6 /64 has 2^64) could grow the memory with no end. Now the counter keeps at most 100,000 clients (RateLimitCounter.defaultMaxKeys, about 15 MB). This cap is on by default. When it is full, the counter first drops the expired counts, then the oldest ones. A dropped client starts again at 0. New clients are never turned away, so a flood of fake clients can not lock out real users. -
Security: new opt-in flag
CoreFlags.rateLimitIpv6Prefix(off by default). With it, the defaultRateLimitkey counts an IPv6 client by its /64 prefix, so a client can not get a new count by changing its address inside its /64. Clients in one /64 then share a count.RateLimit.ipBucket(ip)gives this key for your ownkeyfunction. -
Perf:
RateLimiton a Redis store sent its commands one after the other: 2 round trips per request (3 withsliding). Now they go out in one write, so it is one round trip. The commands, the counts and the errors are the same. If the count is made before its time limit is set (or setting the limit fails), Dox sets the limit after (it tries twice), so a client is not blocked for ever. Other stores work as before. -
Perf:
AfterResponsemade a list and waited for each response, also when no work was added. Now this happens on the firstAfterResponse.runof a request. A request that adds no work pays only for its zone. Apps with the queue package haveAfterResponseon. -
Perf: the
cookiesession driver decrypted the session cookie on every request. Now it decrypts on the first use ofreq.session. Thecachedriver still reads the store before the controller, because the session API is not async. -
Perf: a
Stringbody was encoded withutf8.encode, which first makes a list 3 times the text length, then copies the used part. Now an ASCII text is written straight into a list of the right size (newutf8Bytes). A text with other characters still usesutf8.encode. The bytes are the same. -
Perf: the
Content-Typeof a request with a body was parsed on every request. Now the parsed type is kept per header text (at most 64 texts, a multipart boundary is not kept), so a repeated type is parsed once. NewHttpBody.contentTypeOf(headers). -
Perf: a route with params ran its regex for every url with the same first segment. Now the router first checks the plain text before the first param (new
RouteData.matchPrefix, eg./api/usersfor/api/users/{id}), and skips the regex when the url does not start with it. A route with regex marks (like.) in that text runs the regex as before. The matched routes are the same. -
Perf:
SecurityHeadersandRequestIduse lower case header names, so the server makes no lower case copy per header.RequestId.make()builds the id with one list, not 9 strings. The id is still 32 hex characters. -
Perf: a worker isolate made one timer per rate limited request for the 5 second timeout to the main isolate. Now one timer checks all waiting requests, and it only runs while a request waits.
-
The AI agent skill (dox-core-guide) has a Performance section and
references/performance.md: the common mistakes that block the isolate, the right code for each, and strict mode. -
New:
Dox().compute(task)runs heavy CPU work (a PDF, an image, a big JSON file) on a worker isolate and gives the result. The server can answer other requests in the meantime. There is one small pool of workers for the whole process, shared by every server isolate. The workers start on the first task. More tasks than workers wait in line, first come first served. An error of the task is thrown to the caller, with its stack trace. A worker that dies is replaced, and its task fails with a clear error. The pool stops with the server and never keeps a command or a test running. The task runs in another isolate, so it can only use values that can be sent between isolates, not the IoC container or a database pool. -
New:
AppConfig.computeWorkerssets the number of workers. DefaultAppConfig.defaultComputeWorkers(4). -
Change:
Hash.makeAsyncandHash.verifyAsyncrun on the worker pool ofDox().compute. Before, each call started a new isolate, so 500 logins at once started 500 isolates. The results are the same. They still work without a server. -
New: strict mode for development:
AppConfig(strict: StrictConfig(enabled: true)). Off by default, and then it costs one bool check per request. When on, it writes a[strict]warning to stderr when a route blocks the isolate longer thanStrictConfig.blockLimit(default 50 ms, once per route), when the event loop was blocked that long after anawait(at most once in 10 seconds), and whenHash.make,Hash.verifyorHash.checkruns in the web server (once per place in the code). Each warning says what to use instead. -
Memory: each response called
close()and did not use its Future. On the native server that Future and its microtask kept the request and its batch of bytes alive a bit longer, so under load the heap grew. Now Dox callsNativeResponse.end(), which makes no Future. Adart:ioresponse still callsclose(). Needs the next dox_http_native. -
Perf: CORS read the
Originheader on every request, even with the default config that sets no CORS value. With the content type read, that was a second header lookup, and the native server then parsed all headers. NowOriginis read only whenoriginis a list, and a config with no values returns at once. The headers sent stay the same. -
Memory:
DoxResponsemade a map, a set and a list for every response, also when nothing was set. Now they are made on first use.headersstill gives a map you can change. -
New: every pretty log line starts with a dim tag that says where it comes from, like
[request] GET /users => {...}. Request lines get[request]. Server start, stop and startup warnings get[server]. Error reports get[error]. Your own lines get[app]. Pass your own tag as the third argument:Logger.info('done', null, 'billing').Logger.log,info,warn,successanddangerall take it. In JSON mode the tag is thesourcefield, added at the end of the line. When the data map has its ownsourcekey, that value is kept and the tag is not added. An empty tag counts as no tag. -
Change: the plain warnings on stderr use the same tags.
dox: warning:and[dox]are now[server](isolate, server, WebSocket and CORS warnings) or[request](a middleware returned null). -
Perf: a JSON response made a new 8 KB buffer, even for a small body. This made small JSON bodies about 2x slower to encode. The buffer is 1 KB now. Big bodies are about the same speed.
3.2.1 #
- Fix:
Env.getread as the first env read of the app saw only the shell, because nothing had loaded.envyet. Now every env read (Env.get,Env.appEnv,Env().env) loads.envonce when it is not loaded. After that it is a plain map read, also when there is no.envfile. SettingEnv().envin a test counts as loaded, so the file is not put on top. When the.envfile can not be read (like bad UTF-8), every read throws again; it never looks like an empty file. - New:
AppConfig.isDevelopment. It is true when the envAPP_ENVisdevelopment(notlocal). Not set means production, so false. It reads the env on each call, so it works before the server starts and in every isolate. Use it for config like a databasedebugflag, in place of a computed getter in the env class: every env getter is an env key. - New:
Env.appEnvgivesAPP_ENVin lower case. It loads.envfirst when nothing did yet, so it gives the same answer when it is the first env read.Dox().checkAppKey(),HealthCheck,OpenApiConfig.isEnabledand the null middleware warning use it now.showErrors()keeps its own read, so its per-request cache stays the same. - Security: an env error printed the bad value, like
DB_PORT must be an int, not "...". A value may be a secret, and the error goes to the startup log and to CI output. NowEnvExceptionand theEnv.getcast error name only the key and the expected type. - Security: more public sample keys are refused by the
APP_KEYcheck at startup: the keys from the docs, the dox_core test fixture and the sample app. They get the same rule as the old sample keys: an error outside development, local, test and testing, and a warning in those. If yourAPP_KEYis one of them, rundox key:generate. - Fix: in
.env, an unquoted value that starts with#was read as empty. SoDB_PASSWORD=#Secret1used the default. NowKEY=#fffkeeps#fff, as the docs say.KEY= #xandKEY=a #xare still comments. - Fix:
Env.getread a value with only spaces as text, soEnv.get<int>('MAIL_PORT', 587)threw forMAIL_PORT=" ". Now only spaces counts as empty and gives the default, the same asEnvReader. - Fix:
EnvReader.listof only commas (,) gave an empty list. Now it counts as missing, so the default is used. - Fix: a
Durationtoo big for an int (99999999999999999999s) threw aFormatExceptionright away, and a big one (9223372036854775807d) gave a wrong value. Now both are bad values, listed bycheck()with the others.
3.2.0 #
- New:
Dox().isWebServer. It is true only in the web server process (startServer()and its isolates). It is false inbin/queue.dart, the scheduler and tests. A provider can use it to skip work that only a web server needs, like a startup warning. - New: after
setup()of every provider (and the routes), the app runsboot()of every provider (seeDoxProvider.boot()of dox_annotation). - Changed:
Command,MigrationFileandDoxProvidernow live in dox_annotation.package:dox_core/command.dartandpackage:dox_core/dox_core.dartstill export them. dox_core needs the dox_builder release that finds providers from dox_annotation, so upgrade dox_builder together with dox_core. - New:
RateLimit(sliding: true)uses a sliding window. A client can no longer send 2 xmaxrequests around the edge of a window. The count is the count of this window plus a part of the count of the window before. That part gets smaller as the window goes on.Retry-Afteris the time until one more request fits. Off by default: the fixed window works as before. - New:
CoreFlags.envExpand..envvalues can use${OTHER}, unquoted or in"..."(not in'...'). It reads a real environment variable first, then a key above it (.env.testingalso sees the keys of.env). An unknown name stays as it is. In a"..."value,\n,\t,\",\\and\$become a new line, a tab,",\and$. Off by default: values are read as before. The.envfile is read beforeAppConfigexists, so also setEnv.flags = flagsat the top ofmain(). The server isolates read.envthe same way as the main isolate.Dox().initializewarns when the flag is on inAppConfigbut.envwas read without it. - New:
export KEY=valuelines in.envare read likeKEY=value. - New:
AppConfig(htmlErrors: true)sends a small HTML error page to a request that does not want JSON (seeDoxRequest.expectsJson). Off by default, so errors stay JSON. Indevelopmentorlocalthe page also shows the error text and the stack trace. JSON clients, validation errors and answers fromExceptionHandler.renderdo not change.AppConfig(errorPage: ...)replaces the page;defaultErrorPageis the default. - New:
DoxRequest.expectsJsonFor(headers)isexpectsJson()for the headers of a rawHttpRequest. - New:
Route.resource(..., parameter: 'photo')names the param of one item{photo}instead of{id}, soRoute.bindand model binding work on resource routes. The default is still{id}. - New:
route()andRoute.url()put a param that is not in the path into the query string. Before, it threw anArgumentError. Whenparamsandqueryhave the same key,querywins. - New:
route(..., absolute: true)andRoute.url(..., absolute: true)give the full url, withAPP_URL(orbaseUrl:) in front, likeRoute.signedUrl. - New: a cache store with
'encrypt': trueencrypts its values with theAPP_KEY(Crypt). Old keys inpreviousKeyscan still read old entries. No setup is needed:CryptCacheEncrypteris the default. SetCacheConfig(encrypter: ...)to use your own.CacheEncrypteris exported from dox_core.CryptCacheEncrypter.encryptthrows aStateErrorwhenAPP_KEYis empty. - New:
Dox().addGlobalMiddleware(middleware). A provider calls it insetup()to add global middleware. They run on every route (and on mounts), before the app'sglobalMiddleware. The same middleware added twice runs once.Dox().allGlobalMiddlewaregives the full list. - Ships an AI agent skill (dox-core-guide). Install it in your app with
dart run skills@ get. - New:
Dox().loadRoutes()registers the routes of the app routers and gives them asAppRoutes(routes, fallbacks and mounts), without a server and without providers. When OpenAPI is on, the docs routes (/docs,/openapi.json,/openapi.yaml) are in it too. It is safe to call more than once: the route list is empty before and after the call, so a laterstartServer()starts clean.dox route:listuses it. - New:
RouteData.isWebSocketis true for a route added withRoute.websocket. - Fix:
Route.group,Route.domain,Route.middleware,Route.enabledCorsandRoute.disabledCorsrestore the prefix, name prefix, domain, middleware and CORS setting also when the callback throws. Before, the next routes got the wrong path, name or middleware. - New:
CoreFlags, opt-in behaviors that work like Laravel, asAppConfig(flags: ...). All are off by default, so nothing changes until you turn one on.CoreFlags.all()turns on every flag.Dox().flagsgives the flags of the current isolate. - New:
CoreFlags.laravelErrorssends a422as{"message": "...", "errors": {"field": ["..."]}}. The OpenAPIValidationErrorschema follows it. - New:
CoreFlags.onlyPresentmakesreq.only([...])leave out keys that are not in the input. - New:
CoreFlags.cookieDefaultssendsPath=/andSameSite=Laxfor aDoxCookiewith nopathorsameSite. - New:
CoreFlags.hasKeyOnlymakesreq.has('x')only check that the key is there, likereq.exists('x'). - New:
CoreFlags.htmlStringssends a string from a controller astext/html. A content type set by the app wins. - New:
res.header(k, v, replace: true)replaces a value that a middleware put on the response.CoreFlags.replaceHeadersmakes it the default.VaryandSet-Cookiestill get one more value with the flag. - New:
session.regenerate(keepToken: true)keeps the CSRF token, so forms open in other tabs keep working. The default is still a new token. Do not use it at login: a token from before the login would stay valid. - New:
CoreFlags.decryptServerErrormakes aDecryptExceptiona reported500. - New:
CoreFlags.cacheCopiesmakesCache().store('x'),.tag()and.tags()give a newCache. - New:
dox_coreexportsCacheFlagsandLockTimeoutExceptionofdox_cache.Cache.withAppPrefixkeeps theflagsof theCacheConfig. - Fix:
HealthCheck.cache('name')uses the result ofCache().store('name'), so it checks the named store withCoreFlags.cacheCopiestoo. - Change:
DecryptException.toString()givesDecryptException: The encrypted value is not valid, so a log line says what failed. - BREAKING: the JSON line of
Loggeruses the standard names of log services (Datadog).levelis nowstatus(lower case).nameis nowlogger.name(left out when empty). AMapin the data goes to the top level, other data goes underpayload. The standard fields can not be replaced by a data key. Pretty mode is the same. - BREAKING: the JSON line of
LogMiddlewarehas new field names.levelis nowstatus.source_ipis nownetwork.client.ip.request_idis nowhttp.request_id. New:http.methodandhttp.url.payload.requestandpayload.headersstay. Thefiltergets the new map. It can not changetimestamporlogger. Aloggerkey in the data is always ignored. - Change:
LogMiddlewarenow writes throughLogger. It followsLoggerConfig(enabled,level,prettyPrint). WithprettyPrintit prints the colored text line.enabledis now optional: not set follows the logger,falseturns only the request logs off. - Change:
Loggercollects lines and writes them in one write every 20 ms (or 64 KB), not oneprint()per line. Awarn,warning,dangerorerrorline is written at once, after the lines before it. The buffer is written when the app stops. - Fix: pretty
Loggerlines fordebug,warninganderrorhave a color. Before, they printednullin the color code. - New:
dox_coreexports theJSONhelper.JSON.stringifygives a String.JSON.bytesgives UTF-8 bytes in one pass.JSON.parsereads a String or UTF-8 bytes. Use bytes for sockets, files, queues and HTTP client bodies. Do not returnJSON.bytesfrom a controller. - OpenAPI: a route with the
Canmiddleware gets a401and a403answer in the docs. A route withGuestMiddlewareorValidateSignaturegets a403. They are found by class name. A@Responsewith the same status wins. - OpenAPI: the
ValidationErrorschema is in the docs whenever a route has the automatic422answer, also when it comes from areq.validateSchema(...)call. - New:
ServerTimingmiddleware. It adds aServer-Timingheader with thehandlerandtotaltime of the request. It is off unless you add it, because it shows timing to clients. Use it in development or for trusted clients. - New:
ServerTiming.add(name, duration)andServerTiming.measure(name, fn)add your own timing to the current request, with no request passed. The same name is summed and counted. Without the middleware they do nothing. The namestotalandhandlerare kept for the built-in times: your own ones are sent asapp_totalandapp_handler. AServer-Timingheader that the app sets itself is kept, and the times are added after it. - New:
AfterResponse.run(work)runs work after the answer of the current request is sent. Any code can call it, with no request passed. It is off untilAfterResponse.enable()(for example in thesetup()of a provider). Errors in the work are reported and never stop the server. - Fix:
Dox().stop()closes theIsolateBusagain after the providers shut down. Before, a provider that used the bus during its shutdown joined it again, and the open port could keep the process alive. - Docs:
IsolateBus.publishthrows for a value that can not be sent, before any isolate gets it. In the main isolate it throws only when another isolate listens on the bus.
3.1.3 #
- New:
IsolateBussends a message from one isolate to all the other isolates of the app, with no Redis.publish(channel, message)sends,on(channel)gets the messages of one channel,sizecounts the isolates that listen. The main isolate keeps the hub, like theRateLimitcounts. - New:
Dox().isolateCountis the number of isolates that really run, in every isolate. It also countsDox().totalIsolate(n)and the one isolate on Windows.
3.1.2 #
- Uses dox_validation 3.1.2, so
@Describe('...')can be used on DTO fields.
3.1.1 #
Cache().flexibletakes a nullstale: keep the last good value until a refresh replaces it.- New:
Hash.sha256(value)gives the SHA-256 hex of a value, to store API keys and access tokens as a hash (not for passwords). - New:
ValidationException.issueskeeps every issue of a failed DTO or schema check (path, rule code, message, params). AnExceptionHandlercan use it for another 422 shape, like[{field, message, rule}]. - New:
RequestBodyandBodyKindare exported, soreq.requestBody.kindcan tell invalid JSON (BodyKind.invalidJson) from no body, without importing a file oflib/http.
3.1.0 #
- Behavior change: without Redis,
RateLimitcounts are now shared by all isolates. Before, each isolate counted alone, so the real limit wasmaxtimes the number of isolates. Nowmaxholds for the whole server. An app with more than one isolate gets a lower real limit than before. Raisemaxif you relied on the old number. - Security: new check of the
Originheader on a WebSocket upgrade. UseRoute.websocket(allowedOrigins: [...])for one route, orAppConfig.webSocketAllowedOriginsfor all of them. It is off by default, so apps do not change. A WebSocket route with no check prints one warning on stderr at start. - Security fix:
back()only follows aRefererof the same host. A referer of another site goes to the fallback. Before, it was an open redirect. - Fix: a multipart body with no boundary or no
Content-Dispositiongets 400, not 500. - Fix: the headers of
abort()are kept on routes that have a next middleware. - Fix: a mounted handler that throws now gives 500. Before, the client could hang.
- Fix: a download name with quotes or non-ASCII letters now gets a safe
Content-Disposition. - New: one warning on stderr when CORS has origin
*together withcredentials: true. - New:
Crypt.encryptString/Crypt.decryptString(andCrypt.encrypt/Crypt.decryptfor JSON values) use theAPP_KEYof the app. Old keys inpreviousKeysstill decrypt. - New:
Hash.check, the same asHash.verify, with the Laravel name. - New:
Cache().many(keys)andCache().putMany(values, duration:)on the facade. The store already had them. - New:
MethodOverride(header: true)also reads theX-HTTP-Method-Overrideheader on a POST. It is off by default, so apps do not change. - Fix:
Route().setStatics(Route().statics)emptied the static folders. It cleared the list before it copied it. - Fix: after
%decoding, the.wherecheck now lets.match a new line. Before,.where('page', '.*')did not match/docs/a%0Abany more. req.pathIs(pattern)cleans each pattern once, not on every call.- Docs:
Route.viewis the WebDAVVIEWmethod. It does not render a template like LaravelRoute::view.Route.wheresays the value is checked again after decoding. - Security fix:
.wherenow checks the param again after%decoding. Before, it checked only the text as it is in the URL. So.where('name', '[^/]+')let/nos/..%2F..%2Fetc%2Fpasswdthrough, and the controller got../../etc/passwd. Now a decoded value that does not match the regex makes the route not match, like any other miss (the next route, the fallback or 404). Params with no%and routes without.wheredo not change. - Security fix:
req.pathIs()now cleans the path like the router does. Before, it only dropped the/at the start. So/admin/and/admin//reached the/adminroute, butpathIs('admin')was false, and a middleware guard on it was skipped. Now//counts as one/, and a/at the end does not matter, in the path and in the pattern. A path that matched before still matches. - Fix: with more than one isolate,
Route.staticFilesadded beforestartServer()and outside aRouterworked only in the main isolate. A file like/app.cssgot a 404 at random. Now the static folders go to every isolate, like routes and fallbacks. - Fix: a route with an optional param, like
/greet/{name?}, now shows in the OpenAPI docs as both/greetand/greet/{name}. Before, only/greet/{name}was there, because the?was removed beforedox_openapicould see it. - Fix:
req.session.reflash()now keeps the flash data when it is the first use of the session in a request. Before, it kept nothing, because the old flash keys were read before the session was loaded. - Docs:
hasdoes not read dot keys (onlyinput,filled,exists,missing,booleanandintegerdo).Route.redirectdoes not fill{id}in the target and drops the query string. A GET to a POST-only path gets the fallback if a fallback covers the path, else 405. A fallback added afterstartServer()does not reach the other isolates. - With
MethodOverride, a POST to a path with no route for any method gets 404 at once. Before, Dox read the whole body first. - Fix: with
MethodOverride, a POST with_method=PUTto a path with no PUT route now says "PUT is not allowed" in the 405 message. Before, it said "POST is not allowed". - The router calls
Route()once per route lookup, not twice. - The warning for a middleware that returns
nullreadsAPP_ENVonce, not on every such request. - Fix:
Crypt.decryptof a value made withCrypt.encryptString(text that is not JSON) gave a 500 error with aFormatException. Now it throwsDecryptException, a 400 error. - Fix: in the OpenAPI docs, the short path of an optional route, like
/greetfor/greet/{name?}, listed a 404 "Not found" answer. It has no param, so no record can be missing. Now only/greet/{name}lists the 404. - Fix: a
Route.fallbackin a group with a param in its prefix, like{tenant}, now matches, andreq.paramgives the param. Before, the prefix was compared as plain text, so the fallback never ran. - Fix:
.where('id', '^[0-9]+$')now matches. A leading^and a trailing$are dropped. Before, they ended up inside the route regex, so the route never matched. req.pathIs()andreq.routeIs()build the regex of a pattern once, not on every call.- Fix:
req.pathIs()gives false for a path with a bare%or a bad code like%zz. Before, it threw an error and the client got 500. req.boolean()no longer makes a new set of true words on every call.- New:
Route.match(methods, path, handler)adds one route for each method in the list.Route.any(path, handler)adds one for GET, POST, PUT, PATCH and DELETE. OPTIONS is left out, so the CORS preflight answer still works. - New:
Route.redirect(from, to, status:)andRoute.permanentRedirect(from, to). 302 and 301. - New:
.where(param, regex)on a route. The route matches only when the param text matches the regex. Else the next route is tried. Routes without it match the same as before. - New:
Route.fallback(handler)answers a GET or HEAD request that matches no route and no static file. It runs its middleware, so in a router the global middleware runs too. It follows the group prefix and domain. The built-in 404 and 405 do not change. - New: in development (
APP_ENVisdevelopmentorlocal), Dox prints a warning to stderr when a middleware returnsnull. That ends the request with an empty 200, and the controller does not run. Nothing else changes. - New request helpers on
DoxRequest:input(key, defaultValue)takes a default. A dot key likeuser.nameoritems.0.idreads inside maps and lists. A key that is in the input as it is still wins, so old code works the same.filled(key): the key is there and not empty.exists(key): the key is there, with any value.missing(key): the key is not there.hasdoes not change.except(keys),boolean(key),integer(key, defaultValue).file(key)andhasFile(key)for uploads.bearerToken()reads the token of anAuthorization: Bearerheader.path(),fullUrl(),pathIs(pattern)androuteIs(pattern). A*in the pattern matches any text. It ispathIs, notis, becauseisis a Dart keyword.
- Docs: the
abortexample now usesreq.auth?.id().req.auth?.iddoes not exist. - New:
MethodOverridemiddleware. Add it toAppConfig.globalMiddleware, and a POST request with a_methodfield ofPUT,PATCHorDELETEgoes to the route of that method. So a plain HTML form can reachRoute.put,Route.patch,Route.deleteandRoute.resourceroutes.req.methodgives the new method.CsrfMiddlewarestill checks the request. Other_methodvalues and other request methods are ignored. It is off when the middleware is not there. - Fix:
res.header(name, value)now replaces a header with the same name in any case, likewithHeadersdoes. Before,header('Cache-Control', ..)aftercache()sent twoCache-Controlvalues. - Break: removed the unused
middlewareAndControllerHandlerandgetDoxRequesthelpers. - Fix:
res.withHeaders(map)now adds the headers to the ones set before it. Before, it dropped them all, also theContent-Dispositionof a download. A key in the map replaces the header with the same name, in any case (cache-controlandCache-Controlare one header). - New:
SessionMiddleware().fromCookie(value)loads a session from its cookie value, with no request. Use it for a Socket.IO login. Give the value as the browser sent it (still encrypted). It runs the same checks as the middleware: a changed cookie, a cookie of another name, a cookie made with another APP_KEY, an expired session or an unknown session id gives an empty session. Changes to it are not saved. - New:
DoxCookie.decrypt(name, value)decrypts a cookie value likereq.cookie(name)does.req.cookienow uses it, with no change in what it accepts. - New:
package:dox_core/command.dartwith theCommandbase class. A package or an app adds its owndoxcommands with it. Name a library with a top-levelcommandslist in thedox: commands:key of pubspec.yaml, and thedoxCLI finds it. It is a separate library, so it does not clash with otherCommandclasses (like the one ofpackage:args). - New:
MigrationFileinpackage:dox_core/command.dart. A command writes a migration intodb/migrationwith it, with the same file name asdox make:migration. It does not write a second migration with the same name. - Fix:
Route.mountmatches whole path parts only. A mount at/adminnow gets/admin,/admin/and/admin/..., but no longer/administratoror/admin-login. Only requests that went to the wrong handler change. A prefix that ends in/(like Socket.IO's/socket.io/) works as before. - Fix:
//counts as one/when a path is matched to a mount prefix. So/admin//secure/xgoes to a mount at/admin/secure. The handler still gets the path as it came. - Behavior change: when two mount prefixes match, the longest one wins. Before, the first one added won. Apps with one mount, or with mounts that do not overlap, do not change.
- New:
Route.mount(prefix, handler, middleware: true)runsAppConfig.globalMiddleware(security headers, CSRF, rate limit) before the raw handler. A middleware that gives a response stops the request.RequestTimeoutdoes not run for a mount. When two mount prefixes match, the longest one wins.terminatesteps run once the answer is sent. The global CORS config does not apply to a mount. The default is still no middleware, so Socket.IO does not change. RequestFile.headnow keeps the first 128 KB of a big upload (on disk), and all bytes of a small upload (in memory, no copy). Before, it kept 32 bytes. A JPEG keeps its image size after the photo metadata, so@Dimensionsandv.file().dimensions()need these bytes.- New:
Route.staticFiles(prefix, folder, maxAge:)serves a folder (CSS, JS, images) for GET and HEAD requests that match no route. Routes always win..., dot files and folders get 404. Files getLast-Modified,304, Range support, the global CORS headers and an optionalCache-Control. The prefix followsRoute.group, the router prefix andRoute.domain. - New:
Route.staticFilessends a weakETag(from the file size and change time). A matchingIf-None-Matchgets304with no body.If-None-Matchwins overIf-Modified-Since. - New:
Route.staticFilessends files in a.well-knownfolder at the top of the folder (ACME challenges,security.txt). Every other dot name, also inside.well-known, still gets404. - Fix: a file response with
If-Rangenow uses theRangeonly whenIf-Rangeis the file'sLast-Modifieddate or its strongETag. Else it sends the whole file with200, so a resumed download does not mix two versions of a file. - Fix: a
Range,If-Modified-SinceorIf-None-Matchheader sent on two lines no longer gives500. - Fix: a static file
304has the file's content type, nottext/plain. - New:
AppConfig.idleTimeout. A keep-alive connection with no new request for this long is closed. Default 30 seconds, as before. Behind a load balancer, set it longer than the balancer's idle timeout (eg. 65 seconds for AWS ALB). Needs dox_http_native 3.0.3. - New:
AppConfig.maxConnections. The most connections one isolate holds open at once. Must be 1 or more (0 or less throws anArgumentErrorwhen the server starts). When it is full, new clients wait in the OS listen queue until a connection closes. WebSocket connections and connections that are still closing count too. The queue holds up to 1024 clients, and the OS can make it smaller (somaxconn; 128 by default on macOS). When the queue is full, new clients wait and then time out. On Linux each new client goes to one isolate (SO_REUSEPORT), so it can wait for a full isolate even when others have room. Default no limit, as before. Needs dox_http_native 3.0.3. - New:
Route.websocket(maxMessageSize:). A bigger message closes the socket with 1009. Default 16 MB, as before.
3.0.2 #
- Change: a Redis cache store with no
prefixgets<app name>_cache:fromAPP_NAME(likemy_shop_cache:), so two apps on one Redis do not share keys or flush each other's cache. Existing Redis cache keys are not found once after the update. Rate limit counters, cache locks andcachedriver sessions start fresh, so users with acachedriver session log in again. Set'prefix': 'dox_cache:'on the store to keep the old keys. - New: the
Cache()facade hasflexibleandtouch, andremember/rememberForevertakedecodeandlock. - Perf: the route binder does not load a value again when a middleware already bound it, like
Can(param: 'post')of dox_auth. - New:
RequestIdmiddleware. Each request gets an id in theX-Request-Idheader and inreq.requestId. A safe id from the client is kept.LogMiddlewarelines haverequest_id, andExceptionHandler.reportcan readExceptionHandler.requestId. - New:
ETagmiddleware. GET and HEAD answers with a body in memory get a weakETag. A matchingIf-None-Matchgets304 Not Modifiedwith no body. - New: signed urls.
Route.signedUrl(name, params:, query:, expires:, absolute:, baseUrl:)adds asignature(HMAC-SHA256 with thedox:signed-urlkey) and an optionalexpires. TheValidateSignaturemiddleware answers403for a bad or expired url. Old keys fromAppConfig.previousKeysstill work. - New:
RequestTimeout(Duration)middleware andRoute.get(...).timeout(Duration). A slow route answers503with the coderequest_timeout. The late result is dropped. - New:
IDoxTerminableMiddleware. Itsterminate(req, res)runs after the answer is sent. An error in it is reported, and never changes the answer. Routes without one do not pay for it. - Fix: a middleware item with no
handlestep at the start of a route list ended the request with an empty answer. It is now skipped.
3.0.1 #
- Perf:
AESEncryptor(encrypted cookies, the cookie session, CSRF) now runs AES-GCM in Rust (AesGcmof dox_http_native 3.0.2), with the AES instructions of the CPU. One session cookie took about 116 µs to encrypt and 95 µs to decrypt, now about 1.7 µs and 0.9 µs. The output is the same, so cookies made before still open. - Removed the
pointycastledependency. HKDF now uses HMAC-SHA256 ofpackage:crypto(from the Dart team). The keys are the same. - New: a path that has routes, but not for the request method, answers
405 Method Not Allowedwith anAllowheader (likeAllow: GET, POST, HEAD). Before, it was404. - New:
abort(code, [message, headers])andHttpStatusException(code)for any status. Common codes get a defaulterrorCodeandmessage. Theheadersare sent with the answer. - New:
ForbiddenHttpException(403) andMethodNotAllowedHttpException(405). - New: bracket keys in form bodies and query strings nest, like in Laravel.
tags[]=a&tags[]=bgivesreq.input('tags') == ['a', 'b'], andaddress[city]=xgives a map. A repeated key with no brackets still keeps its last value. - New:
AppConfig(previousKeys: [...]). Encrypted cookies and cookie sessions made with an oldAPP_KEYcan still be read, so a new key does not log out every user.AESEncryptor.decodehas a newpreviousSecretsoption. - Fix: path params are now URL-decoded.
/users/a%20bgives'a b', not'a%20b'. A URL fromRoute.url()now gives back the same value. A param that is not valid UTF-8 (like%ff) gives 404. - Fix: 5xx HTTP exceptions (like
InternalErrorExceptionandQueryException) are now sent toExceptionHandler.report. Before, everyIHttpExceptionwas skipped, so real server errors never reached the logs or Sentry. 4xx exceptions are still not reported. - Fix:
req.headersjoins repeated header values with,. Before, twoAcceptvalues became one string with no separator. - Fix: a
Rangeheader with a number too big for an int gave 200 with an empty body. A start that is too big now gives 416, and a suffix that is too big gives the whole file. - Fix:
req.methodis now the request method. A HEAD request on a GET route saidGET. - Fix: on a route with no params, a write to
req.paramstayed for the next requests to that route. Each request now has its own map.
3.0.0 #
- The first stable release.
3.0.0-rc.1 #
- Breaking: Dox no longer uses
APP_KEYas it is. It makes one key per purpose from it with HKDF-SHA256 (RFC 5869):dox:cookiefor cookies and the cookie session,dox:encryptforAESEncryptor, and more. See the newKeyDerivationclass. Existing encrypted cookies, sessions and tokens become invalid after this version. Users must log in again. AESEncryptor.encodeanddecodetake apurposelabel. The default isdox:encrypt. The secret can now have any length.- Fix:
Hash.makeandHash.makeAsyncwith a password over 72 bytes threw the bcrypt error, and its text held the password. So the password could end up in the logs. Dox now throws its ownArgumentErrorwith no password in the text. - New:
Hash.equals(a, b)compares two secrets in constant time.CsrfMiddlewareuses it. - Fix: the
cookiesession driver did not check the save time in the cookie. A copied cookie stayed valid untilAPP_KEYchanged. A session older thanlifetimeis now a new empty session. - Breaking:
req.authis now its own field on the request, not a value in the input. Before, a query or body fielddox_authentication_instancemadereq.auththrow a 500.AUTH_REQUEST_KEYis removed. UseAuth().setUser(req, user)or setreq.auth. - Fix:
APP_ENV=testingstopped the app on a badAPP_KEY. It is now treated liketest: only a warning. Loggeris now exported frompackage:dox_core/dox_core.dart.- The HTTP exceptions (
NotFoundHttpExceptionand the others) take adynamic message, likeIHttpException. A map message is sent as JSON as it is, likeNotFoundHttpException(message: {'error': 'not_found'}). - Security: the server now sends
X-XSS-Protection: 0, not1; mode=block. OWASP says the old browser filter should be off.SecurityHeadershas a newxssProtectionoption. Anulloption (or anullvalue inextra) now removes the header, also a server default likeX-Frame-Options. - Security:
CsrfMiddlewareno longer reads_tokenfrom the query string. It reads only the body and theX-CSRF-TOKEN/X-XSRF-TOKENheaders. - Doc comments: fixed the examples of
Cache.remember,Route.domain,Route.middlewareandRoute.disabledCors.
3.0.0-alpha.17 #
- Version bump only, to match the other packages.
3.0.0-alpha.16 #
- Version bump only, to match the other packages.
3.0.0-alpha.15 #
- Change: the startup hook is
DoxProvider. Writeclass X extends DoxProvider.setup()runs once in every isolate at start.shutdown()is optional and runs once in every isolate when the app stops. List providers inAppConfig.providers, or add them withDox().addProvider()andDox().addProviders(). The container method isc.provider<T>().
3.0.0-alpha.14 #
- Fix:
AUTH_REQUEST_KEYis now only indox_core, so importingdox_coreanddox_authtogether no longer gives an "ambiguous import" error. - Fix:
response(x).header('Content-Type', 'image/svg+xml')failed with "More than one value for header content-type". The defaulttext/plainstayed next to the new type. Nowheader()replaces the content type, the same ascontentType(). The name can be in any case. - Fix: when sending the error answer failed too, the client got no answer and waited until the timeout. Now Dox reports the error and sends a plain 500. When the head is already sent, it closes the response.
- New:
.env.testing. When the app runs its tests (dart test, or a realAPP_ENV=testing), Dox reads.env.testingon top of.env. Its keys win over.env. A real environment variable still wins over both. It works forEnv.get()and the typedAppEnv.load(). Use it for a test database:DB_NAME=my_app_test. NewEnv.isTesting, andEnv().load(testing: true). - New:
DoxTestClient.withSession()gives a test client that works like a browser. It keeps the cookies of every response, removes deleted or expired ones, and sends theXSRF-TOKENcookie back inX-XSRF-TOKENonPOST,PUT,PATCHandDELETE. It does not follow redirects.client.cookiesgives the kept cookies. The normal client does not change. - Fix:
OpenApiConfig(enabled: null)now treats an emptyAPP_ENVasdevelopment, the same default asappEnvof the typed env. Before,/docswas off whenAPP_ENVwas not set (for example in CI). SetAPP_ENV=productionin production. - Change: an empty
APP_ENVmeans production everywhere in Dox:/docsis off, the 500 error text is hidden and a badAPP_KEYstops the app. SetAPP_ENV=developmentin your.envand in CI. TheappEnvdefault of the typed env in the docs and examples is nowproductiontoo (wasdevelopment). - New:
@Securityon a middleware class sets the login scheme of its routes in the OpenAPI docs.OpenApiConfig.securityByMiddlewarestill wins over it. - Change: a middleware class name that ends with
AuthMiddleware(and has no@Security) now gets abearerAuthscheme with nobearerFormat. Before, the docs called every such token a JWT.
3.0.0-alpha.13 #
- New:
OpenApiConfig(include: ['/api/*'], exclude: ['/api/internal/*'])picks which routes go in the OpenAPI docs by path. A*at the end matches the rest of the path.
3.0.0-alpha.12 #
- Breaking:
dox_coreno longer depends ondox_storageanddox_socketio. Add the package you use to your app.- Storage:
Storage(),StorageConfigandStorageDiskFactorymoved todox_storage.AppConfig.storageis removed: extendStorageServicefromdox_storage(class AppStorageService extends StorageService { AppStorageService() : super(storageConfig); }).Route.files()is nowStorage.route().Dox().storageis nowStorage.manager.RequestFile.store()needsimport 'package:dox_storage/dox_storage.dart'. - Socket.IO:
SocketIoConfigmoved todox_socketio.AppConfig.socketIois removed: extendSocketIoServicefromdox_socketio.Dox().socketIois nowSocketIoService.server. dox_coreno longer exportsDisk,DriveManager,FileNotFoundExceptionandStorageException. Import them fromdox_storage.StreamFileandDownloadableFilestay indox_core.
- Storage:
- Fix: the OpenAPI docs could give a route the docs of another controller with the same method name. The docs now pass the controller class of
(C c) => c.methodandRoute.get<C>routes to the registry. - New:
ControllerAction.controllergives the controller class.
3.0.0-alpha.11 #
- New: middleware that runs after the controller. Implement
IDoxNextMiddleware(handle(DoxRequest req, Next next)), or use a function(DoxRequest req, Next next).await next()runs the rest of the middleware and the controller and gives aDoxResponse, so the code after it can change the status, headers and cookies. A thrown error comes back as its error response, so the after part still runs. Before-only middleware work as before. A route with nonextmiddleware takes the same fast path as before. - New:
DoxResponse.statusandDoxResponse.headersgetters. - New:
redirect(url, status: 302)andback(req, fallback: '/')helpers. - New: sessions.
SessionMiddlewaregives each requestreq.sessionwithget,put,has,forget,all,flush,pull,flash,reflash,keep,regenerate,invalidateandtoken.AppConfig(session: SessionConfig(...))picks thecookiedriver (all data in a cookie, encrypted with AES-GCM, 4 KB limit) or thecachedriver (a random id in the cookie, the data in adox_cachestore likeredis). The cookie isHttpOnlyandSameSite=Laxby default. The cookie driver reads the session on first use. The session is saved, and the cookie sent, only when it changed. - New:
CsrfMiddleware.POST,PUT,PATCHandDELETErequests must send the session token in_token,X-CSRF-TOKENorX-XSRF-TOKEN, else419(TokenMismatchException). It sets anXSRF-TOKENcookie that axios and Inertia send back for you.except:skips paths like/api/*. - New: a validation error on a request with a session that does not want JSON (a form post, an Inertia request) flashes
errorsand the old input (never password fields), and redirects back. JSON requests still get422. Read them withreq.session.errorsandreq.session.old('email').req.session.flashErrors(...)does the same by hand. Newreq.expectsJson()andreq.hasSession. - New:
DoxCookie(sameSite: SameSite.lax). - New:
TestResponse.cookiesandDoxTestClient.withCookies(...), to go on with a session in tests.
3.0.0-alpha.10 #
- Version bump only, to match the other packages.
3.0.0-alpha.9 #
- New: a real IoC container.
IocContainer(Dox().ioc) hasget<T>(),has<T>(),singleton<T>(),factory<T>(),instance<T>(),override<T>()andclearOverrides(). Each isolate has its own container: a singleton is one instance per isolate, made on first use. - New:
AppConfig(container: registerContainer)with the function fromlib/container.g.dart(made bydox_builder). Every isolate runs it. The routers and services it finds are registered for you, soAppConfig.routersandAppConfig.servicescan stay empty. The ones you list there still work and come first. - New: typed routes.
Route.get<UserController>('users', (UserController c) => c.index)(also post, put, patch, delete and the others). The controller comes from the container, once per isolate, at start.(UserController c) => c.indexwithout<UserController>works too.Route.resource('users', UserController)takes a controller class. - New: a controller parameter whose type is in the container gets it from the container.
- New: route model binding for
@DoxModelclasses. A controller parameter of typeUsergets theUserof the{user}param (or the next param), found by its primary key. No row answers 404.Route.bindstill wins. - Breaking: the old
IocContainermethodsregister,registerByName,registerSingletonandgetByNameare removed. Usefactory,singletonandget. - New: named routes.
Route.get('/users/{id}', c).name('users.show'), thenroute('users.show', params: {'id': 5})gives/users/5.query:adds a query string.Route.group(..., name: 'admin.')puts a prefix in front of the names inside. Resource routes are namedblogs.index...blogs.destroy;Route.resource(..., name:)picks another base name. A name used twice stops the app at start. An unknown name, a missing param or an extra param throws anArgumentError. - New: route model binding without
dart:mirrors.Route.bind<User>('user', (String id) => User().find(id))runs before the controller of every route with a{user}param. The controller gets it as aUser userparameter, or withreq.bound<User>('user'). A binder that givesnullanswers 404. - New:
ExceptionHandler, the one place that turns an error into a response. Extend it and setAppConfig(exceptionHandler: ...).report(error, stackTrace)logs,render(error, req)picks the response. The default answers are the same as before. A URL with no route goes through it too. - Breaking:
AppConfig.errorHandleranddefaultErrorHandlerare removed. OverrideExceptionHandler.reportinstead. It gets the same errors: every error that is not anIHttpException, also errors outside a request. A thrown value that is not anExceptionorError(like aString) is now reported too. responseHandlerstill works and still runs afterrender.- New:
RateLimitmiddleware.RateLimit(max: 60, per: Duration(minutes: 1), key: (DoxRequest req) => req.ip()). One request too many gets429withRetry-After. Every answer hasX-RateLimit-LimitandX-RateLimit-Remaining. The counts live in Redis when the default cache store is Redis (shared by all isolates and servers), else in memory. Fixed window. NewTooManyRequestsException. - New:
SecurityHeadersmiddleware. It addsX-Content-Type-Options,X-Frame-Options,Referrer-Policy,Permissions-PolicyandCross-Origin-Opener-Policy, andStrict-Transport-Securityon https requests only. Each one can be changed or turned off withnull.Content-Security-Policyis off by default. - New:
Route.health('/health', checks: {...}). It answers 200{"status": "ok"}, or 503 when a check throws, returnsfalseor times out.HealthCheck.cache()checks the cache. The error text is in the answer only indevelopmentandlocal. - New:
package:dox_core/testing.dartwithDoxTestClient.DoxTestClient.start(appConfig)runs the app in the test on a free port.get,post,put,patch,delete,send,withHeadersandwithToken.TestResponsehasstatus,body,json,headersandexpectStatus,expectJson,expectBody,expectHeader. - dox_core now depends on
matcher(for theexpectmethods ofTestResponse).
3.0.0-alpha.8 #
- Uses dox_http_native 3.0.0-alpha.8: pipelined requests are about 2.8 times faster (1 core: 172k to 480k req/s). Normal requests are as fast as before.
- Security: every file response (
File,Storage().stream(),Storage().download(),Route.files) sendsX-Content-Type-Options: nosniff. Before, aFileresponse and a raw download did not. - New:
Route.files(path, download: true)sends every file as a download (Content-Disposition: attachment). Use it for user uploads. html, svg, xml and javascript files are still always sent as a download in a sandbox. - Fix: a trusted proxy
X-Forwarded-Forhop with a port (1.2.3.4:5678,[::1]:5678) is now read without the port. Before, it was not a valid ip, soreq.ip()could be wrong. A bare IPv6 like::1still works.
3.0.0-alpha.7 #
- Breaking:
dox_websocketis gone. Usedox_socketiofor realtime.Dox().websocketandDox().setWebsocket()are removed. - Breaking:
Route.websocket(path, handler)is now a raw WebSocket route.handlergets the openWebSocketand theDoxRequest. Middleware runs first. A request that is not a WebSocket upgrade gets 400. dox_http_nativenow lives in its own repo (dartondox/dox-http-native). Dox uses it from pub.dev (^3.0.0-alpha.7). Its build hook downloads a ready-built library, so you do not need Rust.- Perf: faster route matching. A plain route is found with one map lookup, also when a param route was added before it (as long as that param route can not match the same path). Param routes are grouped by their first path segment, so a request only tries the routes that can match. The first matching route still wins.
- Perf: the request handler reads
HostandContent-Typeonce per request.Hostis read only when the app has aRoute.domain()route.HttpBody.read()takes an optionalcontentType. - Perf: on the native server, a JSON or form body is used as it is, with no stream in between. The size limit is still checked.
- Perf: JSON responses are encoded in 8 KB chunks, not 256 bytes.
- Perf: fewer objects per request.
RouteData.params,DoxRequest.paramandDoxRequest.methodare made on first use.RouteData.domainLoweris made once. CORS header lists are joined once. - Perf: one Future less per async request (
then(onError:)instead ofthen().onError()). - Perf: multipart parsing makes its regexes once, and no longer builds a
Future.anyper chunk. - Perf:
LogMiddlewarelowercases theredactwords once, not per key. - Perf: an error response reads
APP_ENVand lowercases it only when the value changed. - Perf:
IocContainercallsT.toString()once per call. - Breaking: the
dart:ioserver is gone. Every app runs on the native server (dox_http_native), also an app with WebSocket or Socket.IO routes.AppConfig.server, theServerBackendenum and theDOX_SERVERenv var are removed.DoxServer.usesNative()and theisolateIdoption ofDoxServer.listen()are removed. - Breaking: when the native library does not load, Dox stops at start with an error. It says why (eg. an ABI mismatch) and how to fix it (install Rust so the build hook can build it, or rebuild your
lib_pathlibrary). Before, Dox logged a warning and useddart:io. - On a graceful stop (SIGTERM,
Dox().stop()), open WebSockets get close code 1001. - Perf:
AESEncryptorkeeps the key bytes of the last secret and writes the output into one buffer. Decode reads the nonce and text without copies. The output format is the same. - New:
Hash.makeAsync()andHash.verifyAsync(). They run bcrypt in another isolate, so a request does not block the server. - New:
Hash.rounds(default 10) sets the bcrypt cost.Hash.make()also takesrounds:. - Security: the app does not start when
APP_KEYis empty, not exactly 32 characters, or one of the old public sample keys from.env.example. With such a key anyone can sign tokens and cookies. InAPP_ENVdevelopment,localortestDox only logs a warning. A longer key (eg. 48 or 64 characters) is refused too, because AES needs a key of 16, 24 or 32 bytes and every encrypted cookie failed with it. Before, only an empty key inproductionstopped the app. Rundox key:generatefor a new key. - Security: a multipart part header with many backslashes (
name="\\\\...) no longer blocks a server isolate for hours (ReDoS in the quoted string regex). - Security: a
StreamFileresponse (Storage().stream(),Route.files()) with an html, xml, svg or javascript type is sent withContent-Disposition: attachmentandContent-Security-Policy: sandbox. EveryStreamFilegetsX-Content-Type-Options: nosniff. Before, an uploadedx.htmlorx.svgwas shown inline, and its script ran on the app origin (stored XSS). - Security: a
Route.domain()route only matches when theHostheader matches. Before, a request with noHostmatched every domain route. AHostwith a port (admin.app.com:8080) now matchesRoute.domain('admin.app.com'). - Security: an encrypted cookie is bound to its name (AES-GCM associated data). A value made for
localegivesnullwhen it is sent asuser_id.AESEncryptor.encode()/decode()take a newassociatedDataoption. Encrypted cookies made by older versions no longer decrypt, soreq.cookie()givesnullfor them once. Users may need to log in again. - Security:
DoxCookieisHttpOnlyby default.secureisnullby default, which setsSecurewhen the request came over https (req.scheme(), seetrustedProxies). SethttpOnly: falseorsecure: falseto change it. - Security: the native server checks
maxBodySizeandmaxMultipartSizeon their own. Before, Rust let any body up to the bigger limit (100 MB) through, so a JSON body could take 100 MB of RAM before Dart said 413. - New
AppConfig.bodyTimeout(default 120 seconds). On the native server, a client that does not send the whole body in this time gets 408. It stops slow clients that hold memory and connections.
3.0.0-alpha.6 #
- Security:
Storage().putRequestFile()andRequestFile.store()no longer trust the client file name when the bytes are a known format that does not match it. Before, a valid png sent asa.htmlpassed@Image/@Mimesand was saved as.html, soRoute.files()served it astext/htmlon the app origin (stored XSS). Now it is saved with the extension of the bytes (.png). - Security: new upload file names use a random uuid (v4), not a time-based one (v1). A v1 name shows the upload time and the server, and the next name is easy to guess.
- Security:
trustedProxies: ['*']trusts the direct peer only.req.ip()is the right-mostX-Forwarded-Forhop, the one the proxy added. Before,*also trusted every hop in the header, soreq.ip()was the left-most value, which the client sets (X-Forwarded-For: 6.6.6.6). That broke IP rate limits and allow lists, also behind the Fly.io proxy of the deploy guide. - Security:
LogMiddlewarewrites[REDACTED]for body fields and headers whose name haspassword,passwd,secret,token,authorization,cookie,api_key,api-keyorapikeyin it (upper or lower case). Before, the login body (with the password) and, withwithHeader: true, theAuthorizationheader went to the log as plain text. Change the list withLogMiddleware(redact: [...]). - Security: an error that is not an
IHttpExceptionanswers500with{"code": "server_error", "message": "Server Error"}. The error text is sent only whenAPP_ENVisdevelopmentorlocal. Before, the client always goterror.toString(), which can hold SQL, table names, file paths or database hosts.errorHandlerstill gets the full error. - Graceful shutdown closes the cache stores of
Cache()(eg. Redis), in every isolate, after theDoxShutdownservices. Your app needs no extra code. - The
ORMServiceof a new project implementsDoxShutdownand callsSqlQueryBuilder.close(), so the database connections close on shutdown too. In an older project, add this tolib/services/orm_service.dart:class ORMService implements DoxService, DoxShutdown { // setup() as before @override Future<void> shutdown() async { await SqlQueryBuilder.close(); } }
3.0.0-alpha.5 #
- Fix: CORS
origincan be a list. Dox compares the requestOriginwith the list and sends back only the origin that matches, or no header. Before, it joined the list with commas, and browsers rejected it. A list also sendsVary: Origin. - Breaking:
AESEncryptornow uses AES-GCM with a random nonce for each message. Before, it used AES-CTR with an all-zero nonce and no message check. Old encrypted cookies and values can not be read. - Breaking:
AESEncryptor.decodethrowsDecryptException(400) when the text was changed or the key is wrong. Before, it printed an error and returned''. req.cookie()returnsnullfor an encrypted cookie that can not be decrypted.- Fix:
Hash.verifyreturnsfalsefor a malformed hash. Before, it threw. AESEncryptorandDecryptExceptionare now exported frompackage:dox_core/dox_core.dart.- Fix: in
.env,KEY=value # notegave the valuevalue # note. A#after a space now starts a comment. A#inside quotes, or with no space before it, is kept. - Fix: the
.envparser removed every quote character inside a value. Now only the quotes around the value are removed. - Fix:
HEADrequests got 404, alsoHEAD /docs. AHEADrequest now runs theGETroute of the same path. The answer has the status and headers ofGET, with no body. - New: Dox listens on
PORTwhenAPP_PORTis not set. Cloud Run, Fly, Render and Heroku setPORT.APP_PORTstill wins. - New:
AppConfig.hostand the env varAPP_HOSTpick the network interface to listen on, like127.0.0.1. The default is the same as before: all interfaces (::, IPv6 and IPv4). - Fix: the start log always said
http://127.0.0.1:<port>. It now shows the real host and port, likehttp://[::]:3000. - Removed the unused
sprintfdependency. - New: graceful shutdown. On
SIGTERMorSIGINTevery isolate stops taking new connections and lets open requests finish, up toAppConfig.shutdownTimeout(default 8 seconds). Then Dox runsDoxShutdownservices and exits with code 0. Before, open requests were cut. A second signal stops at once. - New:
DoxShutdown. A service that also implements it getsshutdown()in every isolate on stop, to close connections. - New:
await Dox().stop()stops the server gracefully in every isolate, without exit. - Fix: an
s3storage disk withoutbucket,keyorsecretfailed withNull is not a subtype of String. Now it fails with a clear message that names the missing setting. - Fix: a URL with no route now answers like a thrown
NotFoundHttpException. The body is JSON ({"code": "not_found", "message": "GET /x not found"}), and the appresponseHandlerruns for it, so apps can format it. - Fix: the error answer of an
IHttpExceptionnow has itserrorCode. A text message gives{"code": "<errorCode>", "message": "<text>"}as JSON. Before, the body was plain text anderrorCodewas never sent. AMapmessage (like validation errors) is still sent as it is. - Fix: the
Loggernow readsLoggerConfig.level. Lines below that level are not printed. Levels from low to high:debug,info(andsuccess),warn,error(anddanger). - Fix:
Route.group('blogs')withRoute.get('all')made/blogsall. Path parts now join with one/. This also works for nested groups,Route.prefixandRoute.resource. - Fix:
Route.resourcehid every error from the controller. Now it only skips methods the controller does not have.
3.0.0-alpha.4 #
- Version bump only, to match the other packages.
3.0.0-alpha.3 #
- New:
Cache().getRaw(key)gives the cached value as JSON text, with no decode. Send it as a JSON response with no extra encode step. - New Redis cache option
pool_size(seedox_cache).
3.0.0-alpha.2 #
- New default server:
dox_http_native(Rust hyper parses HTTP, your code stays in Dart). Hello world goes from about 41k to about 144k req/s on one isolate. Setserver: ServerBackend.dartIoinAppConfig(orDOX_SERVER=dartio) to usedart:io. Dox usesdart:ioby itself, with one warning line, when the native library does not load, and for apps with WebSocket or Socket.IO routes. - Faster requests: a simple
GEThello world went from about 31k to about 40k req/s on one isolate (plaindart:iois about 46k). A request with no body and sync middleware and controller now runs with noFuture.req.ip(), the query,req.all()and cookies are read on first use only. Reading the client ip was the biggest cost, because it asks the socket. Clean paths skip the two regex calls, and plain routes are found with a map lookup. - Fix: a
@Dtobody with aRequestFilefield shows asmultipart/form-datain the OpenAPI docs. - Fix:
req.ip()gave::ffff:127.0.0.1for IPv4 clients. Now it gives127.0.0.1. The same goes forX-Forwarded-Forhops. - Needs Dart 3.13 or newer.
- All dependencies updated to their latest versions.
- Removed the
encryptpackage (not maintained, and it blockedpointycastle4). AES for cookies and the file cache now usespointycastle4. The output is the same, so old cookies and cache files still decode. - Fix:
Env.get()of a missing key with no default gave the text"null". A missingAPP_KEYbecame the key"null", which anyone can guess. NowStringgives'',String?givesnull, andint/num/double/boolthrow a clear error. New:Env.get<bool>(). - Startup stops with an error when
APP_KEYis empty andAPP_ENV=production. Other environments log a warning. - New: typed input with DTOs. A controller asks for a
@Dtoclass by type:store(CreateUser body). Dox reads the body (or the query forGET), checks it, and answers422with{"items.1.quantity": "..."}when it is wrong.await req.validate<T>()does the same inside a method. See the Validation guide. - New:
AppConfig(dtos: dtos)(fromlib/dtos.g.dart) andAppConfig(validationMessages:)for other languages.req.localeis the firstAccept-Language. - New: typed controller parameters.
DoxRequestanywhere, one@Dto, andString,int,double,num,boolpath params by position. A path param that does not fit its type answers404. The types are read once at start; an unknown type stops the server with a clear error. - New: optional path params
{id?}. - New: query strings and form data with repeated keys (
tags=a&tags=b) and bracket keys (address[city],items[0][name]) for DTOs. - A DTO answers
400for a body that is not valid JSON, and415for a body type it can not read. RequestFileimplementsFileInputand keeps its first bytes, so@Mimesand@Imagecheck the real file type.- Breaking: removed
req.validate(Map),req.validateAsync(),FormRequest,AppConfig(formRequests:),DoxValidator,IocContainer.registerRequest()andprocessInputMapper(). Use a DTO.req.validateSchema(schema)stays for input you only know at runtime. - Breaking: a controller with more path params than the route has
{...}params stops the start. Before, the extra ones got''. - Fix: a typed path param like
int idgave a 500 (it was always aString). - A
ValidationExceptionfromdox_validation(for exampleschema.parse()in a controller) answers 422. dox_coreexportsdox_validation(not itsValidationException), with the DTO annotations.dox_ormalso hasSchema, andpackage:uuidhasUuid: usehideor a prefix in a file that needs both.- Breaking:
Cache()runs ondox_cache.AppConfig.cacheis adox_cacheCacheConfig(defaultStore:, stores:)with option maps.CacheDriverInterfaceandFileCacheDriverare removed. Values must be JSON types.putwithout a duration keeps the value forever (was 1 hour). New:add,pull,increment,decrement,remember,rememberForever,lock,tags. - Breaking:
Storage()runs ondox_storage.AppConfig.fileStorageis nowAppConfig.storage(StorageConfig(defaultDisk:, disks:)with option maps forlocal,s3,memory).StorageDriverInterfaceandLocalStorageDriverare removed. An unknown disk name throws. Storage().stream()anddownload()stream from any disk (S3 too), withContent-Length. New:url,signedUrl,use()for the fullDisk.- New
Route.files('files')serves local signed URLs (403 for a bad signature). New catch-all route param{path*}. - OpenAPI:
AppConfig(openApi: OpenApiConfig(...))adds/docs,/openapi.jsonand/openapi.yaml. On by default only whenAPP_ENVis development or local. Bodies come from the routebody:option or a DTO.Dox().writeOpenApi(dir)writes the files. RouteData.preMiddlewarenow holds the group and router middleware.- Socket.IO:
AppConfig(socketIo: SocketIoConfig(enabled: true, ...))serves/socket.io/on the app port, before the router.Route.mount(prefix, handler)is the raw hook. Off by default. - No extra work per request when OpenAPI or Socket.IO is off.
- OpenAPI docs are automatic.
dart run build_runner buildwriteslib/openapi.g.dart. Pass it asOpenApiConfig(registry: openApiRegistry). Each route then gets its summary and description (from the///comment), tags,Class.methodoperation id, typed path params, request (a@Dtoclass) and answer schema (from the return type), plus401,404,422and500. - A middleware whose class name ends with
AuthMiddlewareaddsbearerAuthto the docs, with no config. - A
GETorDELETErequest class becomes query params in the docs. dox_coreexportsOpenApi,OpenApiRegistry,OpenApiOperation,OpenApiRouteBindingandResponseDocofdox_openapi.- The OpenAPI JSON and YAML are encoded once and kept, not on each request.
- New
EnvReaderandEnvExceptionfor the typed env class (@DoxEnv()). The real environment wins over.env, the same asEnv.get().Env.get()stays for dynamic keys. - OpenAPI:
/docsuses Scalar by default.OpenApiConfig(ui: DocsUi.swagger)gives Swagger UI. NewOpenApiConfigoptions:scalar: ScalarOptions(...)(theme, dark mode, download button, proxy) andpageTitle.
3.0.0-alpha.1 #
- Version 3 of Dox. All Dox packages now share one version.
- Needs Dart 3.6 or newer.
- See the release notes for all main changes.
- Faster: streamed bodies, all CPU cores, faster router.
uuid4 andmime2.
2.0.0 #
- Change validation {attribute} to {field}
- Restructure response handler and middleware
- Restructure app configuration
- Extract websocket as separate package
dox-websocket - Type improvement on usage of auth package
- Bug fix on multithread with services
- Support storage class for file storage
- Add more unit/integration test coverage
- Fix bug for websocket running on multiple isolates
- Update cache config setting on app config
- Added support for multi-thread http server which is 10x faster on concurrency request
- Added support for services (i.e database, redis) to run on each isolate/multi-thread
- Added cache class that run file driver as default
- Added support for custom cache drivers, i.e redis, memcached
- Added
JSON.stringify()andJSON.parse()that support DateTime to encode - Added support for DateTime object on http response/return data
- Added support of size and bytes information on uploaded
RequestFile - Bug fixed on multipart form data file store
- Removed database config option in app config.
- Moved ioc container from
Global.ioctoDox().ioc - Improvement on routes
- Rename Handler interface to ResponseHandlerInterface
1.0.6 #
- Remove third party dot env package and replace with own
Envclass
1.0.5 #
- Modify request auth getter to function to support type injection
1.0.4 #
- Added interfaces/classes for authentication
- Bug fixed on router prefix
- Bug fixed on cookie return type
String?
1.0.3 #
- Ignore error on missing method of resource route
- Added single quote rule in linter
1.0.2 #
- Bug fixed method not found on resource route
1.0.1 #
- Added missing types on functions and arguments
- Added linter rules
1.0.0 #
- First stable release
1.0.0-alpha.2 #
- Support domain routing
- Improvement group routing
- Support middleware routing
- Added app level middleware support
- Added function's self documentation
- Websocket improvement and support multiple path
- Support serializer
1.0.0-alpha.1 #
- Added support for validation
- Added support for form data for file uploading
- Improve error handling
1.0.0-alpha.0 #
- Refactor the code
- Added test cases
- Added support for global middleware
- Added support to throw error exception in response and add support to handle via response handler
- Rename BaseHttpException to HttpException
- Bug fixed on cookie response
0.0.17 #
- Separate Query builder from core
0.0.16 #
- Replace with dox query builder
- Added feature to auto encode List
- Added resource routes
- Added
req.input()in DoxRequest - Added support CORS
- Added More Response options on DoxResponse
- Added
Hash.make('password')for password encryption - Added Support websocket