Umbau auf postgres 2. step

This commit is contained in:
2024-04-22 22:26:44 +02:00
parent c90d6b72b7
commit 7f0f21b598
77 changed files with 3325 additions and 3066 deletions

View File

@@ -41,5 +41,21 @@
"${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",
],
},
]
}

14
crawler/UserInterface.ts Normal file
View File

@@ -0,0 +1,14 @@
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[];
}

View File

@@ -1,30 +1,30 @@
import yargs from 'yargs'
import fs from 'fs-extra';
import { hideBin } from 'yargs/helpers'
import { BusinessListing } from "../common-models/src/main.model"
// 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
// const argv = yargs(hideBin(process.argv)).argv
if (!argv.userId){
console.log(' --userId [any valid userId]')
process.exit(1)
}
// 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' },
});
}
})();
// (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' },
// });
// }
// })();

View File

@@ -2698,5 +2698,161 @@
"description": "<p>Acquire this stunning waterfront restaurant and event venue located in the historic district of Annapolis, Maryland, offering breathtaking views of the Chesapeake Bay and Annapolis Harbor. The property features a beautifully restored building, multiple dining areas, and a large outdoor terrace, making it a highly sought-after destination for dining, weddings, and special events.</p><h3>Waterfront restaurant and event venue features:</h3><p>- 10,000 square feet of indoor and outdoor dining and event space<br>- Seating capacity for up to 200 guests<br>- Expansive waterfront terrace with unobstructed views of the Chesapeake Bay<br>- Fully equipped commercial kitchen and bar<br>- Elegantly appointed private dining rooms for intimate gatherings<br>- Prime location in the heart of Annapolis' historic district</p><p>Invest in this exceptional waterfront restaurant and event venue and capitalize on the strong demand for unique dining experiences and memorable event spaces in the charming and historically significant Annapolis market, a popular destination for tourists and locals alike.</p>",
"type": "100",
"imageOrder": []
},
{
"id": "a1b2c3d4-e5f6-7g8h-9i0j-1k2l3m4n5o6p",
"userId": "",
"listingsCategory": "commercialProperty",
"title": "Scenic Hill Country Ranch",
"state": "TX",
"hasImages": true,
"price": 7500000,
"city": "Fredericksburg",
"description": "<h2>Stunning Ranch in the Heart of Texas Hill Country</h2><p>Discover the beauty and tranquility of this breathtaking 500-acre ranch nestled in the picturesque Texas Hill Country. With its rolling hills, lush pastures, and crystal-clear streams, this property offers a perfect blend of natural beauty and recreational opportunities.</p><p>Key features include:</p><ul><li>Main residence: 4,500 sq ft luxury home with 5 bedrooms and 4.5 bathrooms</li><li>Guest house: Charming 2-bedroom, 2-bathroom cottage</li><li>Equestrian facilities: 10-stall barn, riding arena, and miles of riding trails</li><li>Hunting and fishing: Abundant wildlife and stocked ponds</li></ul><p>This exceptional ranch is a rare find and presents a unique opportunity for those seeking a luxury retreat or a profitable hunting and recreation property.</p>",
"type": "101",
"imageOrder": []
},
{
"id": "5e6f7g8h-9i0j-1k2l-3m4n-5o6p7q8r9s0t",
"userId": "",
"listingsCategory": "commercialProperty",
"title": "Thriving Gas Station and Convenience Store",
"state": "TX",
"hasImages": true,
"price": 1750000,
"city": "San Antonio",
"description": "<p>Well-established gas station and convenience store located in a high-traffic area of San Antonio. This profitable business offers a prime opportunity for investors seeking a stable income stream and growth potential.</p><h3>Property and Business Highlights:</h3><ul><li>Large 1-acre lot with ample parking</li><li>4,000 sq ft convenience store with modern fixtures</li><li>High-volume fuel sales and diverse in-store product mix</li><li>Long-term supplier contracts and loyal customer base</li></ul><p>Take advantage of this turn-key investment opportunity in San Antonio's robust retail market.</p>",
"type": "100",
"imageOrder": []
},
{
"id": "7g8h9i0j-1k2l-3m4n-5o6p-7q8r9s0t1u2v",
"userId": "",
"listingsCategory": "commercialProperty",
"title": "Full-Service Car Wash in High-Growth Austin Suburb",
"state": "TX",
"hasImages": true,
"price": 3500000,
"city": "Round Rock",
"description": "<p>Highly profitable, full-service car wash located in the rapidly growing Austin suburb of Round Rock. This well-maintained facility has a strong reputation for quality service and boasts a loyal customer base in a high-income residential area.</p><h3>Business and Property Highlights:</h3><ul><li>1.5-acre site with spacious parking and attractive landscaping</li><li>4 self-serve bays and 2 automatic wash tunnels</li><li>Modern equipment and computerized payment systems</li><li>Consistent year-over-year revenue growth and high margins</li></ul><p>Capitalize on the booming Austin metro market with this established, high-performing car wash business.</p>",
"type": "100",
"imageOrder": []
},
{
"id": "9i0j1k2l-3m4n-5o6p-7q8r-9s0t1u2v3w4x",
"userId": "",
"listingsCategory": "commercialProperty",
"title": "Historic Church Building in Downtown San Antonio",
"state": "TX",
"hasImages": true,
"price": 2200000,
"city": "San Antonio",
"description": "<p>Unique opportunity to acquire a beautifully preserved historic church building in the heart of downtown San Antonio. This iconic property offers a blend of old-world charm and modern amenities, making it an ideal space for a variety of commercial or community uses.</p><h3>Property Highlights:</h3><ul><li>10,000 sq ft of versatile interior space with soaring ceilings</li><li>Meticulously maintained original architectural features</li><li>Newly updated electrical, plumbing, and HVAC systems</li><li>Prime location near popular attractions and public transportation</li></ul><p>Embrace the rich history and endless potential of this one-of-a-kind property in San Antonio's vibrant downtown district.</p>",
"type": "106",
"imageOrder": []
},
{
"id": "0j1k2l3m-4n5o-6p7q-8r9s-0t1u2v3w4x5y",
"userId": "",
"listingsCategory": "commercialProperty",
"title": "Established Bar and Live Music Venue in Austin",
"state": "TX",
"hasImages": true,
"price": 1800000,
"city": "Austin",
"description": "<h2>Iconic Austin Bar and Music Hotspot</h2><p>Own a piece of Austin's legendary live music scene with this well-known bar and music venue. Located in the heart of the city's entertainment district, this business has a loyal following and a reputation for showcasing top talent.</p><p>Property and business features:</p><ul><li>6,000 sq ft building with a spacious stage and multiple bars</li><li>Fully equipped kitchen and outdoor patio area</li><li>Established relationships with booking agents and promoters</li><li>Consistent revenue and growth potential in Austin's thriving nightlife scene</li></ul><p>Take center stage in Austin's vibrant music community with this turnkey business opportunity.</p>",
"type": "100",
"imageOrder": []
},
{
"id": "1k2l3m4n-5o6p-7q8r-9s0t-1u2v3w4x5y6z",
"userId": "",
"listingsCategory": "commercialProperty",
"title": "Private Airport and Aviation Community",
"state": "TX",
"hasImages": true,
"price": 15000000,
"city": "Fredericksburg",
"description": "<p>Rare opportunity to acquire a private airport and aviation community nestled in the scenic Texas Hill Country. This unique property features a well-maintained runway, hangar facilities, and a gated residential airpark.</p><h3>Property Highlights:</h3><ul><li>4,500' x 75' paved and lighted runway</li><li>50 acres of land with room for expansion</li><li>20 aircraft hangars and a private fuel farm</li><li>Gated community with 15 aviation-themed homes</li></ul><p>Elevate your investment portfolio with this one-of-a-kind aviation property in the heart of Texas.</p>",
"type": "101",
"imageOrder": []
},
{
"id": "0t1u2v3w-4x5y-6z7a-8b9c-0d1e2f3g4h5i",
"userId": "",
"listingsCategory": "commercialProperty",
"title": "Scenic Hill Country RV Resort",
"state": "TX",
"hasImages": true,
"price": 6500000,
"city": "New Braunfels",
"description": "<h2>Premium RV Resort in the Heart of Texas Hill Country</h2><p>Discover the beauty and tranquility of the Texas Hill Country at this top-rated RV resort in New Braunfels. Nestled along the banks of the Guadalupe River, this immaculately maintained property offers guests a perfect blend of natural beauty, modern amenities, and endless recreational opportunities.</p><p>Resort features and highlights:</p><ul><li>150 spacious RV sites with full hookups and concrete pads</li><li>Sparkling swimming pool, hot tub, and sun deck area</li><li>Private river access with designated swimming and fishing spots</li><li>Clubhouse with game room, fitness center, and meeting spaces</li><li>Close proximity to popular attractions like Schlitterbahn Water Park and Gruene Historic District</li></ul><p>This profitable RV resort presents a unique investment opportunity in one of Texas' most sought-after vacation destinations. With strong occupancy rates, a loyal customer base, and multiple revenue streams, this turn-key property is poised for continued growth and success.</p><p>Capitalize on the booming Texas tourism market with this exceptional RV resort in the picturesque Hill Country region.</p>",
"type": "101",
"imageOrder": []
},
{
"id": "3m4n5o6p-7q8r-9s0t-1u2v-3w4x5y6z7a8b",
"userId": "",
"listingsCategory": "commercialProperty",
"title": "Turnkey Industrial Manufacturing Facility",
"state": "TX",
"hasImages": true,
"price": 9750000,
"city": "Fort Worth",
"description": "<p>Fully equipped industrial manufacturing facility located in Fort Worth's thriving Alliance commercial district. This modern property offers a turnkey solution for businesses seeking to expand or relocate their operations to the Dallas-Fort Worth Metroplex.</p><h3>Property Highlights:</h3><ul><li>150,000 sq ft of manufacturing and warehouse space</li><li>State-of-the-art production equipment and utility systems</li><li>Abundant power, water, and natural gas capacity</li><li>Easy access to I-35W, I-820, and Alliance Airport</li></ul><p>Unlock your company's growth potential with this move-in-ready manufacturing facility in one of the nation's top industrial markets.</p>",
"type": "102",
"imageOrder": []
},
{
"id": "6p7q8r9s-0t1u-2v3w-4x5y-6z7a8b9c0d1e",
"userId": "",
"listingsCategory": "commercialProperty",
"title": "Full-Service Auto Dealership and Service Center",
"state": "TX",
"hasImages": true,
"price": 5500000,
"city": "San Marcos",
"description": "<p>Well-established, full-service auto dealership and service center located in the rapidly growing city of San Marcos. This successful business benefits from a prime location along the heavily trafficked I-35 corridor between Austin and San Antonio.</p><h3>Property and Business Highlights:</h3><ul><li>5-acre site with modern showroom and service facilities</li><li>Franchise rights for a major domestic auto brand</li><li>Loyal customer base and strong revenue growth</li><li>Highly trained sales and service staff in place</li></ul><p>Take the wheel of this profitable auto dealership in one of Texas' fastest-growing markets.</p>",
"type": "100",
"imageOrder": []
},
{
"id": "7q8r9s0t-1u2v-3w4x-5y6z-7a8b9c0d1e2f",
"userId": "",
"listingsCategory": "commercialProperty",
"title": "Multi-Tenant Medical Office Complex",
"state": "TX",
"hasImages": true,
"price": 8750000,
"city": "Plano",
"description": "<p>Newly constructed, multi-tenant medical office complex in the heart of Plano's booming Legacy West district. This state-of-the-art facility offers a prime location and modern amenities, making it an attractive choice for a wide range of healthcare providers.</p><h3>Property Features and Highlights:</h3><ul><li>80,000 sq ft of customizable medical office space</li><li>Abundant parking and easy access from Dallas North Tollway</li><li>On-site surgical center and diagnostic imaging suites</li><li>Close proximity to major hospitals and residential areas</li></ul><p>Capitalize on the growing demand for high-quality medical office space in one of the Dallas area's most affluent and dynamic communities.</p>",
"type": "103",
"imageOrder": []
},
{
"id": "8r9s0t1u-2v3w-4x5y-6z7a-8b9c0d1e2f3g",
"userId": "",
"listingsCategory": "commercialProperty",
"title": "Upscale Boutique Motel in Trendy East Austin",
"state": "TX",
"hasImages": true,
"price": 4200000,
"city": "Austin",
"description": "<h2>Chic Motel in the Heart of Austin's Creative Hub</h2><p>Unique opportunity to acquire a beautifully renovated, upscale boutique motel in Austin's vibrant East Side neighborhood. This trendy property offers a perfect blend of retro charm and modern amenities, attracting a hip, creative clientele.</p><p>Property features and highlights:</p><ul><li>25 stylishly appointed guest rooms with premium finishes</li><li>Instagrammable pool area and cozy outdoor lounge spaces</li><li>Artisanal coffee bar and curated retail shop</li><li>Walking distance to popular restaurants, bars, and music venues</li></ul><p>Tap into Austin's booming tourism market with this one-of-a-kind boutique motel in the city's trendiest neighborhood.</p>",
"type": "100",
"imageOrder": []
},
{
"id": "9s0t1u2v-3w4x-5y6z-7a8b-9c0d1e2f3g4h",
"userId": "",
"listingsCategory": "commercialProperty",
"title": "Warehouse and Showroom Space in Houston's Design District",
"state": "TX",
"hasImages": true,
"price": 3750000,
"city": "Houston",
"description": "<p>Expansive warehouse and showroom space located in the heart of Houston's thriving Design District. This versatile property offers a prime location and flexible layout, making it ideal for a variety of wholesale, distribution, and creative business uses.</p><h3>Property Highlights:</h3><ul><li>30,000 sq ft of warehouse and showroom space</li><li>High ceilings, ample natural light, and modern finishes</li><li>Loading docks and easy access to I-10 and I-45</li><li>Surrounded by premier design showrooms and art galleries</li></ul><p>Showcase your business in one of Houston's most creative and dynamic commercial districts.</p>",
"type": "102",
"imageOrder": []
}
]

