---
title: "Cloudflare Workers ގައި web tier"
description: "ކުޑަވެފައިވާ ޤުއަރޭ web tier އެއް Cloudflare Workers ގައި ހިންގާށެވެ."
image: "https://docs.quirelms.com/og.png"
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.quirelms.com/dv/llms.txt
> Use this file to discover all available pages before exploring further.

# Cloudflare Workers ގައި web tier

<span id="the-web-tier-on-cloudflare-workers"></span>

މިޒައިން `docs/architecture/23-ops.md` ގެ 6 ވަނަ ސެކްޝަނެވެ. Workers އިން ކުޑަވެފައިވާ web tier އެއް ހިންގައެވެ. Workers ގައި feature parity އަކީ scope ނޫނެވެ (PRD ގެ 12 ވަނަ section): މި target އަކުން ނުކުރެވޭ ތަކެއްޗެއް ހިންގާއިރު ނަން ދައްކައި ރިޖެކްޓްކުރެވެއެވެ.

## މި release ގެ ޙާލަތު <!--quire:status-in-this-release-->

ކޮންފިގަރޭޝަން ހުރެއެވެ (`apps/web/wrangler.jsonc`، `cloudflare-module` Nitro preset، Hyperdrive bridge އަދި startup checks). Worker އަށް R2 އަށް S3-compatible storage (`QUIRE_STORAGE_DRIVER=s3`)، request ތަކާ ދެމެދު realtime driver (`QUIRE_REALTIME_DRIVER=durable_objects` ނުވަތަ `centrifugo`)، shared cache (`QUIRE_CACHE_DRIVER=postgres` ނުވަތަ `valkey`) އަދި HTTP email provider ލާޒިމެވެ. މިއެއް ނެތްނަމަ Worker ހިންގާނެއް ނޫނެވެ، log ގައި ސެޓިންގްތައް ނަންދެއެވެ. Durable Objects driver އަކީ `apps/realtime-worker` ގެ realtime Worker ގެ client އެކެވެ (fan-out، presence އަދި history އަށް channel އަކަށް އެއް Durable Object، disconnect އަށް މީހަކަށް އެއް); ތިރީގައި އެއާއެކު deploy ކުރާ، ނުވަތަ Centrifugo ބޭނުންކުރާށެވެ.

## ބައިތައް <!--quire:the-pieces-->

| ބައި | Cloudflare ގައި |
| --- | --- |
| `web` | `nodejs_compat` އާއެކު Worker |
| Postgres | Hyperdrive މެދުވެރިކޮށް external: application role އަށް `HYPERDRIVE`، އެ physical database ގެ report role އަށް `REPORT_HYPERDRIVE`. ހިންގާއިރު web tier ކޮންމެ connection string އެއް `DATABASE_URL` އަދި `QUIRE_REPORT_DATABASE_URL` އަށް ކޮޕީކުރެއެވެ |
| Files | R2، S3 API އިން (`S3_ENDPOINT=https://<account>.r2.cloudflarestorage.com`); `FILES` binding އިން bucket ގުޅުވައެވެ |
| Background jobs | write އާއިއެކު enqueue ކުރަންޖެހޭނަމަ Hyperdrive މަތިން pg-boss. Companion worker ގައި `QUIRE_QUEUE_DRIVER=cloudflare` ހުރިޔާ ލުއި job (unordered notification އަދި webhook delivery) Cloudflare Queues އިން ދާނެއެވެ؛ Postgres އަށް poll ނުކުރާނެއެވެ. Companion worker ދެމެދު ދެތިން ހިންގައެވެ |
| Realtime | Durable Objects އާއެކު realtime Worker، `apps/realtime-worker` |
| `worker`، `scheduler`، `collab`، `content`، ClamAV، Gotenberg، ffmpeg | Companion container host. Worker އިން މިތަކެއް ނުހިންގާނެއެވެ |
| Tracing | Workers observability؛ `wrangler.jsonc` ގައި enable ކުރާށެވެ |

`REPORT_HYPERDRIVE` އިން `HYPERDRIVE` ނަންދޭ physical database ގެ report role ދެއެވެ. ތިރީގައި އެންގި ގޮތަށް މި target އިން additional physical database ތަކަށް pinned tenant ނުހިންގާނެއެވެ.

## މި target އަކުން ނުކުރެވޭ ތަކެތި <!--quire:what-this-target-cannot-do-->

ހިންގުމުގައި ހުރިހާ މައްސަލަ ލިސްޓްކޮށް ރިޖެކްޓްކުރެއެވެ:

- **SMTP ނެތެވެ.** `QUIRE_EMAIL_PROVIDER_CONFIG` ގައި HTTP provider އެއް ބޭނުންކުރާށެވެ.
- **Local disk ނެތެވެ.** `QUIRE_STORAGE_DRIVER` އިން object storage ނަން ދޭންޖެހެއެވެ.
- **In-process realtime ނުވަތަ cache ނެތެވެ.** Worker request ތަކާ ދެމެދު memory ނުޝެއާރކުރެއެވެ، އެހެންވެ `QUIRE_REALTIME_DRIVER=inprocess` އަދި `QUIRE_CACHE_DRIVER=memory` މަނާވެއެވެ.
- **Worker ގައި ClamAV، Gotenberg ނުވަތަ ffmpeg ނެތެވެ.** `CLAMAV_URL`، `GOTENBERG_URL` އަދި `FFMPEG_PATH` Worker ގައި ސެޓްކުރިޔާ ރިޖެކްޓްވާނެއެވެ؛ އޭތައް companion worker ގައި ސެޓްކުރާށެވެ.
- **Dedicated database ހުރި އޮގަނައިޒޭޝަން ނެތެވެ.** Worker ގެ Hyperdrive binding ތައް deploy ވަގުތު ނިންމެވެއެވެ؛ އަމިއްލަ database ހުރި އޮގަނައިޒޭޝަނަށް “މިތަނުގައި ނުލިބޭ” ޕޭޖެއް ދެއެވެ. Compose ނުވަތަ Vercel އިން އެއީ ހިންގާށެވެ.

