Compare commits

...

2 Commits

Author SHA1 Message Date
Andreas Knuth 995468fa30 asds 2025-11-09 16:17:44 -06:00
Andreas Knuth 6fa3bea614 git rm 2025-11-09 16:17:00 -06:00
27 changed files with 286 additions and 33784 deletions

View File

@ -1,17 +0,0 @@
# Editor configuration, see https://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 4
max_line_length = 180
insert_final_newline = true
trim_trailing_whitespace = true
[*.ts]
quote_type = single
[*.md]
max_line_length = off
trim_trailing_whitespace = false

4
crawler/.gitignore vendored
View File

@ -1,4 +0,0 @@
node_modules
*.js
*.map
package-lock.json

View File

@ -1,61 +0,0 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Crawler",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/index.js",
"outFiles": [
"${workspaceFolder}/**/*.js"
]
},
{
"type": "node",
"request": "launch",
"name": "ChangeUserId",
"skipFiles": [
"<node_internals>/**"
],
"args": ["--userId","e0811669-c7eb-4e5e-a699-e8334d5c5b01"],
"program": "${workspaceFolder}/changeUserId.js",
"outFiles": [
"${workspaceFolder}/**/*.js"
]
},
{
"type": "node",
"request": "launch",
"name": "postgres_business_import",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/build/crawler/postgres_business_import.js",
"outFiles": [
"${workspaceFolder}/**/*.js"
]
},
{
"type": "node",
"request": "launch",
"name": "generateTypes",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/generateTypes.js",
"outFiles": [
"${workspaceFolder}/**/*.js"
],
"args": [
"--sourcefile","schema.ts",
"--outfile", "model.ts",
],
},
]
}

View File

@ -1,14 +0,0 @@
export interface User {
id: string;
firstname: string;
lastname: string;
email: string;
phoneNumber?: string;
description?: string;
created_at: Date;
updated_at?: Date;
isActive: boolean;
score?: number;
balance?: number;
tags?: string[];
}

40
crawler/changeUserId.js Normal file
View File

@ -0,0 +1,40 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const yargs_1 = __importDefault(require("yargs"));
const helpers_1 = require("yargs/helpers");
const argv = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv)).argv;
if (!argv.userId) {
console.log(' --userId [any valid userId]');
process.exit(1);
}
(() => __awaiter(void 0, void 0, void 0, function* () {
console;
const response = yield fetch('http://localhost:3000/bizmatch/listings', {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
});
const listings = yield response.json();
for (const listing of listings) {
listing.userId = argv.userId;
listing.created = new Date();
listing.updated = new Date();
const response = yield fetch(`http://localhost:3000/bizmatch/listings/${listing.id}`, {
method: 'PUT',
body: JSON.stringify(listing),
headers: { 'Content-Type': 'application/json' },
});
}
}))();
//# sourceMappingURL=changeUserId.js.map

View File