View File

@@ -1,13 +0,0 @@
import fs from 'fs-extra';
(async () => {
const listings = await fs.readJson('./users.json');
//listings.forEach(element => {
for (const listing of listings) {
const response = await fetch('http://localhost:3000/bizmatch/user', {
method: 'POST',
body: JSON.stringify(listing),
headers: { 'Content-Type': 'application/json' },
});
}
})();

View File

@@ -1,6 +1,6 @@
// import puppeteer, { Browser, ElementHandle, Page } from 'puppeteer-core';
import puppeteer, { Browser, ElementHandle, Page } from 'puppeteer';
import { BusinessListing } from "../common-models/src/main.model"
import currency from 'currency.js';
import fs from 'fs-extra'
@@ -51,7 +51,7 @@ async function getParentElementText(elementHandle: ElementHandle<Element> | null
return textContent?(textContent.length<2?textContent.join():textContent):null
}
async function extractListingData(page: Page): Promise<BusinessListing | null> {
async function extractListingData(page: Page): Promise<any | null> {
const labels = {
summaryLabel: 'Summary',
descriptionLabel: 'Description',

View File

@@ -3,7 +3,6 @@
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
@@ -11,6 +10,9 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/parser": "^7.24.4",
"@babel/traverse": "^7.24.1",
"commander": "^12.0.0",
"typescript": "^5.4.5"
},
"dependencies": {

View File

@@ -3,7 +3,7 @@ const { Pool } = pkg;
import fsextra from 'fs-extra';
const { fstat, readFileSync, writeJsonSync } = fsextra;
import { v4 as uuidv4 } from 'uuid';
import { CommercialPropertyListing, User } from '../common-models/src/main.model';
// PostgreSQL Verbindungskonfiguration
const pool = new Pool({
user: 'bizmatch',
@@ -70,7 +70,7 @@ async function importBusinesses() {
async function importUser() {
const filePath = './data/broker.json'
const data: string = readFileSync(filePath, 'utf8');
const jsonData: User[] = JSON.parse(data); // Erwartet ein Array von Objekten
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(),
@@ -96,7 +96,7 @@ async function importUser() {
async function importCommercials() {
const filePath = './data/commercials.json'
const data: string = readFileSync(filePath, 'utf8');
const jsonData: CommercialPropertyListing[]|any = JSON.parse(data); // Erwartet ein Array von Objekten
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(),

View File

@@ -1,80 +1,81 @@
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';
// 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 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 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'>;
// // 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
});
// // Erstelle eine Verbindung zur Datenbank
// const pool = new Pool({
// // Konfiguriere die Verbindungsoptionen
// });
const db = drizzle(pool);
// 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,
};
// // 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({
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 });
// 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);
};
// console.log('Generated ID:', insertedBusiness.generatedId);
// console.log('JSON Data:', insertedBusiness.jsonData);
// };
insertBusiness();
// insertBusiness();

77
crawler/schema.ts Normal file
View File

@@ -0,0 +1,77 @@
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

@@ -25,9 +25,9 @@
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Modules */
"module": "ESNext", /* Specify what module code is generated. */
// "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. */
// "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. */

View File

@@ -1,7 +1,7 @@
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){
@@ -19,7 +19,7 @@ import { BusinessListing } from "../common-models/src/main.model"
method: 'GET',
headers: { 'Content-Type': 'application/json' },
})
const listings:Array<BusinessListing> = await response.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){