Deployment
Deploy the API gateway
Deploy the app as a standard Next.js service with database migrations, object storage, provider secrets, and scheduled internal jobs.
Production flow
pnpm install
pnpm db:setup
pnpm db:generate
pnpm db:review
pnpm api:test
pnpm build
pnpm db:migrate
pnpm startRequired env
NEXT_PUBLIC_APP_URL=https://your-domain.com
NEXT_PUBLIC_APP_NAME=APIAny
DATABASE_PROVIDER=postgres
DATABASE_URL=postgresql://user:pass@host:5432/db
AUTH_SECRET=generate-with-openssl-rand-base64-32
INTERNAL_JOBS_TOKEN=long-random-token
API_CALLBACK_MAX_RETRIES=3
API_CALLBACK_TIMEOUT_MS=10000
API_RETENTION_DAYS=30
API_CLEANUP_BATCH_SIZE=5000Scheduled jobs
Call internal job endpoints from your scheduler with x-internal-jobs-token set to INTERNAL_JOBS_TOKEN. Keep jobs idempotent because schedulers can retry.
Core jobs
POST /api/internal/jobs/process-pending-media
POST /api/internal/jobs/process-pending-callbacks
POST /api/internal/jobs/check-stale-media-tasks
POST /api/internal/jobs/check-api-channels
POST /api/internal/jobs/scheduled-maintenanceRelease checklist
- pnpm build passes with the target DATABASE_PROVIDER.
- Production schema changes are generated with pnpm db:generate, checked with pnpm db:review, and manually reviewed before pnpm db:migrate.
- The app responds and the configured database is reachable.
- process-pending-media, process-pending-callbacks, check-stale-media-tasks, check-api-channels, and scheduled-maintenance can run with a valid internal jobs token.
- STORAGE_* is configured when durable image, video, or audio result URLs are required.
- pnpm api:test verifies API key budgets, credit deduction, failed-task refund, and retention cleanup; payment webhook idempotency is verified separately.
- The previous container image and database backup are available before release.
