Repository navigation
feat: add Cloudflare Workers backend (D1 + Nitro + Drizzle) replacing… #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 17 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
21ff151
feat: add Cloudflare Workers backend (D1 + Nitro + Drizzle) replacing…
Swastikdan 99403d9
feat(backend): implement Cloudflare Workers backend with D1 and Nitro
Swastikdan 8fe646f
refactor(schema): replace Zod with Valibot across all server schemas …
Swastikdan ada5a9d
ci: configure Cloudflare deploy workflow for cloudflare and feature b…
Swastikdan d5136d6
chore: update pnpm-lock.yaml after removing zod
Swastikdan daaa8c5
ci: specify pnpm version for GitHub Actions workflow
Swastikdan b67efdf
ci: rely on packageManager field in package.json for pnpm version
Swastikdan a917bf8
fix(import): sanitize reaction, progress, and rating inputs to satisf…
Swastikdan 8a93a62
perf: remove Upstash Redis in favor of direct D1 edge queries and opt…
Swastikdan 4619230
chore: update pnpm-lock.yaml after dependency removals
Swastikdan 75b4d4c
fix(auth): handle expired/malformed Clerk tokens gracefully without l…
Swastikdan a811412
chore: Update public app URL to swastik.workers.dev
Swastikdan 7e3595d
docs: update README with Cloudflare Workers, D1, Drizzle, and Valibot…
Swastikdan 1b5c629
feat: implement RequestBatcher utility and batch watchlist membership…
Swastikdan 1bb75c6
feat: implement upsert logic for watch items and episode progress, up…
Swastikdan a81daa2
refactor: improve watchlist import schema and validation logic for ro…
Swastikdan 66f6f08
refactor: update watchlist metadata types to handle nullability and i…
Swastikdan 253774a
refactor: update watchlist mutation handlers to return authoritative …
Swastikdan dc6ca80
refactor: add lifecycle-managed flush to RequestBatcher, introduce Da…
Swastikdan e833633
refactor: remove unnecessary pulse animations and optimize CSS transi…
Swastikdan 80abae3
refactor: harden security with D1 batch constraints, live JWT admin c…
Swastikdan cfd4242
refactor: migrate daily pick logic to custom hook and integrate toast…
Swastikdan b69dffe
feat: implement user caching with fast-path lookups and optimize data…
Swastikdan 68068ca
refactor: migrate backend from Convex to Drizzle and implement reposi…
Swastikdan 5cce60d
refactor: migrate backend from Convex to Drizzle and implement reposi…
Swastikdan 972393f
docs: add comprehensive project documentation and remove docs folder …
Swastikdan 68e3eb0
perf: optimize memory usage and UI performance by reducing query garb…
Swastikdan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| name: Deploy Cloudflare | ||
| on: | ||
| push: | ||
| branches: | ||
| - cloudflare | ||
| - feat/convex-to-traditional-backend | ||
| workflow_dispatch: # Allows manual trigger from GitHub Actions UI | ||
|
|
||
| jobs: | ||
| deploy: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: pnpm/action-setup@v4 | ||
| - uses: actions/setup-node@v4 | ||
|
Swastikdan marked this conversation as resolved.
Resolved
Swastikdan marked this conversation as resolved.
Resolved
|
||
| with: { node-version: 22, cache: pnpm } | ||
| - run: pnpm install --frozen-lockfile | ||
| - run: pnpm typecheck | ||
|
|
||
| - name: Apply D1 migrations (prod) | ||
| uses: cloudflare/wrangler-action@v3 | ||
| with: | ||
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
| command: d1 migrations apply pebbly --remote | ||
|
|
||
| - name: Build (Nitro cloudflare preset) | ||
| run: pnpm build | ||
| env: | ||
| VITE_CLERK_PUBLISHABLE_KEY: ${{ secrets.VITE_CLERK_PUBLISHABLE_KEY }} | ||
| VITE_PUBLIC_TMDB_ACCESS_TOKEN: ${{ secrets.VITE_PUBLIC_TMDB_ACCESS_TOKEN }} | ||
| VITE_PUBLIC_TMDB_API_URL: ${{ secrets.VITE_PUBLIC_TMDB_API_URL }} | ||
| VITE_PUBLIC_APP_URL: ${{ secrets.VITE_PUBLIC_APP_URL }} | ||
| VITE_PUBLIC_VIDEO_URL: ${{ secrets.VITE_PUBLIC_VIDEO_URL }} | ||
|
|
||
| - name: Deploy Worker | ||
| uses: cloudflare/wrangler-action@v3 | ||
| with: | ||
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
| command: deploy | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { defineConfig } from "drizzle-kit"; | ||
|
|
||
| // generate-only config: `drizzle-kit generate` emits SQL migrations into ./drizzle. | ||
| // They are applied to D1 with `wrangler d1 migrations apply pebbly [--local|--remote]`, | ||
| // so no live DB connection (driver) is required here. | ||
| export default defineConfig({ | ||
| dialect: "sqlite", | ||
| schema: "./src/server/db/schema.ts", | ||
| out: "./drizzle", | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import { defineConfig } from "drizzle-kit"; | ||
| import fs from "node:fs"; | ||
|
|
||
| /** | ||
| * Drizzle Studio dashboard for the remote (production) D1 database. | ||
| * | ||
| * pnpm db:studio | ||
| * | ||
| * Uses the `d1-http` driver (Cloudflare API) — no local sqlite client needed. | ||
| * Credentials come from the environment: | ||
| * - CLOUDFLARE_API_TOKEN (API token with "D1 Edit" permission) | ||
| * - CLOUDFLARE_ACCOUNT_ID (Cloudflare account id) | ||
| * The database id is read from wrangler.toml. | ||
| * | ||
| * For the local D1 database use: | ||
| * wrangler d1 execute pebbly --local --command "SELECT * FROM watch_items;" | ||
| */ | ||
| function readWranglerTomlValue(key: string): string | undefined { | ||
| try { | ||
| const raw = fs.readFileSync( | ||
| new URL("./wrangler.toml", import.meta.url), | ||
| "utf8", | ||
| ); | ||
| const match = raw.match(new RegExp(`^${key}\\s*=\\s*"([^"]+)"`, "m")); | ||
| return match?.[1]; | ||
| } catch { | ||
| return undefined; | ||
| } | ||
| } | ||
|
|
||
| export default defineConfig({ | ||
| dialect: "sqlite", | ||
| schema: "./src/server/db/schema.ts", | ||
| out: "./drizzle", | ||
| driver: "d1-http", | ||
| dbCredentials: { | ||
| accountId: process.env.CLOUDFLARE_ACCOUNT_ID ?? "", | ||
| databaseId: readWranglerTomlValue("database_id") ?? "", | ||
| token: process.env.CLOUDFLARE_API_TOKEN ?? "", | ||
| }, | ||
|
Swastikdan marked this conversation as resolved.
Resolved
|
||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.