@ -1,30 +0,0 @@
// import yargs from 'yargs'
// import fs from 'fs-extra';
// import { hideBin } from 'yargs/helpers'
// import { BusinessListing } from "../common-models/src/main.model"
// const argv = yargs(hideBin(process.argv)).argv
// if (!argv.userId){
// console.log(' --userId [any valid userId]')
// process.exit(1)
// }
// (async () => {
// console
// const response = await fetch('http://localhost:3000/bizmatch/listings', {
// method: 'GET',
// headers: { 'Content-Type': 'application/json' },
// })
// const listings:Array<BusinessListing> = await response.json();
// for (const listing of listings) {
// listing.userId=argv.userId;
// listing.created=new Date()
// listing.updated=new Date()
// const response = await fetch(`http://localhost:3000/bizmatch/listings/${listing.id}`, {
// method: 'PUT',
// body: JSON.stringify(listing),
// headers: { 'Content-Type': 'application/json' },
// });
// }
// })();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,192 +0,0 @@
[
{
"userId": "8a2b1c5d-7e6f-4g3h-9i1j-2k3l4m5n6o7p",
"listingsCategory": "business",
"title": "Gourmet Coffee Shop",
"description": "<h2>Community-Centric Café</h2><p>A beloved local coffee shop offering a wide variety of gourmet coffees, teas, and handmade pastries. Known for its cozy atmosphere and strong community ties. Ideal for someone passionate about coffee and community engagement.</p>",
"type": "2",
"state": "CA",
"city": "San Francisco",
"id": "02JRPQ2YPK7CMXS55XP9G8UIJ2",
"price": 220000,
"salesRevenue": 340000,
"temporary": false,
"leasedLocation": false,
"established": 2015,
"employees": 10,
"reasonForSale": "Retirement",
"supportAndTraining": "2 weeks of training provided.",
"cashFlow": 95000
},
{
"userId": "4q5r6s7t-8u9v-0w1x-2y3z-4a5b6c7d8e9f",
"listingsCategory": "business",
"title": "Organic Farm Supply",
"description": "<h2>Sustainable Agriculture</h2><p>Offering a range of products for organic farming, including seeds, tools, and fertilizers. Committed to promoting sustainable farming practices. A great opportunity for someone with a green thumb and a passion for sustainability.</p>",
"type": "3",
"state": "OR",
"city": "Portland",
"id": "03KRQQ3ZPL8DNYS66YQ1H9VJK3",
"price": 180000,
"salesRevenue": 260000,
"temporary": false,
"leasedLocation": true,
"established": 2017,
"employees": 6,
"reasonForSale": "Focusing on other ventures",
"supportAndTraining": "1 month of comprehensive training.",
"cashFlow": 78000
},
{
"userId": "3m4n5o6p-7q8r-9s0t-1u2v-3w4x5y6z7a8b",
"listingsCategory": "business",
"title": "Modern Italian Restaurant",
"description": "<h2>Authentic Italian Cuisine</h2><p>An upscale Italian restaurant known for its modern twist on traditional dishes. Features a full bar and an elegant dining room. A fantastic opportunity for a culinary entrepreneur or chef.</p>",
"type": "4",
"state": "NY",
"city": "New York",
"id": "04LRPP4AOQ9ENZT77ZR2I0WKL4",
"price": 450000,
"salesRevenue": 670000,
"temporary": false,
"leasedLocation": false,
"established": 2012,
"employees": 15,
"reasonForSale": "New business interests",
"supportAndTraining": "Owner willing to consult for 3 months.",
"cashFlow": 220000
},
{
"userId": "4q5r6s7t-8u9v-0w1x-2y3z-4a5b6c7d8e9f",
"listingsCategory": "business",
"title": "Boutique Clothing Store",
"description": "<h2>High-End Fashion</h2><p>A boutique store offering an exclusive selection of women's clothing and accessories from top designers. Located in a prime shopping district, it's known for its exceptional customer service and unique fashion finds.</p>",
"type": "5",
"state": "IL",
"city": "Chicago",
"id": "05MSQQ5BPRAFO1U88ZS3J1XML5",
"price": 310000,
"salesRevenue": 430000,
"temporary": false,
"leasedLocation": true,
"established": 2018,
"employees": 8,
"reasonForSale": "Personal reasons",
"supportAndTraining": "3 weeks of training and support.",
"cashFlow": 120000
},
{
"userId": "3m4n5o6p-7q8r-9s0t-1u2v-3w4x5y6z7a8b",
"listingsCategory": "business",
"title": "Tech Startup - Mobile Apps",
"description": "<h2>Innovative Technology Solutions</h2><p>A tech startup specializing in developing cutting-edge mobile applications for both iOS and Android. With several successful apps already in the market, this is an exciting opportunity for tech enthusiasts or investors.</p>",
"type": "6",
"state": "WA",
"city": "Seattle",
"id": "06NTQR6CQSBGP2V99AT4K2YNM6",
"price": 500000,
"salesRevenue": 800000,
"temporary": false,
"leasedLocation": false,
"established": 2020,
"employees": 20,
"reasonForSale": "Seeking new challenges",
"supportAndTraining": "Technical and business support for 1 month.",
"cashFlow": 300000
},
{
"userId": "8a2b1c5d-7e6f-4g3h-9i1j-2k3l4m5n6o7p",
"listingsCategory": "business",
"title": "Eco-Friendly Cleaning Service",
"description": "<h2>Green Home and Office Cleaning</h2><p>A fast-growing cleaning service that uses eco-friendly products. Offers home and office cleaning with a focus on sustainability and environmentally friendly practices. A perfect venture for those passionate about the environment.</p>",
"type": "7",
"state": "CO",
"city": "Denver",
"id": "07OUQR7DRTCGQ3WAAAU5L3ZON7",
"price": 90000,
"salesRevenue": 150000,
"temporary": false,
"leasedLocation": true,
"established": 2021,
"employees": 12,
"reasonForSale": "Expanding to new markets",
"supportAndTraining": "Comprehensive eco-friendly cleaning training.",
"cashFlow": 65000
},
{
"userId": "3m4n5o6p-7q8r-9s0t-1u2v-3w4x5y6z7a8b",
"listingsCategory": "business",
"title": "Independent Bookstore",
"description": "<h2>A Haven for Book Lovers</h2><p>An independent bookstore with a strong community presence, offering a wide range of books, from bestsellers to local authors. Includes a cozy café space for readers to relax and enjoy their books.</p>",
"type": "8",
"state": "MA",
"city": "Boston",
"id": "08PVRS8ESUDHR4XBBBV6M4APO8",
"price": 130000,
"salesRevenue": 210000,
"temporary": false,
"leasedLocation": false,
"established": 2016,
"employees": 5,
"reasonForSale": "Owner relocating",
"supportAndTraining": "Training on operations and inventory management.",
"cashFlow": 70000
},
{
"userId": "7w8x9y0z-1a2b-3c4d-5e6f-7g8h9i0j1k2l",
"listingsCategory": "business",
"title": "Luxury Spa and Wellness Center",
"description": "<h2>Ultimate Relaxation and Wellness</h2><p>A luxury spa offering a comprehensive range of services, including massages, facials, and wellness programs. Situated in a tranquil and upscale area, it's the perfect retreat for health and wellness enthusiasts.</p>",
"type": "9",
"state": "FL",
"city": "Miami",
"id": "09QWTR9FTVEIS5YCCDW7N5BQP9",
"price": 350000,
"salesRevenue": 520000,
"temporary": false,
"leasedLocation": true,
"established": 2014,
"employees": 18,
"reasonForSale": "Pursuing other interests",
"supportAndTraining": "Owner available for a smooth transition over 2 months.",
"cashFlow": 190000
},
{
"userId": "1g2h3i4j-5k6l-7m8n-9o0p-1q2r3s4t5u6v",
"listingsCategory": "business",
"title": "Custom Jewelry Shop",
"description": "<h2>Exquisite Handcrafted Jewelry</h2><p>A shop specializing in custom-made jewelry, from engagement rings to unique pieces for special occasions. Utilizes high-quality materials and offers a personalized design service.</p>",
"type": "10",
"state": "NV",
"city": "Las Vegas",
"id": "10RXUS0GUWFJT6ZDDDX8O6CQR0",
"price": 275000,
"salesRevenue": 400000,
"temporary": false,
"leasedLocation": false,
"established": 2018,
"employees": 4,
"reasonForSale": "Health reasons",
"supportAndTraining": "Design and crafting training provided.",
"cashFlow": 110000
},
{
"userId": "4q5r6s7t-8u9v-0w1x-2y3z-4a5b6c7d8e9f",
"listingsCategory": "business",
"title": "Digital Marketing Agency",
"description": "<h2>Online Branding and Marketing Solutions</h2><p>A full-service digital marketing agency offering SEO, PPC, social media marketing, and web design services. Known for its innovative strategies and results-driven approach. Ideal for those with a background in marketing or business.</p>",
"type": "11",
"state": "TX",
"city": "Dallas",
"id": "11SYVT1HVXGKU7AEEEX9P7DRR1",
"price": 400000,
"salesRevenue": 600000,
"temporary": false,
"leasedLocation": true,
"established": 2019,
"employees": 25,
"reasonForSale": "Scaling down",
"supportAndTraining": "4 weeks of digital marketing training.",
"cashFlow": 250000
}
]

File diff suppressed because it is too large Load Diff

View File

