Appearance
Deployment
Platform
Semua apps deploy ke Cloudflare:
| App | Platform | URL Pattern |
|---|---|---|
apps/web | Cloudflare Worker + ASSETS | https://xprivate.tigor.dev |
apps/docs | Cloudflare Pages | https://docs.xprivate.pages.dev |
apps/web adalah Cloudflare Worker dengan ASSETS binding. SvelteKit app di-render server-side dan static assets diserve via ASSETS binding. API ditangani oleh Worker script yang di-generate oleh @sveltejs/adapter-cloudflare.
Wrangler Configuration
Setiap app punya wrangler.jsonc sendiri. File ini adalah JSON with comments.
apps/web/wrangler.jsonc
jsonc
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "xprivate-web",
"main": "dist/index.js",
"compatibility_date": "2026-05-10",
"compatibility_flags": ["nodejs_compat"],
"observability": {
"logs": { "enabled": true, "head_sampling_rate": 1 }
},
"assets": {
"directory": "dist",
"binding": "ASSETS",
"not_found_handling": "404-page"
},
"env": {
"development": { ... },
"production": { ... }
}
}Build step: vite build (via @sveltejs/adapter-cloudflare) menghasilkan dist/index.js sebagai Worker entrypoint dan static assets di dist/.
apps/docs/wrangler.jsonc
jsonc
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "xprivate-docs",
"compatibility_date": "2026-05-11",
"pages_build_output_dir": ".vitepress/dist",
}Secrets
Secrets di-set via wrangler secret put atau Cloudflare dashboard. Jangan commit secrets ke repo.
| Secret | App | Purpose |
|---|---|---|
DATABASE_URL | web | Neon Postgres connection |
BETTER_AUTH_SECRET | web | Session signing |
GOOGLE_CLIENT_ID | web | Google OAuth |
GOOGLE_CLIENT_SECRET | web | Google OAuth |
PLUNK_API_KEY | web | Email sending |
PLUNK_FROM | web | From address email |
Local development menggunakan .dev.vars (sudah di-gitignore).
CI/CD
Pipeline yang direkomendasikan:
- Build:
pnpm builddi root - Test:
pnpm test(jika ada) - Deploy Web:
cd apps/web && wrangler deploy --env development - Deploy Docs:
cd apps/docs && wrangler pages deploy .vitepress/dist
Prefer GitHub Actions dengan cloudflare/wrangler-action.
Environment Strategy
| Environment | Neon Postgres | R2 Bucket | Purpose |
|---|---|---|---|
| Local | local/dev Neon project | emulated atau skip | Development |
| Staging | xprivate-db-staging | xprivate-storage-staging | Pre-prod testing |
| Production | xprivate-db | xprivate-storage | Live |
Setiap environment punya wrangler config terpisah atau gunakan wrangler deploy --env.
worker-configuration.d.ts
File ini di-generate otomatis oleh wrangler types. Jangan commit file ini — sudah di-gitignore. Root prepare script harus menjalankan wrangler types setelah pnpm install.
R2 Storage
@packages/storagemenggunakan R2 bindings untuk upload photo evidence dan payment proofs.- Validasi file: image only, max 5MB.
- Public access ke R2 objects via signed URLs atau Cloudflare Images — jangan expose raw R2 URLs langsung.
Email (Plunk)
- Plunk API key disimpan sebagai Cloudflare secret.
- Email sending logic di
@packages/email. - Magic link email template dikelola di sini.