From 897ab1ff77f9e314c6f10f7a41273f9fe300ffbd Mon Sep 17 00:00:00 2001 From: knuthtimo-lab Date: Mon, 12 Jan 2026 14:03:48 +0100 Subject: [PATCH] Final cleanup and documentation updates --- DOCKER_SYNC_GUIDE.md | 52 +-- FINAL_SUMMARY.md | 146 ++++---- bizmatch-server/prod.dump | Bin bizmatch/Dockerfile | 26 +- bizmatch/docker-compose.yml | 20 +- .../my-listing/my-listing.component.html | 344 +++++++++--------- bizmatch/src/environments/environment.dev.ts | 14 +- debug-inarray.ts | 118 +++--- fix-vulnerabilities.sh | 0 9 files changed, 360 insertions(+), 360 deletions(-) mode change 100644 => 100755 bizmatch-server/prod.dump mode change 100644 => 100755 fix-vulnerabilities.sh diff --git a/DOCKER_SYNC_GUIDE.md b/DOCKER_SYNC_GUIDE.md index e688d5b..a559fa5 100644 --- a/DOCKER_SYNC_GUIDE.md +++ b/DOCKER_SYNC_GUIDE.md @@ -1,27 +1,27 @@ -# Docker Code Sync Guide - -If you have made changes to the backend code and they don't seem to take effect (even though the files on disk are updated), it's because the Docker container is running from a pre-compiled `dist/` directory. - -### The Problem -The `bizmatch-app` container compiles the TypeScript code *only once* when the container starts. It does not automatically watch for changes and recompile while running. - -### The Solution -You must restart or recreate the container to trigger a new build. - -**Option 1: Quick Restart (Recommended)** -Run this in the `bizmatch-server` directory: -```bash -docker-compose restart app -``` - -**Option 2: Force Rebuild (If changes aren't picked up)** -If a simple restart doesn't work, use this to force a fresh build: -```bash -docker-compose up -d --build app -``` - -### Summary for Other Laptops -1. **Pull** the latest changes from Git. -2. **Execute** `docker-compose restart app`. -3. **Verify** the logs for the new `WARN` debug messages. +# Docker Code Sync Guide + +If you have made changes to the backend code and they don't seem to take effect (even though the files on disk are updated), it's because the Docker container is running from a pre-compiled `dist/` directory. + +### The Problem +The `bizmatch-app` container compiles the TypeScript code *only once* when the container starts. It does not automatically watch for changes and recompile while running. + +### The Solution +You must restart or recreate the container to trigger a new build. + +**Option 1: Quick Restart (Recommended)** +Run this in the `bizmatch-server` directory: +```bash +docker-compose restart app +``` + +**Option 2: Force Rebuild (If changes aren't picked up)** +If a simple restart doesn't work, use this to force a fresh build: +```bash +docker-compose up -d --build app +``` + +### Summary for Other Laptops +1. **Pull** the latest changes from Git. +2. **Execute** `docker-compose restart app`. +3. **Verify** the logs for the new `WARN` debug messages. . \ No newline at end of file diff --git a/FINAL_SUMMARY.md b/FINAL_SUMMARY.md index 339f8d9..321ae81 100644 --- a/FINAL_SUMMARY.md +++ b/FINAL_SUMMARY.md @@ -1,73 +1,73 @@ -# Final Project Summary & Deployment Guide - -## Recent Changes (Last 3 Git Pushes) - -Here is a summary of the most recent activity on the repository: - -1. **`e3e726d`** - Timo, 3 minutes ago - * **Message**: `feat: Initialize BizMatch application with core UI components, routing, listing pages, backend services, migration scripts, and vulnerability management.` - * **Impact**: Major initialization of the application structure, including core features and security baselines. - -2. **`e32e43d`** - Timo, 10 hours ago - * **Message**: `docs: Add comprehensive deployment guide for BizMatch project.` - * **Impact**: Added documentation for deployment procedures. - -3. **`b52e47b`** - Timo, 10 hours ago - * **Message**: `feat: Initialize Angular SSR application with core pages, components, and server setup.` - * **Impact**: Initial naming and setup of the Angular SSR environment. - ---- - -## Deployment Instructions - -### 1. Prerequisites -* **Node.js**: Version **20.x** or higher is recommended. -* **Package Manager**: `npm`. - -### 2. Building for Production (SSR) -The application is configured for **Angular SSR (Server-Side Rendering)**. You must build the application specifically for this mode. - -**Steps:** -1. Navigate to the project directory: - ```bash - cd bizmatch - ``` -2. Install dependencies: - ```bash - npm install - ``` -3. Build the project: - ```bash - npm run build:ssr - ``` - * This command executes `node version.js` (to update build versions) and then `ng build --configuration prod`. - * Output will be generated in `dist/bizmatch/browser` and `dist/bizmatch/server`. - -### 3. Running the Application -To start the production server: - -```bash -npm run serve:ssr -``` -* **Entry Point**: `dist/bizmatch/server/server.mjs` -* **Port**: The server listens on `process.env.PORT` or defaults to **4200**. - -### 4. Critical Deployment Checks (SSR & Polyfills) -**⚠️ IMPORTANT:** -The application uses a custom **DOM Polyfill** to support third-party libraries that might rely on browser-specific objects (like `window`, `document`) during server-side rendering. - -* **Polyfill Location**: `src/ssr-dom-polyfill.ts` -* **Server Verification**: Open `server.ts` and ensure the polyfill is imported **BEFORE** any other imports: - ```typescript - // IMPORTANT: DOM polyfill must be imported FIRST - import './src/ssr-dom-polyfill'; - ``` -* **Why is this important?** - If this import is removed or moved down, you may encounter `ReferenceError: window is not defined` or `document is not defined` errors when the server tries to render pages containing Leaflet maps or other browser-only libraries. - -### 5. Environment Variables & Security -* Ensure all necessary environment variables (e.g., Database URLs, API Keys) are configured in your deployment environment. -* Since `server.ts` is an Express app, you can extend it to handle specialized headers or proxy configurations if needed. - -### 6. Vulnerability Status -* Please refer to `FINAL_VULNERABILITY_STATUS.md` for the most recent security audit and known issues. +# Final Project Summary & Deployment Guide + +## Recent Changes (Last 3 Git Pushes) + +Here is a summary of the most recent activity on the repository: + +1. **`e3e726d`** - Timo, 3 minutes ago + * **Message**: `feat: Initialize BizMatch application with core UI components, routing, listing pages, backend services, migration scripts, and vulnerability management.` + * **Impact**: Major initialization of the application structure, including core features and security baselines. + +2. **`e32e43d`** - Timo, 10 hours ago + * **Message**: `docs: Add comprehensive deployment guide for BizMatch project.` + * **Impact**: Added documentation for deployment procedures. + +3. **`b52e47b`** - Timo, 10 hours ago + * **Message**: `feat: Initialize Angular SSR application with core pages, components, and server setup.` + * **Impact**: Initial naming and setup of the Angular SSR environment. + +--- + +## Deployment Instructions + +### 1. Prerequisites +* **Node.js**: Version **20.x** or higher is recommended. +* **Package Manager**: `npm`. + +### 2. Building for Production (SSR) +The application is configured for **Angular SSR (Server-Side Rendering)**. You must build the application specifically for this mode. + +**Steps:** +1. Navigate to the project directory: + ```bash + cd bizmatch + ``` +2. Install dependencies: + ```bash + npm install + ``` +3. Build the project: + ```bash + npm run build:ssr + ``` + * This command executes `node version.js` (to update build versions) and then `ng build --configuration prod`. + * Output will be generated in `dist/bizmatch/browser` and `dist/bizmatch/server`. + +### 3. Running the Application +To start the production server: + +```bash +npm run serve:ssr +``` +* **Entry Point**: `dist/bizmatch/server/server.mjs` +* **Port**: The server listens on `process.env.PORT` or defaults to **4200**. + +### 4. Critical Deployment Checks (SSR & Polyfills) +**⚠️ IMPORTANT:** +The application uses a custom **DOM Polyfill** to support third-party libraries that might rely on browser-specific objects (like `window`, `document`) during server-side rendering. + +* **Polyfill Location**: `src/ssr-dom-polyfill.ts` +* **Server Verification**: Open `server.ts` and ensure the polyfill is imported **BEFORE** any other imports: + ```typescript + // IMPORTANT: DOM polyfill must be imported FIRST + import './src/ssr-dom-polyfill'; + ``` +* **Why is this important?** + If this import is removed or moved down, you may encounter `ReferenceError: window is not defined` or `document is not defined` errors when the server tries to render pages containing Leaflet maps or other browser-only libraries. + +### 5. Environment Variables & Security +* Ensure all necessary environment variables (e.g., Database URLs, API Keys) are configured in your deployment environment. +* Since `server.ts` is an Express app, you can extend it to handle specialized headers or proxy configurations if needed. + +### 6. Vulnerability Status +* Please refer to `FINAL_VULNERABILITY_STATUS.md` for the most recent security audit and known issues. diff --git a/bizmatch-server/prod.dump b/bizmatch-server/prod.dump old mode 100644 new mode 100755 diff --git a/bizmatch/Dockerfile b/bizmatch/Dockerfile index 8515709..70d106c 100644 --- a/bizmatch/Dockerfile +++ b/bizmatch/Dockerfile @@ -1,13 +1,13 @@ -FROM node:22-alpine - -WORKDIR /app - -# GANZEN dist-Ordner kopieren, nicht nur bizmatch -COPY dist ./dist -COPY package*.json ./ - -RUN npm ci --omit=dev - -EXPOSE 4200 - -CMD ["node", "dist/bizmatch/server/server.mjs"] +FROM node:22-alpine + +WORKDIR /app + +# GANZEN dist-Ordner kopieren, nicht nur bizmatch +COPY dist ./dist +COPY package*.json ./ + +RUN npm ci --omit=dev + +EXPOSE 4200 + +CMD ["node", "dist/bizmatch/server/server.mjs"] diff --git a/bizmatch/docker-compose.yml b/bizmatch/docker-compose.yml index 3b1a0a9..c216dfe 100644 --- a/bizmatch/docker-compose.yml +++ b/bizmatch/docker-compose.yml @@ -1,10 +1,10 @@ -services: - bizmatch-ssr: - build: . - image: bizmatch-ssr - container_name: bizmatch-ssr - restart: unless-stopped - ports: - - '4200:4200' - environment: - NODE_ENV: DEVELOPMENT +services: + bizmatch-ssr: + build: . + image: bizmatch-ssr + container_name: bizmatch-ssr + restart: unless-stopped + ports: + - '4200:4200' + environment: + NODE_ENV: DEVELOPMENT diff --git a/bizmatch/src/app/pages/subscription/my-listing/my-listing.component.html b/bizmatch/src/app/pages/subscription/my-listing/my-listing.component.html index c87276f..94ab119 100644 --- a/bizmatch/src/app/pages/subscription/my-listing/my-listing.component.html +++ b/bizmatch/src/app/pages/subscription/my-listing/my-listing.component.html @@ -1,172 +1,172 @@ -
-
-