@ -1,142 +0,0 @@
[
{
"id": "2b5c900f-894d-5e48-c987-8cf735170b5f",
"temporary": false,
"userId": "",
"listingsCategory": "commercialProperty",
"title": "Downtown Retail Space",
"state": "NY",
"hasImages": true,
"price": 3200000,
"city": "New York",
"description": "<p>Prime retail space in the heart of New York City. An excellent opportunity for investors to own a piece of the vibrant downtown shopping district. High foot traffic and visibility make this an ideal location for any retail business.</p>",
"type": "100",
"imageOrder": []
},
{
"id": "3c6d901g-905e-6f59-d098-9dg846280c6g",
"temporary": false,
"userId": "",
"listingsCategory": "commercialProperty",
"title": "Expansive Land Development Opportunity",
"state": "CA",
"hasImages": true,
"price": 5000000,
"city": "Los Angeles",
"description": "<p>Offering a unique opportunity to purchase vast acreage in Los Angeles. Perfect for developers looking to create a new residential community or commercial complex. Accessibility to major highways and urban centers.</p>",
"type": "101",
"imageOrder": []
},
{
"id": "4d7ea012-h16f-7g6a-e109-feh957390d7h",
"temporary": false,
"userId": "",
"listingsCategory": "commercialProperty",
"title": "Industrial Warehouse Complex",
"state": "IL",
"hasImages": true,
"price": 7500000,
"city": "Chicago",
"description": "<p>A modern industrial warehouse complex suitable for manufacturing or distribution businesses. Features multiple loading docks, office spaces, and state-of-the-art facilities. Strategically located for easy transport access.</p>",
"type": "102",
"imageOrder": []
},
{
"id": "5e8fb123-i27g-8h7b-f210-gfi0684a1e8i",
"temporary": false,
"userId": "",
"listingsCategory": "commercialProperty",
"title": "Luxury Office Building",
"state": "TX",
"hasImages": true,
"price": 8900000,
"city": "Houston",
"description": "<p>An architectural masterpiece, this luxury office building offers state-of-the-art amenities, including a fitness center, conference rooms, and rooftop gardens. Ideal for businesses looking for a prestigious address.</p>",
"type": "103",
"imageOrder": []
},
{
"id": "6f9gc234-j38h-9i8c-g311-hgj1795b2f9j",
"temporary": false,
"userId": "",
"listingsCategory": "commercialProperty",
"title": "Mixed-Use Building Downtown",
"state": "FL",
"hasImages": true,
"price": 4200000,
"city": "Miami",
"description": "<p>A prominent mixed-use building featuring retail spaces on the ground floor and modern apartments above. Located in the bustling downtown area, it offers a perfect blend of commercial and residential opportunities.</p>",
"type": "104",
"imageOrder": []
},
{
"id": "7hagd345-k49i-aj9d-h422-ikj2806c3gak",
"temporary": false,
"userId": "",
"listingsCategory": "commercialProperty",
"title": "Multifamily Residential Complex",
"state": "WA",
"hasImages": true,
"price": 6700000,
"city": "Seattle",
"description": "<p>This modern multifamily complex features a variety of amenities including a gym, pool, and community center. Offering a mix of one, two, and three-bedroom units, it's a perfect investment for steady rental income.</p>",
"type": "105",
"imageOrder": []
},
{
"id": "8ibhe456-l5aj-bk0e-i533-jkl3917d4hab",
"temporary": false,
"userId": "",
"listingsCategory": "commercialProperty",
"title": "Versatile Commercial Property",
"state": "CO",
"hasImages": true,
"price": 3900000,
"city": "Denver",
"description": "<p>A versatile commercial property that can accommodate various business types, from retail to offices. Located in a high-traffic area, it offers great visibility and accessibility. Ample parking and flexible space configurations available.</p>",
"type": "106",
"imageOrder": []
},
{
"id": "9jcfi567-m6bk-cl1f-j644-kml4028e5icm",
"temporary": false,
"userId": "",
"listingsCategory": "commercialProperty",
"title": "Premier Shopping Center",
"state": "AZ",
"hasImages": true,
"price": 12000000,
"city": "Phoenix",
"description": "<p>A leading shopping center with a mix of national and local retailers, restaurants, and entertainment options. High annual foot traffic and a loyal customer base make this a highly desirable investment.</p>",
"type": "100",
"imageOrder": []
},
{
"id": "akdjh678-n7cl-dm2g-k755-lnm5139f6jdn",
"temporary": false,
"userId": "",
"listingsCategory": "commercialProperty",
"title": "Expansive Industrial Park",
"state": "NV",
"hasImages": true,
"price": 15000000,
"city": "Las Vegas",
"description": "<p>An expansive industrial park offering a range of facilities for light manufacturing, warehousing, and logistics. Includes customizable units, ample parking, and is strategically located for easy access to major transport routes.</p>",
"type": "102",
"imageOrder": []
},
{
"id": "blemj789-o8dm-en3h-l866-mno6240g7keo",
"temporary": false,
"userId": "",
"listingsCategory": "commercialProperty",
"title": "High-End Office Suites",
"state": "GA",
"hasImages": true,
"price": 5300000,
"city": "Atlanta",
"description": "<p>Elegant and modern office suites in a prestigious part of Atlanta. Offers businesses a high-profile location with top-notch amenities, including secure parking, high-speed internet, and on-site management.</p>",
"type": "103",
"imageOrder": []
}
]

View File

@ -1,156 +0,0 @@
[
{
"id": "8a2b1c5d-7e6f-4g3h-9i1j-2k3l4m5n6o7p",
"firstname": "Sarah",
"lastname": "Thompson",
"email": "sarah.thompson@businessbrokers.com",
"licensedIn": [
{
"name": "California",
"value": "123456"
},
{
"name": "Nevada",
"value": "789012"
}
],
"phoneNumber": "(310) 555-1234",
"companyLocation": "Los Angeles - CA",
"hasCompanyLogo": true,
"hasProfile": true,
"companyName": "Business Brokers Inc.",
"companyWebsite": "https://www.businessbrokers.com",
"description": "Experienced business brokers helping clients buy and sell businesses in California and Nevada.",
"companyOverview": "<p>Business Brokers Inc. is a team of experienced professionals dedicated to helping clients navigate the complex process of buying and selling businesses. With a strong focus on client satisfaction and a deep understanding of the local markets in California and Nevada, we strive to deliver exceptional results for our clients.</p>",
"areasServed": [
"Los Angeles County, CA",
"Orange County, CA",
"San Diego County, CA",
"Clark County, NV",
"Washoe County, NV"
],
"offeredServices": "<h2>Services Offered</h2><ul><li>Business valuation</li><li>Market analysis</li><li>Buyer and seller representation</li><li>Due diligence assistance</li><li>Negotiations and closing support</li></ul>"
},
{
"id": "4q5r6s7t-8u9v-0w1x-2y3z-4a5b6c7d8e9f",
"firstname": "Michael",
"lastname": "Johnson",
"email": "michael@bizbrokers.net",
"licensedIn": [
{
"name": "Florida",
"value": "654321"
}
],
"phoneNumber": "(407) 555-9876",
"companyLocation": "Orlando - FL",
"hasCompanyLogo": false,
"hasProfile": true,
"companyName": "BizBrokers",
"companyWebsite": "https://www.bizbrokers.net",
"description": "Helping business owners in Florida sell their businesses and assisting buyers in finding the perfect opportunity.",
"companyOverview": "<p>At BizBrokers, we understand the unique challenges of buying and selling businesses in the Florida market. Our team of experienced brokers is committed to providing personalized service and expert guidance to ensure a smooth and successful transaction for our clients.</p>",
"areasServed": [
"Orange County, FL",
"Seminole County, FL",
"Osceola County, FL",
"Brevard County, FL",
"Volusia County, FL"
],
"offeredServices": "<h2>Services Offered</h2><ul><li>Business listings</li><li>Buyer search and qualification</li><li>Due diligence support</li><li>Financing assistance</li><li>Closing coordination</li></ul>"
},
{
"id": "1g2h3i4j-5k6l-7m8n-9o0p-1q2r3s4t5u6v",
"firstname": "Emily",
"lastname": "Davis",
"email": "emily.davis@bizsaleexperts.com",
"licensedIn": [
{
"name": "New York",
"value": "987654"
},
{
"name": "New Jersey",
"value": "210987"
}
],
"phoneNumber": "(212) 555-4321",
"companyLocation": "New York City - NY",
"hasCompanyLogo": true,
"hasProfile": true,
"companyName": "Business Sale Experts",
"companyWebsite": "https://www.bizsaleexperts.com",
"description": "Experienced business brokers specializing in the sale of businesses in the New York and New Jersey area.",
"companyOverview": "<p>Business Sale Experts is a leading business brokerage firm serving the New York and New Jersey markets. With a team of seasoned professionals and a proven track record of success, we are dedicated to helping our clients achieve their goals in the sale or acquisition of businesses.</p>",
"areasServed": [
"New York County, NY",
"Kings County, NY",
"Queens County, NY",
"Bronx County, NY",
"Hudson County, NJ",
"Bergen County, NJ",
"Essex County, NJ"
],
"offeredServices": "<h2>Services Offered</h2><ul><li>Business valuation</li><li>Marketing and advertising</li><li>Buyer screening and qualification</li><li>Negotiations and deal structuring</li><li>Due diligence coordination</li><li>Closing support</li></ul>"
},
{
"id": "7w8x9y0z-1a2b-3c4d-5e6f-7g8h9i0j1k2l",
"firstname": "David",
"lastname": "Wilson",
"email": "david.wilson@bizacquisitions.com",
"licensedIn": [
{
"name": "Texas",
"value": "543210"
}
],
"phoneNumber": "(713) 555-8765",
"companyLocation": "Houston - TX",
"hasCompanyLogo": true,
"hasProfile": true,
"companyName": "Business Acquisitions Ltd.",
"companyWebsite": "https://www.bizacquisitions.com",
"description": "Helping business owners in Texas sell their businesses and assisting buyers in finding the perfect acquisition opportunity.",
"companyOverview": "<p>Business Acquisitions Ltd. is a leading business brokerage firm serving the Texas market. Our team of experienced brokers is dedicated to providing expert guidance and personalized service to help our clients achieve their goals in the sale or acquisition of businesses.</p>",
"areasServed": [
"Harris County, TX",
"Dallas County, TX",
"Tarrant County, TX",
"Bexar County, TX",
"Travis County, TX"
],
"offeredServices": "<h2>Services Offered</h2><ul><li>Business valuation</li><li>Market analysis</li><li>Buyer search and qualification</li><li>Due diligence coordination</li><li>Financing assistance</li><li>Closing support</li></ul>"
},
{
"id": "3m4n5o6p-7q8r-9s0t-1u2v-3w4x5y6z7a8b",
"firstname": "Jessica",
"lastname": "Brown",
"email": "jessica@bizbrokerexperts.com",
"licensedIn": [
{
"name": "Illinois",
"value": "876543"
},
{
"name": "Wisconsin",
"value": "109876"
}
],
"phoneNumber": "(312) 555-2109",
"companyLocation": "Chicago - IL",
"hasCompanyLogo": true,
"hasProfile": true,
"companyName": "Business Broker Experts",
"companyWebsite": "https://www.bizbrokerexperts.com",
"description": "Experienced business brokers helping clients buy and sell businesses in Illinois and Wisconsin.",
"companyOverview": "<p>Business Broker Experts is a leading business brokerage firm serving the Illinois and Wisconsin markets. With a team of seasoned professionals and a commitment to client satisfaction, we strive to deliver exceptional results for our clients in the sale or acquisition of businesses.</p>",
"areasServed": [
"Cook County, IL",
"DuPage County, IL",
"Lake County, IL",
"Milwaukee County, WI",
"Dane County, WI"
],
"offeredServices": "<h2>Services Offered</h2><ul><li>Business valuation</li><li>Market analysis</li><li>Buyer and seller representation</li><li>Due diligence assistance</li><li>Negotiations and closing support</li></ul>"
}
]

