Step 1: Create the project
This step makes a new Dox project, points it at SQLite, starts the dev server and calls the first route.
1. Install the CLI and make the project
dox create downloads the dox-sample template from GitHub and names the package blog.
So every import in this tutorial starts with package:blog/.
2. Use SQLite
dox create already made .env with a new random APP_KEY. The template already uses SQLite:
Dox makes the file db/dox.sqlite at the first start. SQLite does not read the other DB_* lines.
The app reads these keys through the typed class in lib/config/env.dart. See Environment variables.
The folder must exist
Dox makes the database file when it is missing, but not its folder.
If you set DB_NAME=storage/blog.sqlite, run mkdir storage first.
3. Start the server
dox s runs the code generator and the server. It restarts the server when you save a .dart file.
The first start is slower, because it compiles the SQLite library.
At the first start it also runs the migrations of the template.
The last line is a JSON log line with this message:
Open it at http://localhost:3000. The number of isolates is the number of CPU cores.
Check it
In a second terminal:
The route is in lib/routes/api.dart. The ApiRouter has the prefix api, so /ping is served at /api/ping.