Use workers instead of pages

This commit is contained in:
Arthur Belleville 2025-07-12 19:18:43 +02:00
parent 42b64b9373
commit fce28e7ef2
No known key found for this signature in database
14 changed files with 8375 additions and 13 deletions

View file

@ -22,5 +22,8 @@ dev:
update-types:
npx supabase gen types typescript --project-id "mhcafqvzbrrwvahpvvzd" --schema public > ui/src/types/database.types.ts && cp ui/src/types/database.types.ts api/src/database.types.ts
deploy-api:
gcloud run deploy xablo-api --source api --region europe-west1 --set-env-vars "SUPABASE_URL=https://mhcafqvzbrrwvahpvvzd.supabase.co" --set-env-vars "SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im1oY2FmcXZ6YnJyd3ZhaHB2dnpkIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc0MTI0MTMyMSwiZXhwIjoyMDU2ODE3MzIxfQ.9r33CUsu6ZR4vyv4ed-UY6cLE1FZzSSxTNE8pFUKjN4" --set-env-vars "STREAM_CHAT_API_KEY=t5vvvddteapa" --set-env-vars "STREAM_CHAT_API_SECRET=zrr32sqenw3atpv9rnz2nhhyyncf7bunr7fmfqy9r7e69fcw978dhzevmhpxa2jj" --set-env-vars "FRONTEND_URL=https://develop.xtablo-source.pages.dev" --set-env-vars "EMAIL_USER=baptiste@xtablo.com" --set-env-vars "EMAIL_KEY=jayf pzpj nrsv vtim" --set-env-vars "XTABLO_URL=https://develop.xtablo-source.pages.dev"
deploy-api-dev:
gcloud run deploy xablo-api-dev --source api --region europe-west1 --set-env-vars "SUPABASE_URL=https://mhcafqvzbrrwvahpvvzd.supabase.co" --set-env-vars "SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im1oY2FmcXZ6YnJyd3ZhaHB2dnpkIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc0MTI0MTMyMSwiZXhwIjoyMDU2ODE3MzIxfQ.9r33CUsu6ZR4vyv4ed-UY6cLE1FZzSSxTNE8pFUKjN4" --set-env-vars "STREAM_CHAT_API_KEY=t5vvvddteapa" --set-env-vars "STREAM_CHAT_API_SECRET=zrr32sqenw3atpv9rnz2nhhyyncf7bunr7fmfqy9r7e69fcw978dhzevmhpxa2jj" --set-env-vars "FRONTEND_URL=https://xtablo-ui-dev.arbelleville.workers.dev" --set-env-vars "EMAIL_USER=baptiste@xtablo.com" --set-env-vars "EMAIL_KEY=jayf pzpj nrsv vtim" --set-env-vars "XTABLO_URL=https://xtablo-ui-dev.arbelleville.workers.dev"
deploy-api-prod:
gcloud run deploy xablo-api --source api --region europe-west1 --set-env-vars "SUPABASE_URL=https://mhcafqvzbrrwvahpvvzd.supabase.co" --set-env-vars "SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im1oY2FmcXZ6YnJyd3ZhaHB2dnpkIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc0MTI0MTMyMSwiZXhwIjoyMDU2ODE3MzIxfQ.9r33CUsu6ZR4vyv4ed-UY6cLE1FZzSSxTNE8pFUKjN4" --set-env-vars "STREAM_CHAT_API_KEY=t5vvvddteapa" --set-env-vars "STREAM_CHAT_API_SECRET=zrr32sqenw3atpv9rnz2nhhyyncf7bunr7fmfqy9r7e69fcw978dhzevmhpxa2jj" --set-env-vars "FRONTEND_URL=https://app.xtablo.com" --set-env-vars "EMAIL_USER=baptiste@xtablo.com" --set-env-vars "EMAIL_KEY=jayf pzpj nrsv vtim" --set-env-vars "XTABLO_URL=https://app.xtablo.com"

View file

@ -1,5 +1,9 @@
CLOUDFLARE_ENV=dev
VITE_SUPABASE_URL=https://mhcafqvzbrrwvahpvvzd.supabase.co
VITE_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im1oY2FmcXZ6YnJyd3ZhaHB2dnpkIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDEyNDEzMjEsImV4cCI6MjA1NjgxNzMyMX0.Otxn5BWCPD2ABlMM59hCgeur9Tf_Q7PndAbTkqXDPtM
VITE_SUPABASE_ID=mhcafqvzbrrwvahpvvzd
VITE_STREAM_CHAT_API_KEY="t5vvvddteapa"
VITE_STREAM_CHAT_API_KEY="t5vvvddteapa"
VITE_API_URL=https://xablo-api-636270553187.europe-west1.run.app