View File

@ -1,193 +0,0 @@
import fs from 'fs-extra';
import path from 'path';
// import { prompt, Question} from 'inquirer';
import inquirer from 'inquirer';
import chalk from 'chalk';
const COMPLETED = 'SELECTION_COMPLETED';
const CANCELLED = 'SELECTION_CANCELLED';
const CHECKMARK = '\u2713';
class FilesSystemService {
directories(directoryPath, directoryFilter ?: (joinedPath) => true) {
return fs.readdirSync(directoryPath).filter((name) => {
const joinedPath = path.join(directoryPath, name);
return this.isDirectory(joinedPath) && directoryFilter(joinedPath);
});
}
files(directoryPath, fileFilter = (joinedPath) => true) {
return fs.readdirSync(directoryPath).filter((name) => {
const joinedPath = path.join(directoryPath, name);
return this.isFile(joinedPath) && fileFilter(joinedPath);
});
}
isDirectory(directoryPath) {
return fs.statSync(directoryPath).isDirectory();
}
isFile(filePath) {
return fs.statSync(filePath).isFile();
}
}
class FilesSelectionService extends Set {
lastFileSelected = null;
constructor(selectedFiles) {
super(selectedFiles);
}
get selectedFiles() {
return Array.from(this);
}
isSelected(file) {
return this.has(file);
}
selectFile(file) {
this.add(file);
this.lastFileSelected = file;
}
removeFile(file) {
this.delete(file);
}
}
class LocationService {
constructor(public currentPath) {
this.currentPath = currentPath;
}
}
class OptionsService {
constructor(public options) {
this.options = { ...this.defaultOptions, ...options };
}
get defaultOptions() {
return {
directoryFilter: () => true,
fileFilter: () => true,
root: process.cwd(),
startingPath: process.cwd(),
multi: true,
pageSize: 10,
selectedFiles: [],
clearConsole: true,
};
}
}
export const selectFiles = function (options = {}) {
const optionsService = new OptionsService(options);
const locationService = new LocationService(
optionsService.options.startingPath
);
const fileSystemService = new FilesSystemService();
const filesSelectionService = new FilesSelectionService(
optionsService.options.selectedFiles
);
return new Promise((resolve):FCResult|void => {
(async function promptUserToSelectFiles() {
const directories = fileSystemService.directories(
locationService.currentPath,
optionsService.options.directoryFilter
);
if (locationService.currentPath !== optionsService.options.root) {
directories.unshift('..');
}
const files = fileSystemService.files(
locationService.currentPath,
optionsService.options.fileFilter
);
const choices = [
...directories.map((directoryName) => {
const value = path.join(locationService.currentPath, directoryName);
const name = chalk.yellow(directoryName);
return { value, name };
}),
...files.map((fileName) => {
const value = path.join(locationService.currentPath, fileName);
const name = `${fileName} ${
filesSelectionService.isSelected(value)
? chalk.green(CHECKMARK)
: ''
}`;
return { value, name };
}),
];
if (filesSelectionService.selectedFiles.length) {
choices.push({
name: chalk.green('-- File Selection Complete --'),
value: COMPLETED,
});
}
choices.push({
name: chalk.red('-- Cancel File Selection --'),
value: CANCELLED,
});
if (optionsService.options.clearConsole) {
console.clear();
}
const { selection } = await inquirer.prompt([
{
type: 'list',
message: `Select file(s) in ${locationService.currentPath}`,
name: 'selection',
pageSize: optionsService.options.pageSize,
choices,
default: () => filesSelectionService.lastFileSelected,
},
]);
if (optionsService.options.clearConsole) {
console.clear();
}
if (selection === COMPLETED || selection === CANCELLED) {
return resolve({
selectedFiles: filesSelectionService.selectedFiles,
status: selection,
});
} else if (!optionsService.options.multi) {
return resolve({
selectedFiles: [selection],
status: COMPLETED,
});
}
if (fileSystemService.isDirectory(selection)) {
locationService.currentPath = selection;
} else {
if (filesSelectionService.isSelected(selection)) {
filesSelectionService.removeFile(selection);
} else {
filesSelectionService.selectFile(selection);
}
}
promptUserToSelectFiles();
})();
});
};
export type FCResult = {
selectedFiles:Array<string>
status:'SELECTION_COMPLETED'|'SELECTION_CANCELLED'
}
// const exports = {
// COMPLETED,
// CANCELLED,
// selectFiles,
// };

27
crawler/import.js Normal file
View File

@ -0,0 +1,27 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_extra_1 = __importDefault(require("fs-extra"));
(() => __awaiter(void 0, void 0, void 0, function* () {
const listings = yield fs_extra_1.default.readJson('./listings.json');
//listings.forEach(element => {
for (const listing of listings) {
const response = yield fetch('http://localhost:3000/bizmatch/listings', {
method: 'POST',
body: JSON.stringify(listing),
headers: { 'Content-Type': 'application/json' },
});
}
}))();
//# sourceMappingURL=import.js.map

View File