My Listings

- - - - - -
- -
-
- - - - - -
-
- -
-

{{ listing.title }}

-

Category: {{ listing.listingsCategory === 'commercialProperty' ? 'Commercial Property' : 'Business' }}

-

Located in: {{ listing.location?.name ? listing.location.name : listing.location?.county }} - {{ listing.location?.state }}

-

Price: ${{ listing.price.toLocaleString() }}

-

Internal #: {{ listing.internalListingNumber ?? '—' }}

-
- Publication Status: - - {{ listing.draft ? 'Draft' : 'Published' }} - -
-
- @if(listing.listingsCategory==='business'){ - - } @if(listing.listingsCategory==='commercialProperty'){ - - } - -
-
-
-
-
- - +
+
+

My Listings

+ + + + + +
+ +
+
+ + + + + +
+
+ +
+

{{ listing.title }}

+

Category: {{ listing.listingsCategory === 'commercialProperty' ? 'Commercial Property' : 'Business' }}

+

Located in: {{ listing.location?.name ? listing.location.name : listing.location?.county }} - {{ listing.location?.state }}

+

Price: ${{ listing.price.toLocaleString() }}

+

Internal #: {{ listing.internalListingNumber ?? '—' }}

+
+ Publication Status: + + {{ listing.draft ? 'Draft' : 'Published' }} + +
+
+ @if(listing.listingsCategory==='business'){ + + } @if(listing.listingsCategory==='commercialProperty'){ + + } + +
+
+
+
+
+ + diff --git a/bizmatch/src/environments/environment.dev.ts b/bizmatch/src/environments/environment.dev.ts index f2991ad..9027caa 100644 --- a/bizmatch/src/environments/environment.dev.ts +++ b/bizmatch/src/environments/environment.dev.ts @@ -1,7 +1,7 @@ -import { environment_base } from './environment.base'; - -export const environment = environment_base; - -environment.apiBaseUrl = 'http://bizsearch.at-powan.ts.net:3001'; -environment.mailinfoUrl = 'http://bizsearch.at-powan.ts.net'; -environment.imageBaseUrl = 'http://bizsearch.at-powan.ts.net'; +import { environment_base } from './environment.base'; + +export const environment = environment_base; + +environment.apiBaseUrl = 'http://bizsearch.at-powan.ts.net:3001'; +environment.mailinfoUrl = 'http://bizsearch.at-powan.ts.net'; +environment.imageBaseUrl = 'http://bizsearch.at-powan.ts.net'; diff --git a/debug-inarray.ts b/debug-inarray.ts index 817393a..d086a02 100644 --- a/debug-inarray.ts +++ b/debug-inarray.ts @@ -1,59 +1,59 @@ - -import { and, inArray, sql, SQL } from 'drizzle-orm'; -import { businesses_json, users_json } from './bizmatch-server/src/drizzle/schema'; - -// Mock criteria similar to what the user used -const criteria: any = { - types: ['retail'], - brokerName: 'page', - criteriaType: 'businessListings' -}; - -const user = { role: 'guest', email: 'timo@example.com' }; - -function getWhereConditions(criteria: any, user: any): SQL[] { - const whereConditions: SQL[] = []; - - // Category filter - if (criteria.types && criteria.types.length > 0) { - // Suspected problematic line: - whereConditions.push(inArray(sql`${businesses_json.data}->>'type'`, criteria.types)); - } - - // Broker filter - if (criteria.brokerName) { - const firstname = criteria.brokerName; - const lastname = criteria.brokerName; - whereConditions.push( - sql`((${users_json.data}->>'firstname') ILIKE ${`%${firstname}%`} OR (${users_json.data}->>'lastname') ILIKE ${`%${lastname}%` bubble})` - ); - } - - // Draft check - if (user?.role !== 'admin') { - whereConditions.push( - sql`((${ businesses_json.email } = ${ user?.email || null}) OR(${ businesses_json.data } ->> 'draft')::boolean IS NOT TRUE)` - ); - } - - return whereConditions; -} - -const conditions = getWhereConditions(criteria, user); -const combined = and(...conditions); - -console.log('--- Conditions Count ---'); -console.log(conditions.length); - -console.log('--- Generated SQL Fragment ---'); -// We need a dummy query to see the full SQL -// Since we don't have a real DB connection here, we just inspect the SQL parts -// Drizzle conditions can be serialized to SQL strings -// This is a simplified test - -try { - // In a real environment we would use a dummy pg adapter - console.log('SQL serializing might require a full query context, but let\'s see what we can get.'); -} catch (e) { - console.error(e); -} + +import { and, inArray, sql, SQL } from 'drizzle-orm'; +import { businesses_json, users_json } from './bizmatch-server/src/drizzle/schema'; + +// Mock criteria similar to what the user used +const criteria: any = { + types: ['retail'], + brokerName: 'page', + criteriaType: 'businessListings' +}; + +const user = { role: 'guest', email: 'timo@example.com' }; + +function getWhereConditions(criteria: any, user: any): SQL[] { + const whereConditions: SQL[] = []; + + // Category filter + if (criteria.types && criteria.types.length > 0) { + // Suspected problematic line: + whereConditions.push(inArray(sql`${businesses_json.data}->>'type'`, criteria.types)); + } + + // Broker filter + if (criteria.brokerName) { + const firstname = criteria.brokerName; + const lastname = criteria.brokerName; + whereConditions.push( + sql`((${users_json.data}->>'firstname') ILIKE ${`%${firstname}%`} OR (${users_json.data}->>'lastname') ILIKE ${`%${lastname}%` bubble})` + ); + } + + // Draft check + if (user?.role !== 'admin') { + whereConditions.push( + sql`((${ businesses_json.email } = ${ user?.email || null}) OR(${ businesses_json.data } ->> 'draft')::boolean IS NOT TRUE)` + ); + } + + return whereConditions; +} + +const conditions = getWhereConditions(criteria, user); +const combined = and(...conditions); + +console.log('--- Conditions Count ---'); +console.log(conditions.length); + +console.log('--- Generated SQL Fragment ---'); +// We need a dummy query to see the full SQL +// Since we don't have a real DB connection here, we just inspect the SQL parts +// Drizzle conditions can be serialized to SQL strings +// This is a simplified test + +try { + // In a real environment we would use a dummy pg adapter + console.log('SQL serializing might require a full query context, but let\'s see what we can get.'); +} catch (e) { + console.error(e); +} diff --git a/fix-vulnerabilities.sh b/fix-vulnerabilities.sh old mode 100644 new mode 100755