Cloudflare Integration
Zintrust is optimized for Cloudflare Workers, providing native support for D1 databases and KV storage.
D1 Database
Cloudflare D1 is a native serverless SQL database. Zintrust provides a dedicated adapter to use D1 as your primary ORM database.
Configuration
In your wrangler.jsonc (or wrangler.toml), define your D1 binding:
{
"d1_databases": [
{
"binding": "DB",
"database_name": "your_db_name",
"database_id": "your_database_id",
},
],
}In your .env or Env class, set the connection driver:
DB_CONNECTION=d1Migrations
Zintrust includes a CLI command to manage D1 migrations via Wrangler:
# Run migrations locally
zin d1:migrate --local
# Run migrations on remote D1
zin d1:migrate --remoteKV Storage
Cloudflare KV is a low-latency key-value store. You can use it as a cache driver in Zintrust.
Configuration
In your wrangler.jsonc, define your KV binding:
{
"kv_namespaces": [
{
"binding": "CACHE",
"id": "your_kv_id",
},
],
}Set the cache driver to kv:
CACHE_DRIVER=kvDeployment
To deploy your Zintrust application to Cloudflare Workers:
npm run deployThis will use Wrangler to bundle and upload your application to the Cloudflare edge.
Because the Wrangler config defines multiple environments, deployments should always specify a target environment. npm run deploy defaults to production.
# Deploy to production
WRANGLER_ENV=production npm run deploy
# Deploy to development
WRANGLER_ENV=development npm run deploy