@ -1,37 +0,0 @@
import yargs from 'yargs'
import { hideBin } from 'yargs/helpers'
import fs from 'fs-extra';
import { selectFiles } from './filechooser.js';
import path from 'path';
const argv = yargs(hideBin(process.argv)).argv
(async () => {
const result = await selectFiles({startingPath:'./data',directoryFilter: (directoryName)=>{
return false;
},fileFilter: (fileName) => {
return /\.json$/gi.test(fileName);
},pageSize:10,multi:false});
if (argv.delete){ // delete==business or commercialProperty
const ids = await fetch(`http://localhost:3000/bizmatch/listings/undefined/repo/${argv.delete}`,{
method: 'GET',
headers: { 'Content-Type': 'application/json' },
})
await fetch(`http://localhost:3000/bizmatch/listings/undefined/repo/${argv.delete}`,{
method: 'DELETE',
headers: { 'Content-Type': 'application/json' },
})
}
console.log(result['selectedFiles'][0]);
const file = result['selectedFiles'][0];
const listings = await fs.readJson(file);
for (const listing of listings) {
const type = listing.listingsCategory
const response = await fetch(`http://localhost:3000/bizmatch/listings/${type}`, {
method: 'POST',
body: JSON.stringify(listing),
headers: { 'Content-Type': 'application/json' },
});
}
})();

179
crawler/index.js Normal file
View File