އަދި އެނގިގެންވާ އެއްކަމެއް: **prerender އަދި incremental static regeneration Workers ގައި ނުހިންގާނެއެވެ**، framework documentation ގައި ކީ ބުނިޔަސް. ކޮންމެ route އެއްވެސް request އަކަށް render ވެއެވެ.

މި target ގައި transaction ތައް ކުރުކޮށް، network call އާއެކު އެއްވެސް transaction ނުބެހެއްޓާށެވެ: Hyperdrive connection އެއް pool އަށް އަނބުރާލާއިރު session state reset ކުރެއެވެ، އެހެންވެ tenant context transaction އަކަށް set ކުރަންޖެހެއެވެ.

## Deploy ކުރުން <!--quire:deploying-->

1. Resources ހަދާށެވެ:
   ```sh
   bun run --bun wrangler hyperdrive create quire-app --connection-string="postgres://quire_app:...@db.example.com:5432/quire"
   bun run --bun wrangler hyperdrive create quire-report --connection-string="postgres://quire_report:...@db.example.com:5432/quire"
   bun run --bun wrangler r2 bucket create quire-files
   bun run --bun wrangler queues create quire-jobs
   ```
   ދެ Hyperdrive ID ތައް `apps/web/wrangler.jsonc` ގައި ލާށެވެ.
2. Secret ތައް ކޮންމެ އެއް `bun run --bun wrangler secret put <NAME>` އިން ސެޓްކޮށް، `apps/web` އިން ހިންގައި، މިތަކެއްޗެއް ލާށެވެ: `QUIRE_SECRET_KEY`، `QUIRE_MASTER_KEY`، `QUIRE_EMAIL_PROVIDER_CONFIG`، `S3_ACCESS_KEY_ID`، `S3_SECRET_ACCESS_KEY`، `QUIRE_COLLAB_SIGNING_KEY`، `QUIRE_REALTIME_WORKER_SECRET`. އާންމު settings (`QUIRE_APP_ORIGIN`، `QUIRE_CONTENT_ORIGIN`، `QUIRE_PLATFORM_DOMAINS`، `QUIRE_DATABASE_ID`، `S3_ENDPOINT`، `S3_BUCKET`، `QUIRE_COLLAB_URL`) `vars` ގައި ލާށެވެ.
3. `apps/web` އިން build ކޮށް deploy ކުރާށެވެ:
   ```sh
   NITRO_PRESET=cloudflare-module bun run build
   bun run --bun wrangler deploy
   ```
4. Realtime Worker ވެސް web tier ގެ `QUIRE_REALTIME_WORKER_SECRET` އާއި token secret `QUIRE_REALTIME_TOKEN_SECRET` އާއެކު deploy ކުރާށެވެ (web tier އިން realtime token ތައް އޭގެ `QUIRE_REALTIME_TOKEN_SECRET` އިން ސޮއިކުރެއެވެ؛ އެއީ ނެތްނަމަ `QUIRE_SECRET_KEY` އިން. އެއްބޭނުންކުރާށެވެ)، އަދި web tier ގައި `QUIRE_REALTIME_WORKER_URL` އެއަށް ދާ address ސެޓްކުރާށެވެ:
   ```sh
   cd apps/realtime-worker
   bun run --bun wrangler secret put QUIRE_REALTIME_WORKER_SECRET
   bun run --bun wrangler secret put QUIRE_REALTIME_TOKEN_SECRET
   bun run --bun wrangler deploy
   ```
5. ލުއި job އަށް Cloudflare Queues ބޭނުންކުރާނަމަ ކޮންމެ light queue އަކަށް އެއް queue ހަދައި، companion worker ގައި މިތަކެއްޗެއް ސެޓްކުރާށެވެ (Queues read އަދި write އިޚްތިޞާޞްހުރި API token):
   ```sh
   bun run --bun wrangler queues create quire-events-notifications
   bun run --bun wrangler queues create quire-events-notifications-dead
   bun run --bun wrangler queues create quire-events-webhooks
   bun run --bun wrangler queues create quire-events-webhooks-dead
   ```
   `QUIRE_QUEUE_DRIVER=cloudflare`، `CLOUDFLARE_ACCOUNT_ID`، `CLOUDFLARE_QUEUES_TOKEN` އަދި `QUIRE_QUEUE_PREFIX` ނޫންނަމަ `quire-` ސެޓްކުރާށެވެ.
6. [Vercel guide](/dv/ops/vercel/) ގެ 3 ވަނަ step ފަދައިން companion host ހިންގާށެވެ. Worker deploy ކޮންމެއްގެ ކުރިން migrations އެތާ ހިންގާނެއެވެ.

ރިޖެކްޓްވި config އެއް `bun run --bun wrangler tail` ގައި "The web tier did not start on cloudflare" ކަމަށް ދައްކާ، ބަދަލުކުރަންޖެހޭ ސެޓިންގްތައް ލިސްޓްކުރެއެވެ.

Source: https://docs.quirelms.com/dv/ops/cloudflare/index.mdx
