A small blog app (users, profiles, posts, comments, tags) that runs on the
local Dox framework code in ../dox/packages (see pubspec_overrides.yaml).
It uses every Dox package: ORM, migrations, auth, validation, cache, storage,
OpenAPI and Socket.IO.
An end-to-end test calls every endpoint over HTTP and Socket.IO.
Check it by hand: see MANUAL_TEST.md.
cp .env.example .env
dart run ../dox-cli/bin/dox.dart key:generate # a new APP_KEY in .env
dart pub get
dart run build_runner build # models + lib/openapi.g.dartdocker compose up -d --wait # postgres 5452, mysql 3326, redis 6459, minio 9110 (console 9111)
docker compose down # stop them when donedart run bin/server.dart # http://127.0.0.1:3100 , Socket.IO /chat
dart run bin/migrate.dart # only run the migrations (also: rollback, reset, refresh, status)dart test # starts the server on a fresh database, then checks everythingThe test rolls back all migrations first, so every run starts empty. It needs redis and minio from docker compose (also for SQLite).
DB_CONNECTION picks the database: postgres (default), mysql or sqlite.
Set it in .env, or just for one run:
dart test # postgres
DB_CONNECTION=mysql dart test
DB_CONNECTION=sqlite dart test # no docker needed
DB_CONNECTION=mysql dart run bin/server.dartA shell variable wins over .env. DB_PORT defaults to 5452 (postgres) or 3326 (mysql).
SQLite uses a file: DB_DATABASE, default <system temp>/dox_test.sqlite.
A file (not :memory:) lets every isolate see the same data.
dart run is JIT: slow start, about 390 MB memory. Use the AOT build in production.
dart run ../dox-cli/bin/dox.dart build # or: dox build
./build/bundle/bin/server # run from the project folder, so it finds .env, public/ and storage/It starts in about 0.05 s and uses about 16 MB.
dart run ../dox-cli/bin/dox.dart openapi:generate # storage/openapi/openapi.json + .yaml.github/workflows/test.yaml runs dart test three times: on Postgres, MySQL and SQLite.
It checks out this repo into dox-test and dartondox/dox into dox, so the
../dox/packages paths still work. Pick the dox branch with the dox_ref input
(default develop). Redis is a service. MinIO starts with docker run.
lib/routes->lib/app/http/controllers->lib/app/services->lib/app/repositories->lib/app/modelslib/providers: dox providers (database + observers, auth, IoC container)lib/app/ws: the Socket.IO/chatnamespacelib/app/dtos:@Dtoclasses for request input.lib/app/http/rules: custom rulespublic/playground.html: the browser test page at/playgroundlib/config: all config. Env keys are typed inlib/config/env.dart(@DoxEnv).lib/constants: global constants.db/migration: Dart migrations, written with the schema builder. The same file works on Postgres, MySQL and SQLite.db/migration/migrations.dartlists them. Do not edit it:dox make:migrationanddox migration:*make it again. Add a migration withdart run ../dox-cli/bin/dox.dart make:migration <name>.