@ -0,0 +1,179 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
// import puppeteer, { Browser, ElementHandle, Page } from 'puppeteer-core';
const puppeteer_1 = __importDefault(require("puppeteer"));
const currency_js_1 = __importDefault(require("currency.js"));
const fs_extra_1 = __importDefault(require("fs-extra"));
const typesOfBusiness = [
{ name: 'Automotive', value: '1' },
{ name: 'Industrial Services', value: '2' },
{ name: 'Real Estate', value: '3' },
{ name: 'Uncategorized', value: '4' },
{ name: 'Retail', value: '5' },
{ name: 'Oilfield SVE and MFG.', value: '6' },
{ name: 'Service', value: '7' },
{ name: 'Advertising', value: '8' },
{ name: 'Agriculture', value: '9' },
{ name: 'Franchise', value: '10' },
{ name: 'Professional', value: '11' },
{ name: 'Manufacturing', value: '12' },
{ name: 'Food and Restaurant', value: '13' },
];
function getParentElementText(elementHandle) {
return __awaiter(this, void 0, void 0, function* () {
const textContent = elementHandle
? yield elementHandle.evaluate((el) => {
const getText = (nodes) => {
const result = [];
//debugger;
for (const node of nodes) {
if (node.nodeType === Node.TEXT_NODE && node.nodeValue !== "\n") {
result.push(node.nodeValue.replace('\n', ''));
}
}
return result;
};
const parent = el.parentElement;
if (!parent)
return null;
let text = '';
const preResult = Array.from(parent.childNodes).find((e) => e.nodeName === 'PRE');
if (preResult) {
return getText(Array.from(preResult.childNodes));
}
else {
return getText(Array.from(parent.childNodes));
}
})
: null;
return textContent ? (textContent.length < 2 ? textContent.join() : textContent) : null;
});
}
function extractListingData(page) {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
const labels = {
summaryLabel: 'Summary',
descriptionLabel: 'Description',
categoryLabel: 'Category:',
locationLabel: 'Located in:',
askingPriceLabel: 'Asking Price:',
realEstateLabel: 'Real Estate Included:',
salesRevenueLabel: 'Sales revenue:',
cashflowLabel: 'Cash flow:',
inventoryLabel: 'Inventory:',
brokerLabel: 'Broker licensing:',
reasonLabel: 'Reason for sale:',
employeesLabel: 'Employees:',
};
const title = (yield page.$eval('div.title', (el) => el.textContent)).trim();
const content = {};
for (const key of Object.values(labels)) {
const element = yield findElementWithText(page, 'div.sub-title', key);
try {
content[key] = element ? yield getParentElementText(element) : 'N/A';
}
catch (error) {
console.log(`Fehler bei : ${key}`);
}
}
let categoryType;
if (content['Category:']) {
categoryType = typesOfBusiness.find((t) => t.name.toLowerCase() === content['Category:'].toLowerCase());
}
else {
console.log(`---> No Category ...`);
}
if (!categoryType) {
console.log(`---> ${content['Category:']}`);
}
try {
const listing = {
id: 'NA',
userId: '1',
listingsCategory: 'business',
title: title,
summary: Array.isArray(content[labels.summaryLabel]) ? content[labels.summaryLabel] : [content[labels.summaryLabel]],
description: Array.isArray(content[labels.descriptionLabel]) ? content[labels.descriptionLabel] : [content[labels.descriptionLabel]],
type: categoryType.value,
location: content[labels.locationLabel],
price: (0, currency_js_1.default)(content[labels.askingPriceLabel]).value,
salesRevenue: (_a = (0, currency_js_1.default)(content[labels.salesRevenueLabel])) === null || _a === void 0 ? void 0 : _a.value,
cashFlow: (_b = (0, currency_js_1.default)(content[labels.cashflowLabel])) === null || _b === void 0 ? void 0 : _b.value,
brokerLicencing: content[labels.brokerLabel],
established: null,
realEstateIncluded: content[labels.realEstateLabel] === 'Yes' ? true : false,
inventory: content[labels.inventoryLabel],
employees: content[labels.employeesLabel],
reasonForSale: content[labels.reasonLabel],
internals: '',
};
return listing;
}
catch (error) {
console.log(`Fehler bei ${title}`);
return null;
}
});
}
function findElementWithText(page, selector, text) {
return __awaiter(this, void 0, void 0, function* () {
const elementHandle = yield page.evaluateHandle((selector, text) => {
const elements = Array.from(document.querySelectorAll(selector));
return elements.find((element) => { var _a; return ((_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim()) === text; });
}, selector, text);
return elementHandle;
});
}
function processPage(browser, url, out) {
return __awaiter(this, void 0, void 0, function* () {
const page = yield browser.newPage();
yield page.goto(url, { waitUntil: 'domcontentloaded' });
const listings = yield page.$$('div.ResultsGridItem');
for (const listing of listings) {
const detailLinkElement = yield listing.$('a.viewListing');
if (detailLinkElement) {
const detailLink = yield detailLinkElement.evaluate((el) => el.getAttribute('href'));
const detailPage = yield browser.newPage();
yield detailPage.goto(detailLink, { waitUntil: 'domcontentloaded' });
const listingData = yield extractListingData(detailPage);
if (listingData) {
console.log(JSON.stringify(listingData));
out.push(listingData);
}
yield detailPage.close();
}
}
const nextPageElement = yield page.$('a.next');
if (nextPageElement) {
let nextPageLink = yield nextPageElement.evaluate((el) => el.getAttribute('href'));
if (!nextPageLink.startsWith('https')) {
const origin = yield page.evaluate(() => location.origin);
nextPageLink = `${origin}${nextPageLink}`;
}
yield processPage(browser, nextPageLink, out);
}
yield page.close();
});
}
(() => __awaiter(void 0, void 0, void 0, function* () {
const browser = yield puppeteer_1.default.launch({ headless: true, executablePath: '/snap/bin/chromium', devtools: true, slowMo: 50 });
//const browser = await puppeteer.launch({devtools: true});
const out = [];
yield processPage(browser, 'https://www.bizmatch.net/results', out);
yield fs_extra_1.default.writeJson('./listings.json', out);
yield browser.close();
}))();
//# sourceMappingURL=index.js.map

View File

@ -1,172 +0,0 @@
// import puppeteer, { Browser, ElementHandle, Page } from 'puppeteer-core';
import puppeteer, { Browser, ElementHandle, Page } from 'puppeteer';
import currency from 'currency.js';
import fs from 'fs-extra'
export interface KeyValue {
name: string;
value: string;
}
const typesOfBusiness: Array<KeyValue> = [
{ name: 'Automotive', value: '1' },
{ name: 'Industrial Services', value: '2' },
{ name: 'Real Estate', value: '3' },
{ name: 'Uncategorized', value: '4' },
{ name: 'Retail', value: '5' },
{ name: 'Oilfield SVE and MFG.', value: '6' },
{ name: 'Service', value: '7' },
{ name: 'Advertising', value: '8' },
{ name: 'Agriculture', value: '9' },
{ name: 'Franchise', value: '10' },
{ name: 'Professional', value: '11' },
{ name: 'Manufacturing', value: '12' },
{ name: 'Food and Restaurant', value: '13' },
];
async function getParentElementText(elementHandle: ElementHandle<Element> | null) {
const textContent = elementHandle
? await elementHandle.evaluate((el) => {
const getText = (nodes: Node[]) => {
const result = [];
//debugger;
for (const node of nodes) {
if (node.nodeType === Node.TEXT_NODE && node.nodeValue!=="\n") {
result.push(node.nodeValue.replace('\n',''));
}
}
return result;
};
const parent = el.parentElement;
if (!parent) return null;
let text = '';
const preResult = Array.from(parent.childNodes).find((e) => e.nodeName === 'PRE');
if (preResult) {
return getText(Array.from(preResult.childNodes));
} else {
return getText(Array.from(parent.childNodes));
}
})
: null;
return textContent?(textContent.length<2?textContent.join():textContent):null
}
async function extractListingData(page: Page): Promise<any | null> {
const labels = {
summaryLabel: 'Summary',
descriptionLabel: 'Description',
categoryLabel: 'Category:',
locationLabel: 'Located in:',
askingPriceLabel: 'Asking Price:',
realEstateLabel: 'Real Estate Included:',
salesRevenueLabel: 'Sales revenue:',
cashflowLabel: 'Cash flow:',
inventoryLabel: 'Inventory:',
brokerLabel: 'Broker licensing:',
reasonLabel: 'Reason for sale:',
employeesLabel: 'Employees:',
};
const title = (await page.$eval('div.title', (el) => el.textContent)).trim();
const content = {};
for (const key of Object.values(labels)) {
const element = await findElementWithText(page, 'div.sub-title', key);
try {
content[key] = element ? await getParentElementText(element) : 'N/A';
} catch (error) {
console.log(`Fehler bei : ${key}`);
}
}
let categoryType
if (content['Category:']){
categoryType = typesOfBusiness.find((t) => t.name.toLowerCase() === content['Category:'].toLowerCase());
} else {
console.log(`---> No Category ...`);
}
if (!categoryType) {
console.log(`---> ${content['Category:']}`);
}
try {
const listing = {
id: 'NA',
userId: '1',
listingsCategory: 'business',
title: title,
summary: Array.isArray(content[labels.summaryLabel])?content[labels.summaryLabel]:[content[labels.summaryLabel]],
description: Array.isArray(content[labels.descriptionLabel])?content[labels.descriptionLabel]:[content[labels.descriptionLabel]],
type: categoryType.value,
location: content[labels.locationLabel],
price: currency(content[labels.askingPriceLabel]).value,
salesRevenue: currency(content[labels.salesRevenueLabel])?.value,
cashFlow: currency(content[labels.cashflowLabel])?.value,
brokerLicencing: content[labels.brokerLabel],
established: null,
realEstateIncluded: content[labels.realEstateLabel] === 'Yes' ? true : false,
inventory: content[labels.inventoryLabel],
employees: content[labels.employeesLabel],
reasonForSale: content[labels.reasonLabel],
internals: '',
} as any;
return listing;
} catch (error) {
console.log(`Fehler bei ${title}`);
return null;
}
}
async function findElementWithText(page: Page, selector: string, text: string) {
const elementHandle = await page.evaluateHandle(
(selector, text) => {
const elements = Array.from(document.querySelectorAll(selector));
return elements.find((element) => element.textContent?.trim() === text);
},
selector,
text
);
return elementHandle;
}
async function processPage(browser: Browser, url: string,out:Array<any>) {
const page = await browser.newPage();
await page.goto(url, { waitUntil: 'domcontentloaded' });
const listings = await page.$$('div.ResultsGridItem');
for (const listing of listings) {
const detailLinkElement = await listing.$('a.viewListing');
if (detailLinkElement) {
const detailLink = await detailLinkElement.evaluate((el) => el.getAttribute('href'));
const detailPage = await browser.newPage();
await detailPage.goto(detailLink!, { waitUntil: 'domcontentloaded' });
const listingData = await extractListingData(detailPage);
if (listingData) {
console.log(JSON.stringify(listingData));
out.push(listingData);
}
await detailPage.close();
}
}
const nextPageElement = await page.$('a.next');
if (nextPageElement) {
let nextPageLink = await nextPageElement.evaluate((el) => el.getAttribute('href'));
if (!nextPageLink.startsWith('https')) {
const origin = await page.evaluate(() => location.origin);
nextPageLink = `${origin}${nextPageLink}`;
}
await processPage(browser, nextPageLink!, out);
}
await page.close();
}
(async () => {
const browser = await puppeteer.launch({ headless: true, executablePath: '/snap/bin/chromium', devtools: true,slowMo: 50 });
//const browser = await puppeteer.launch({devtools: true});
const out = []
await processPage(browser, 'https://www.bizmatch.net/results',out);
await fs.writeJson('./listings.json', out)
await browser.close();
})();

View File

@ -1,34 +0,0 @@
{
"name": "git",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/parser": "^7.24.4",
"@babel/traverse": "^7.24.1",
"commander": "^12.0.0",
"typescript": "^5.4.5"
},
"dependencies": {
"@types/node": "^20.12.7",
"currency.js": "^2.0.4",
"drizzle-orm": "^0.30.8",
"fs-extra": "^11.2.0",
"inquirer": "^9.2.17",
"ioredis": "^5.3.2",
"node-fetch": "^3.3.2",
"pg": "^8.11.5",
"puppeteer": "^22.1.0",
"redis": "^4.6.13",
"redis-om": "^0.4.3",
"uuidv4": "^6.2.13",
"winston": "^3.13.0",
"yargs": "^17.7.2"
}
}

View File

