Changelog
What changed in dox_core, newest first. Each version lists the changes you may notice in your app. The full list, with every detail, is in CHANGELOG.md.
3.2.8
New
AppConfig(ports: [PortConfig(8443, http2: true, tls: TlsOptions(...))])adds ports that have their ownhttp2andtls. One process can serve plain HTTP and HTTPS at the same time. See Plain HTTP and HTTPS together.
Changed
req.scheme()andreq.isSecure()come from the port of the request. For an app with noports, the result is the same as before.Dox().server.reloadCertificate()also reads the certificate files of each port ofportsthat hastls.
3.2.7
Fast JSON also needs dox_builder 3.2.3, dox_annotation 3.2.1 and dox_orm 3.2.5. Run dart run build_runner build after the upgrade.
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. See Returning a DTO. @Serialize()on a serializer or on a plain class makes the generator write its JSON code, with no map. See Serializer.JsonWritableandJsonWriter: a class writes its own JSON inwriteJson(). See Response.DoxResponse.contentBytes(bytes)sets a text body that is already UTF-8 bytes.DoxResponse.getContentBytes()gives a text body as bytes.ETag.ofUtf8(bytes)gives the tag of UTF-8 bytes with no decode.AppConfig(additionalPorts: [8082])makes the same process also listen on more ports, with the same routes and settings.AppConfig(compressLevel:)sets the gzip level, from 1 (fast) to 12 (small). The default is 1.CoreFlags.sdkJsonEncodermakes Dox use the JSON encoder of the Dart SDK. Off by default.
Changed
- With
dox_http_native, gzip uses libdeflate at level 1. It is faster, and the body is a little bigger. SetcompressLevel: 6to get about the same size as before. DoxRequest.uriis a getter and a setter, and it is made on first use. A read or a write works as before.
Fixed
- A query with an escape that is not UTF-8, like
?a=%ff, gave a 500. Now it gives a 400. - A cookie that the native server refuses made the request get no answer. Now the client gets a 500.
Performance
- Dox encodes JSON with its own encoder. A list of 40 rows (6.7 kB) goes from 41 µs to 16.5 µs. The bytes of the response do not change.
- A model in a response makes no
Map. A list of 40 rows with two dates each goes from 44 µs to 8 µs. - A list of
@Dtoobjects encodes in 2.8 µs. On the same data and machine,JSON.stringifyof Bun takes 3.3 µs. - A request makes fewer objects: the router reads the path with no
Uri, and a plain query is split with no decode.
3.2.6
New
AppConfig.tlsserves HTTPS with no proxy. Give it aTlsOptionswith the certificate file and the key file. Withhttp2: true, the client selects HTTP/2 or HTTP/1.1 in the handshake. It needsdox_http_native3.2.6 or later.Dox().server.reloadCertificate()reads the certificate and key files again, without a restart.- With
AppConfig.tls,req.isSecure()is true, cookies getSecure, andDoxTestClientspeaks HTTPS. CoreFlags.isolateGroupsstarts each server isolate in its own isolate group, so a GC pause in one isolate does not stop the others. Off by default.Dox().isPrimaryis true in the first isolate only.- A warning at the start when the app has more isolates than the Dart VM runs at the same time (8 by default). It gives the
DART_VM_OPTIONSvalue to use.
Fixed
- A multipart body that is not valid made the request wait with no answer, or gave a 500. Now it gets a 400.
- A bracket key with an index that is not plain digits, like
k[01]=z, lost its value. Now it is a map key and keeps its value.
3.2.5
Fixed
- A route part can have text and params together, like
/v{id}/{name}and/{a}-{b}. Each param has its own name and value. Two rare routes change:/v{id}now matches/v5, and/{a}-{b}matches/x-ybut not/x.
Performance
- A route with params like
/users/{id}is matched without a regex. The match goes from 142 ns to 16 ns. - Needs
dox_http_native3.2.3 or later. It has lower tail latency when the server has idle CPU cores.
3.2.4
New
AppConfig.http2lets the same port also speak HTTP/2 over plain TCP (h2c).AppConfig.maxConcurrentStreams(default 250) sets the open requests of one connection.req.protocolVersiongives the version. Off by default.req.takeOverResponse()says that the handler sends the response itself. Dox then sends nothing more for the request.Route.fallback(controller, when: check)tries the fallback for any method, and answers only when the check gives true..withoutMiddleware<T>()on a route takes out every middleware of typeT, also the global ones..renderErrorsWith(renderer)on a route sends its errors to the renderer, not toExceptionHandler.render.IAuthMiddlewareis an interface for a middleware that logs a user in.asOptional()gives a copy that lets guests through.showErrors()is public. It is true whenAPP_ENVisdevelopmentorlocal.
Changed
- The OpenAPI spec no longer lists the middleware class names of a route (
x-dox-middleware).
Fixed
- The OpenAPI docs showed a route path with a
:, like/books:search, as/books{search}. Now the path is shown as it is.
3.2.3
Fixed
- In a Linux container with a CPU limit, Dox started one isolate for each CPU of the host. Now the default
totalIsolateis the number of CPUs that the container allows. - With
OpenApiConfig.includeorexclude, the docs listed every schema. Now they list only the schemas that the shown routes use.
3.2.2
New
Dox().compute(task)runs heavy CPU work (a PDF, an image, a big JSON file) on a worker isolate. The server keeps answering other requests in the meantime.AppConfig.computeWorkerssets the number of workers (default 4).- Strict mode for development:
AppConfig(strict: StrictConfig(enabled: true)). It warns when a route blocks the isolate too long, or whenHash.makeruns in the web server. Off by default. - Log lines have a tag that says where they come from:
[request],[server],[error]or[app]. Pass your own tag as the third argument:Logger.info('done', null, 'billing'). CoreFlags.rateLimitIpv6Prefixcounts an IPv6 client by its /64 prefix. Off by default.
Changed
Hash.makeAsyncandHash.verifyAsyncuse theDox().computeworkers. Before, each call started a new isolate.- The stderr warnings use the same tags.
dox: warning:and[dox]are now[server]or[request].
Fixed
- Sessions with the
cachedriver on amemorystore were kept per isolate, so users were logged out at random. They are now shared by all isolates. - A slow handler could lose its upload temp file when the client left early.
- An error after a stream started (like server-sent events) wrote
Internal Server Errorinto the stream. Now the stream just ends. - A cut multipart upload kept the request open for ever. Now it gets 400.
AfterResponsework could start before the handler ended, or never run after a sync throw.
Security
- The
RateLimitcounter without Redis now keeps at most 100,000 clients, so many fake IPs can not fill the memory.
Performance
- Faster and lighter requests: lazy request body, lazy cookie session, fewer header reads, a smaller JSON buffer, faster route matching and
RateLimiton Redis in one round trip.
3.2.1
New
AppConfig.isDevelopmentis true whenAPP_ENVisdevelopment.Env.appEnvgivesAPP_ENVin lower case.
Fixed
Env.getas the first env read of the app did not see.env. Now every env read loads.envfirst.- In
.env,KEY=#valuewas read as empty. Now it keeps#value. - A value with only spaces now gives the default.
Security
- An env error no longer prints the bad value, because it may be a secret.
- The
APP_KEYcheck refuses more public sample keys. If your key is one of them, rundox key:generate.
3.2.0
Breaking
- The JSON lines of
LoggerandLogMiddlewareuse standard log field names (Datadog).levelis nowstatus.LogMiddlewarealso renamessource_iptonetwork.client.ipandrequest_idtohttp.request_id. Command,MigrationFileandDoxProvidermoved todox_annotation.dox_corestill exports them. Upgradedox_buildertogether withdox_core.
New
CoreFlags: opt-in behaviors, all off by default. Pass them asAppConfig(flags: ...).CoreFlags.all()turns on every flag. See App config.CoreFlags.envExpandlets.envvalues use${OTHER}.export KEY=valuelines now work too.RateLimit(sliding: true)uses a sliding window.AppConfig(htmlErrors: true)sends an HTML error page to browsers. Errors stay JSON by default.- Providers get a
boot()step that runs after everysetup(). Dox().addGlobalMiddleware()lets a provider add global middleware.Dox().isWebServeris true only in the web server process.Dox().loadRoutes()gives the app routes without a server.dox route:listuses it.Route.resource(..., parameter: 'photo')names the item param.route()andRoute.url()takeabsolute: true, and put unknown params in the query string.- A cache store with
'encrypt': trueencrypts its values withAPP_KEY. ServerTimingmiddleware adds aServer-Timingheader.AfterResponse.run(work)runs work after the response is sent.session.regenerate(keepToken: true)keeps the CSRF token.dox_coreexports theJSONhelper.- An AI agent skill (
dox-core-guide). Install it withdart run skills@ get.
Changed
Loggerwrites lines in batches, not oneprint()per line. Warnings and errors are written at once.LogMiddlewarewrites throughLoggerand followsLoggerConfig.
Fixed
Route.groupand the other route scopes now restore their state when the callback throws.Dox().stop()could keep the process alive.
3.1.3
New
IsolateBussends a message to all isolates of the app, with no Redis.Dox().isolateCountgives the number of running isolates.
3.1.2
Changed
- Uses
dox_validation3.1.2, so@Describe('...')works on DTO fields.
3.1.1
New
Hash.sha256(value), to store API keys and tokens as a hash. Not for passwords.ValidationException.issueskeeps every issue, so you can build your own 422 body.Cache().flexibletakes a nullstale.RequestBodyandBodyKindare exported, to tell invalid JSON from no body.
3.1.0
Breaking
- Without Redis,
RateLimitcounts are shared by all isolates. Before, the real limit wasmaxtimes the number of isolates. Raisemaxif you relied on that. - When two
Route.mountprefixes match, the longest one wins. Before, the first one won. - Removed the unused
middlewareAndControllerHandlerandgetDoxRequesthelpers.
New
- Routes:
Route.match,Route.any,Route.redirect,Route.permanentRedirect,Route.fallbackand.where(param, regex). Route.staticFiles(prefix, folder)serves CSS, JS and images, withETag,304and Range support.MethodOverridemiddleware, so an HTML form can send PUT, PATCH and DELETE.- Request helpers:
inputwith dot keys and a default,filled,exists,missing,except,boolean,integer,file,hasFile,bearerToken,path,fullUrl,pathIsandrouteIs. Crypt.encryptStringandCrypt.decryptString, with theAPP_KEY.Hash.check, the same asHash.verify.Cache().manyandCache().putMany.Route.mount(..., middleware: true)runs the global middleware before the raw handler.SessionMiddleware().fromCookie(value)loads a session with no request, for a Socket.IO login.package:dox_core/command.dartlets a package add its owndoxcommands.AppConfig.idleTimeoutandAppConfig.maxConnections.Route.websocket(maxMessageSize:).- A warning in development when a middleware returns
null.
Fixed
res.withHeadersdropped the headers set before it.res.headeradded a second value instead of replacing one.- A mounted handler that threw left the client hanging.
Route.mount('/admin')also matched/administrator.- Static files added before
startServer()worked only in one isolate. - Many smaller router, OpenAPI and session fixes.
Security
.wherenow checks a param again after%decoding. Before,%2Fcould slip../past it.req.pathIs()now cleans the path like the router does, so/admin//can not skip a guard.back()only follows aRefererof the same host. It was an open redirect.- WebSocket routes can check the
Originheader:Route.websocket(allowedOrigins: [...]).
3.0.2
Changed
- A Redis cache store with no
prefixuses<app name>_cache:. Your old cache keys are not found once after the update. Set'prefix': 'dox_cache:'to keep them.
New
- Middleware:
RequestId,ETag,ValidateSignatureandRequestTimeout. - Signed urls:
Route.signedUrl(...). IDoxTerminableMiddlewareruns a step after the response is sent.Cache()hasflexibleandtouch.
3.0.1
New
- A path with routes, but not for the request method, gives
405with anAllowheader. Before, it gave404. abort(code, [message, headers])for any status.- Bracket keys nest:
tags[]=a&tags[]=bgives a list. AppConfig(previousKeys: [...])reads cookies made with an oldAPP_KEY, so a new key does not log users out.
Fixed
- Path params are now URL-decoded.
- 5xx HTTP exceptions now reach
ExceptionHandler.report. req.methodsaidGETfor a HEAD request.
Performance
- Encrypted cookies and sessions are about 100 times faster (AES-GCM in Rust).
3.0.0
The first stable release.