9
ui/.env.production Normal file
View file

@ -0,0 +1,9 @@
CLOUDFLARE_ENV=production
VITE_SUPABASE_URL=https://mhcafqvzbrrwvahpvvzd.supabase.co
VITE_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im1oY2FmcXZ6YnJyd3ZhaHB2dnpkIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDEyNDEzMjEsImV4cCI6MjA1NjgxNzMyMX0.Otxn5BWCPD2ABlMM59hCgeur9Tf_Q7PndAbTkqXDPtM
VITE_SUPABASE_ID=mhcafqvzbrrwvahpvvzd
VITE_STREAM_CHAT_API_KEY="t5vvvddteapa"
VITE_API_URL=https://xablo-api-636270553187.europe-west1.run.app

View file

@ -0,0 +1 @@
{"configPath":"../../dist/xtablo_ui/wrangler.json","auxiliaryWorkers":[]}

View file

@ -6,14 +6,19 @@
"scripts": {
"dev": "vite",
"typecheck": "tsc -b",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview",
"test": "vitest run",
"build:dev": "tsc -b && vite build --mode dev",
"build:prod": "tsc -b && vite build --mode production",
"deploy:dev": "pnpm run build:dev && wrangler deploy",
"deploy:prod": "pnpm run build:prod && wrangler deploy",
"cf-typegen": "wrangler types",
"test": "vitest run --mode dev",
"test:watch": "vitest watch",
"test:coverage": "vitest run --coverage"
},
"devDependencies": {
"@cloudflare/vite-plugin": "^1.9.4",
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@eslint/js": "^9.22.0",
"@floating-ui/react": "^0.27.4",
@ -52,7 +57,8 @@
"typescript-eslint": "^8.26.1",
"vite": "^6.2.2",
"vite-tsconfig-paths": "^5.1.4",
"vitest": "^3.1.1"
"vitest": "^3.1.1",
"wrangler": "^4.24.3"
},
"dependencies": {
"@react-stately/calendar": "^3.7.1",

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -1,7 +1,17 @@
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.node.json"
},
{
"path": "./tsconfig.worker.json"
}
],
"compilerOptions": {
"types": ["./worker-configuration.d.ts"]
}
}

8
ui/tsconfig.worker.json Normal file
View file

@ -0,0 +1,8 @@
{
"extends": "./tsconfig.node.json",
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.worker.tsbuildinfo",
"types": ["./worker-configuration.d.ts", "vite/client"]
},
"include": ["./worker-configuration.d.ts", "./worker"]
}

View file

@ -4,6 +4,7 @@ import react from "@vitejs/plugin-react";
import tailwindcss from "@tailwindcss/vite";
import { visualizer } from "rollup-plugin-visualizer";
import tsconfigPaths from "vite-tsconfig-paths";
import { cloudflare } from "@cloudflare/vite-plugin";
// https://vitejs.dev/config/
export default defineConfig({
@ -12,6 +13,7 @@ export default defineConfig({
visualizer() as PluginOption,
tailwindcss(),
tsconfigPaths(),
cloudflare(),
],
test: {
globals: true,

7358
ui/worker-configuration.d.ts vendored Normal file

File diff suppressed because it is too large Load diff

4
ui/worker/index.d.ts vendored Normal file
View file

@ -0,0 +1,4 @@
declare const _default: {
fetch(request: Request<unknown, IncomingRequestCfProperties<unknown>>): Response;
};
export default _default;

12
ui/worker/index.ts Normal file
View file

@ -0,0 +1,12 @@
export default {
fetch(request) {
const url = new URL(request.url);
if (url.pathname.startsWith("/api/")) {
return Response.json({
name: "Cloudflare",
});
}
return new Response(null, { status: 404 });
},
} satisfies ExportedHandler<Env>;

21
ui/wrangler.toml Normal file
View file

@ -0,0 +1,21 @@
name = "xtablo-ui"
main = "worker/index.ts"
compatibility_date = "2025-07-11"
[assets]
directory = "./dist/"
not_found_handling = "single-page-application"
[observability]
enabled = true
[vars]
PYTHON_VERSION = "3.11.5"
[env.production.vars]
PYTHON_VERSION = "3.11.5"
[env.production]
route = { pattern = "app.xtablo.com", custom_domain = true }
[env.dev]