@ -1,68 +0,0 @@
import {createLogger,transports, format} from 'winston';
import { createClient } from 'redis';
import { Repository, Schema, SchemaDefinition } from 'redis-om';
const baseListingSchemaDef : SchemaDefinition = {
id: { type: 'string' },
userId: { type: 'string' },
listingsCategory: { type: 'string' },
title: { type: 'string' },
description: { type: 'string' },
country: { type: 'string' },
state:{ type: 'string' },
city:{ type: 'string' },
zipCode: { type: 'number' },
type: { type: 'string' },
price: { type: 'number' },
favoritesForUser:{ type: 'string[]' },
hideImage:{ type: 'boolean' },
draft:{ type: 'boolean' },
created:{ type: 'date' },
updated:{ type: 'date' }
}
const businessListingSchemaDef : SchemaDefinition = {
...baseListingSchemaDef,
salesRevenue: { type: 'number' },
cashFlow: { type: 'number' },
employees: { type: 'number' },
established: { type: 'number' },
internalListingNumber: { type: 'number' },
realEstateIncluded:{ type: 'boolean' },
leasedLocation:{ type: 'boolean' },
franchiseResale:{ type: 'boolean' },
supportAndTraining: { type: 'string' },
reasonForSale: { type: 'string' },
brokerLicencing: { type: 'string' },
internals: { type: 'string' },
}
const businessListingSchema = new Schema('business',businessListingSchemaDef, {
dataStructure: 'JSON'
})
const logger = createLogger({
transports: [
new transports.Console(),
],
format: format.combine(
format.colorize(),
format.timestamp(),
format.printf(({ timestamp, level, message, service }) => {
return `[${timestamp}] ${service} ${level}: ${message}`;
})
),
});
const redis = await createClient()
.on('error', err => console.log('Redis Client Error', err))
.connect();
const businessListingRepository = new Repository(businessListingSchema, redis);
(async () => {
logger.info(`start findBusinessListings:`);
const result = await redis.ft.search('business:index','*',{LIMIT:{from:0,size:200}});
//result.documents.forEach(d=>console.log(d));
logger.info(`end findBusinessListings:`);
logger.info(`start businessListingRepository:`);
await businessListingRepository.search().return.all()
logger.info(`end businessListingRepository:`);
redis.disconnect();
})();

View File

@ -1,158 +0,0 @@
import pkg from 'pg';
const { Pool } = pkg;
import fsextra from 'fs-extra';
const { fstat, readFileSync, writeJsonSync } = fsextra;
import { v4 as uuidv4 } from 'uuid';
// PostgreSQL Verbindungskonfiguration
const pool = new Pool({
user: 'bizmatch',
host: 'localhost',
database: 'bizmatch',
password: 'xieng7Seih',
port: 5432,
});
// Typdefinition für das JSON-Objekt
interface BusinessListing {
userId?: string;
listingsCategory: string;
title: string;
description: string;
type: string;
state: string;
city: string;
id: string;
price: number;
salesRevenue: number;
leasedLocation: boolean;
established: number;
employees: number;
reasonForSale: string;
supportAndTraining: string;
cashFlow: number;
brokerLicencing: string;
internalListingNumber: number;
realEstateIncluded: boolean;
franchiseResale: boolean;
draft: boolean;
internals: string;
created: Date;
}
async function importBusinesses() {
const filePath = './data/businesses.json'
const data: string = readFileSync(filePath, 'utf8');
const jsonData: BusinessListing[]|any = JSON.parse(data); // Erwartet ein Array von Objekten
await pool.query('drop table if exists businesses');
await pool.query(`CREATE TABLE businesses (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
created TIMESTAMP,
updated TIMESTAMP,
visits INTEGER,
last_visit TIMESTAMP,
data jsonb
);`);
for (const listing of jsonData) {
const created = listing.created
delete listing.created;
delete listing.id;
delete listing.temporary
const json_values = [
created, new Date(), 0, null, listing
]
await pool.query('INSERT INTO businesses (created, updated, visits, last_visit, data) VALUES ($1,$2,$3,$4,$5)', json_values);
}
console.log('All data imported successfully.');
}
async function importUser() {
const filePath = './data/broker.json'
const data: string = readFileSync(filePath, 'utf8');
const jsonData: any[] = JSON.parse(data); // Erwartet ein Array von Objekten
await pool.query('drop table if exists users');
await pool.query(`CREATE TABLE users (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
created TIMESTAMP,
updated TIMESTAMP,
visits INTEGER,
last_visit TIMESTAMP,
data jsonb
);`);
for (const user of jsonData) {
delete user.id;
user.hasCompanyLogo=false;
user.hasProfile=false;
const json_values = [
getRandomDateLastYear(), new Date(), 0, null, user
]
await pool.query('INSERT INTO users (created, updated, visits, last_visit, data) VALUES ($1,$2,$3,$4,$5)', json_values);
}
console.log('All data imported successfully.');
}
async function importCommercials() {
const filePath = './data/commercials.json'
const data: string = readFileSync(filePath, 'utf8');
const jsonData: any[]|any = JSON.parse(data); // Erwartet ein Array von Objekten
await pool.query('drop table if exists commercials');
await pool.query(`CREATE TABLE commercials (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
created TIMESTAMP,
updated TIMESTAMP,
visits INTEGER,
last_visit TIMESTAMP,
data jsonb
);`);
for (const commercial of jsonData) {
commercial.hasImages=false;
commercial.imagePath=commercial.id;
delete commercial.id;
delete commercial.temporary;
const json_values = [
getRandomDateLastYear(), new Date(), 0, null, commercial
]
await pool.query('INSERT INTO commercials (created, updated, visits, last_visit, data) VALUES ($1,$2,$3,$4,$5)', json_values);
}
console.log('All data imported successfully.');
}
function idUpdate(jsonData) {
const out: BusinessListing[] = []
for (const listing of jsonData) {
const uuid = uuidv4();
listing.id = uuid;
out.push(listing);
}
writeJsonSync('./data/businesses_.json', out);
console.log('All data updated sucessfully.');
}
function getRandomDateLastYear(): Date {
const today = new Date();
const lastYear = new Date(today.getFullYear() - 1, today.getMonth(), today.getDate());
// Generiere eine zufällige Zahl zwischen 0 und der Anzahl der Millisekunden in einem Jahr
const randomTime = Math.random() * (today.getTime() - lastYear.getTime());
// Erstelle ein neues Datum basierend auf dieser zufälligen Zeit
const randomDate = new Date(lastYear.getTime() + randomTime);
return randomDate;
}
// Passen Sie den Dateipfad an Ihre spezifischen Bedürfnisse an
try {
await importBusinesses();
await importUser();
await importCommercials();
} catch (err) {
console.error('Error importing data:', err.message);
} finally {
// Schließen der Verbindung zum Pool
await pool.end();
}

View File

