From 81bb515a5bdf5db567e74628a4e09b81afacb46b Mon Sep 17 00:00:00 2001 From: Torben Sorensen Date: Sat, 22 Nov 2025 12:37:54 -0800 Subject: [PATCH] frontend work ! --- .gitea/workflows/deploy.yml | 33 ++++++++++++++++----- package.json | 3 +- src/tests/setup/integration-global-setup.ts | 7 +++-- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index cf996fd4..1109827d 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -137,13 +137,30 @@ jobs: # This maps the Gitea secret to the environment variable the application expects. run: VITE_API_KEY=${{ secrets.VITE_GOOGLE_GENAI_API_KEY }} npm run build - - name: Deploy Frontend via Local Copy + - name: Deploy Application to Server run: | - echo "Deploying frontend files to local web server path..." - # Ensure the destination directory exists before copying. - mkdir -p "/var/www/flyer-crawler.projectium.com" - # Use rsync to efficiently copy files from the 'dist' output to the web server directory. - # The '--delete' flag removes old files from the destination, ensuring a clean deployment. - # We exclude '.env.local' to prevent deleting the server-specific environment file. + echo "Deploying application files to /var/www/flyer-crawler.projectium.com..." + APP_PATH="/var/www/flyer-crawler.projectium.com" + + # Ensure the destination directory exists + mkdir -p "$APP_PATH" + + # 1. Copy the backend source code and project files first. + # We exclude node_modules, .git, and the build output (dist). + rsync -avz --delete --exclude 'node_modules' --exclude '.git' --exclude 'dist' ./ "$APP_PATH/" + + # 2. Copy the built frontend assets into the same directory. + # This will correctly place index.html and the assets/ folder in the webroot. rsync -avz --delete --exclude '.env.local' dist/ "/var/www/flyer-crawler.projectium.com" - echo "Local deployment complete." \ No newline at end of file + echo "Application deployment complete." + + - name: Install Backend Dependencies and Restart Server + run: | + echo "Installing production dependencies and restarting server..." + cd /var/www/flyer-crawler.projectium.com + npm install --omit=dev # Install only production dependencies + # Use pm2 to reload the application with zero downtime. + # This assumes you have a pm2 process named 'flyer-crawler-api' configured on your server. + # If not, you would use `pm2 start npm --name "flyer-crawler-api" -- run start` for the first time. + pm2 reload flyer-crawler-api + echo "Backend server reloaded successfully." \ No newline at end of file diff --git a/package.json b/package.json index a86110cb..1b9ceb30 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "type": "module", "scripts": { "dev": "concurrently \"npm:start:server:dev\" \"vite\"", - "build": "DEBUG=\"tailwindcss:*\" vite build --debug", + "start": "tsx --env-file .env server.ts", + "build": "vite build", "preview": "vite preview", "test": "vitest run --coverage", "test:integration": "vitest run -c vitest.config.integration.ts", diff --git a/src/tests/setup/integration-global-setup.ts b/src/tests/setup/integration-global-setup.ts index 2b17a68a..d7f39258 100644 --- a/src/tests/setup/integration-global-setup.ts +++ b/src/tests/setup/integration-global-setup.ts @@ -70,8 +70,11 @@ export async function teardown() { console.log('✅ Backend server process terminated.'); } if (pool) { - // Check if the pool was actually initialized before trying to end it. - if ((pool as any)._connected) await pool.end(); + // Check if the pool has any clients (total, idle, or waiting) before ending it. + // This is a safer, type-approved way to see if the pool was used, avoiding `any`. + if (pool.totalCount > 0 || pool.idleCount > 0 || pool.waitingCount > 0) { + await pool.end(); + } console.log('✅ Global database pool teardown complete.'); } } \ No newline at end of file