Deployment
Deploying a Zintrust application is straightforward thanks to its zero-dependency core and standard Node.js architecture.
Prerequisites
- Node.js 18 or higher.
- A supported database (SQLite, MySQL, or PostgreSQL).
Build Process
First, compile your TypeScript code to JavaScript:
npm run buildThis will generate the production-ready files in the dist/ directory.
Environment Configuration
Ensure your .env file is properly configured for production:
APP_ENV=production
APP_DEBUG=false
DB_CONNECTION=mysql
DB_HOST=your-db-hostRunning the Server
You can start the server using node:
node dist/src/bootstrap.jsFor production, it's recommended to use a process manager like PM2:
pm2 start dist/src/bootstrap.js --name zintrust-appMigrations
Run your migrations on the production database:
zin migrate --forceBundle Optimization
For cloud deployments (AWS Lambda, Cloudflare Workers), bundle size is critical. Zintrust includes a built-in Bundle Optimizer to reduce your deployment artifact size.
The optimizer performs:
- Tree-shaking: Removes unused code and dependencies.
- Platform-specific pruning: Removes adapters not needed for the target platform (e.g., removing SQL drivers for Cloudflare).
- Minification: Compresses JavaScript files.
To run the optimizer:
# Optimize for AWS Lambda
npm run build:lambda
# Optimize for Cloudflare Workers
npm run build:cloudflareYou can also run the optimizer manually:
# Analyze current bundle
npx tsx src/builder/BundleOptimizer.ts analyze
# Optimize for specific platform
npx tsx src/builder/BundleOptimizer.ts lambdaStatic Assets
If your application serves static assets, it's recommended to use a reverse proxy like Nginx to serve them directly for better performance.