@ -1,81 +0,0 @@
// import { pgTable, timestamp, integer, jsonb, uuid } from 'drizzle-orm/pg-core';
// import { InferModel } from 'drizzle-orm';
// import { sql } from 'drizzle-orm';
// import { drizzle } from 'drizzle-orm/node-postgres';
// import { Pool } from 'pg';
// // Definiere den benutzerdefinierten Typ für das JSON-Objekt
// type BusinessData = {
// id?: string;
// firstname: string;
// lastname: string;
// email: string;
// phoneNumber: string;
// companyLocation: string;
// hasCompanyLogo: boolean;
// hasProfile: boolean;
// };
// // Definiere die Tabelle "businesses"
// const businesses = pgTable('businesses', {
// id: uuid('id').primaryKey(),
// created: timestamp('created'),
// updated: timestamp('updated'),
// visits: integer('visits'),
// lastVisit: timestamp('last_visit'),
// data: jsonb('data'),
// });
// // Definiere den Typ für das Modell
// type Business = InferModel<typeof businesses, 'select'>;
// // Erstelle eine Verbindung zur Datenbank
// const pool = new Pool({
// // Konfiguriere die Verbindungsoptionen
// });
// const db = drizzle(pool);
// // Beispiel für das Einfügen eines neuen Datensatzes
// const insertBusiness = async () => {
// const businessData: BusinessData = {
// firstname: 'Robert',
// lastname: 'Jackson',
// email: 'robert.jackson@texasbizbrokers.com',
// phoneNumber: '(214) 555-7890',
// companyLocation: 'Dallas - TX',
// hasCompanyLogo: true,
// hasProfile: true,
// };
// const [insertedBusiness] = await db
// .$with('sq')
// .as({
// new_business: sql<{ generated_id: string; created: Date; updated: Date; visits: number; last_visit: Date; data: BusinessData }>`(${(qb) => {
// return qb
// .select({
// generated_id: sql`uuid_generate_v4()`,
// created: sql`NOW()`,
// updated: sql`NOW()`,
// visits: sql`0`,
// last_visit: sql`NOW()`,
// data: sql`jsonb_set(${JSON.stringify(businessData)}::jsonb, '{id}', to_jsonb(uuid_generate_v4()))`,
// });
// }})`
// })
// .insert(businesses)
// .values((eb) => ({
// id: eb.generated_id,
// created: eb.created,
// updated: eb.updated,
// visits: eb.visits,
// lastVisit: eb.last_visit,
// data: sql`jsonb_set(${eb.data}::jsonb, '{id}', to_jsonb(${eb.generated_id}))`,
// }))
// .returning({ generatedId: businesses.id, jsonData: businesses.data });
// console.log('Generated ID:', insertedBusiness.generatedId);
// console.log('JSON Data:', insertedBusiness.jsonData);
// };
// insertBusiness();

View File

@ -1,77 +0,0 @@
import { integer, serial, text, pgTable, timestamp, jsonb, varchar, char, numeric, boolean, uuid, real, doublePrecision } from 'drizzle-orm/pg-core';
import { InferInsertModel, InferModel, InferModelFromColumns, InferSelectModel, relations, sql } from 'drizzle-orm';
export const PG_CONNECTION = 'PG_CONNECTION';
export const users = pgTable('users', {
id: uuid('id').primaryKey().defaultRandom(),
firstname: varchar('firstname', { length: 255 }).notNull(),
lastname: varchar('lastname', { length: 255 }).notNull(),
email: varchar('email', { length: 255 }).notNull(),
phoneNumber: varchar('phoneNumber', { length: 255 }),
description: text('description'),
companyName: varchar('companyName', { length: 255 }),
companyOverview: text('companyOverview'),
companyWebsite: varchar('companyWebsite', { length: 255 }),
companyLocation: varchar('companyLocation', { length: 255 }),
offeredServices: text('offeredServices'),
areasServed: varchar('areasServed', { length: 100 }).array(),
hasProfile: boolean('hasProfile'),
hasCompanyLogo: boolean('hasCompanyLogo'),
licensedIn:varchar('licensedIn', { length: 50 }).array(),
});
export const businesses = pgTable('businesses', {
id: uuid('id').primaryKey().defaultRandom(),
userId: uuid('userId').references(()=>users.id),
type: varchar('type', { length: 255 }),
title: varchar('title', { length: 255 }),
description: text('description'),
city: varchar('city', { length: 255 }),
state: char('state', { length: 2 }),
price: doublePrecision('price'),
favoritesForUser: varchar('favoritesForUser',{length:30}).array(),
draft: boolean('draft'),
listingsCategory: varchar('listingsCategory', { length: 255 }),
realEstateIncluded: boolean('realEstateIncluded'),
leasedLocation: boolean('leasedLocation'),
franchiseResale: boolean('franchiseResale'),
salesRevenue: doublePrecision('salesRevenue'),
cashFlow: doublePrecision('cashFlow'),
supportAndTraining: text('supportAndTraining'),
employees: integer('employees'),
established: integer('established'),
internalListingNumber: integer('internalListingNumber'),
reasonForSale: varchar('reasonForSale', { length: 255 }),
brokerLicencing: varchar('brokerLicencing', { length: 255 }),
internals: text('internals'),
created: timestamp('created'),
updated: timestamp('updated'),
visits: integer('visits'),
lastVisit: timestamp('lastVisit'),
});
export const commercials = pgTable('commercials', {
id: uuid('id').primaryKey().defaultRandom(),
userId: uuid('userId').references(()=>users.id),
type: varchar('type', { length: 255 }),
title: varchar('title', { length: 255 }),
description: text('description'),
city: varchar('city', { length: 255 }),
state: char('state', { length: 2 }),
price: doublePrecision('price'),
favoritesForUser: varchar('favoritesForUser',{length:30}).array(),
hideImage: boolean('hideImage'),
draft: boolean('draft'),
zipCode:integer('zipCode'),
county:varchar('county', { length: 255 }),
email: varchar('email', { length: 255 }),
website: varchar('website', { length: 255 }),
phoneNumber: varchar('phoneNumber', { length: 255 }),
imageOrder:varchar('imageOrder',{length:30}).array(),
imagePath:varchar('imagePath',{length:30}).array(),
created: timestamp('created'),
updated: timestamp('updated'),
visits: integer('visits'),
lastVisit: timestamp('lastVisit'),
});

View File

@ -1,109 +0,0 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */
/* Projects */
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "ES2020", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Modules */
// "module": "Node16", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "Node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
// "resolveJsonModule": true, /* Enable importing .json files. */
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
/* JavaScript Support */
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
/* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
"sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
"outDir": "./build", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
// "newLine": "crlf", /* Set the newline character for emitting files. */
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
"allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
/* Type Checking */
"strict": false, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}

40
crawler/updateFields.js Normal file
View File

@ -0,0 +1,40 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
//const argv = yargs(hideBin(process.argv)).argv
// if (!argv.userId){
// console.log(' --userId [any valid userId]')
// process.exit(1)
// }
(() => __awaiter(void 0, void 0, void 0, function* () {
const selectOptionsResponse = yield fetch('http://localhost:3000/bizmatch/select-options', {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
});
const selectOptions = yield selectOptionsResponse.json();
const response = yield fetch('http://localhost:3000/bizmatch/listings', {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
});
const listings = yield response.json();
for (const listing of listings) {
const option = selectOptions.locations.find(l => l.name.toLowerCase() === listing.location.toLowerCase());
if (option) {
listing.location = option.value;
}
const response = yield fetch(`http://localhost:3000/bizmatch/listings/${listing.id}`, {
method: 'PUT',
body: JSON.stringify(listing),
headers: { 'Content-Type': 'application/json' },
});
}
}))();
//# sourceMappingURL=updateFields.js.map

View File

@ -1,34 +0,0 @@
import yargs from 'yargs'
import fs from 'fs-extra';
import { hideBin } from 'yargs/helpers'
//const argv = yargs(hideBin(process.argv)).argv
// if (!argv.userId){
// console.log(' --userId [any valid userId]')
// process.exit(1)
// }
(async () => {
const selectOptionsResponse = await fetch('http://localhost:3000/bizmatch/select-options', {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
})
const selectOptions:any = await selectOptionsResponse.json();
const response = await fetch('http://localhost:3000/bizmatch/listings', {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
})
const listings:Array<any> = await response.json();
for (const listing of listings) {
const option = selectOptions.locations.find(l=>l.name.toLowerCase()===listing.state.toLowerCase());
if (option){
listing.state=option.value
}
const response = await fetch(`http://localhost:3000/bizmatch/listings/${listing.id}`, {
method: 'PUT',
body: JSON.stringify(listing),
headers: { 'Content-Type': 'application/json' },
});
}
})();