initial release

This commit is contained in:
2024-02-29 10:23:41 -06:00
commit 5146c8e919
210 changed files with 11040 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
import { Controller, Param, Post, UploadedFile, UseInterceptors } from '@nestjs/common';
import { FileInterceptor } from '@nestjs/platform-express';
import { FileService } from '../file/file.service.js';
@Controller('account')
export class AccountController {
constructor(private fileService:FileService){}
@Post('uploadPhoto/:id')
@UseInterceptors(FileInterceptor('file'),)
uploadFile(@UploadedFile() file: Express.Multer.File,@Param('id') id:string) {
this.fileService.storeFile(file,id);
}
}

View File

@@ -0,0 +1,4 @@
import { Injectable } from '@nestjs/common';
@Injectable()
export class AccountService {}

View File

@@ -0,0 +1,12 @@
import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service.js';
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
@Get()
getHello(): string {
return this.appService.getHello();
}
}

View File

@@ -0,0 +1,51 @@
import { Module } from '@nestjs/common';
import { AppController } from './app.controller.js';
import { AppService } from './app.service.js';
import { ListingsController } from './listings/listings.controller.js';
import { FileService } from './file/file.service.js';
import { AuthService } from './auth/auth.service.js';
import { AuthController } from './auth/auth.controller.js';
import { ConfigModule } from '@nestjs/config';
import { SelectOptionsController } from './select-options/select-options.controller.js';
import { SelectOptionsService } from './select-options/select-options.service.js';
import { SubscriptionsController } from './subscriptions/subscriptions.controller.js';
import { RedisModule } from './redis/redis.module.js';
import { ListingsService } from './listings/listings.service.js';
import { AccountController } from './account/account.controller.js';
import { AccountService } from './account/account.service.js';
import { ServeStaticModule } from '@nestjs/serve-static';
import path, { join } from 'path';
import { fileURLToPath } from 'url';
import { utilities as nestWinstonModuleUtilities, WinstonModule } from 'nest-winston';
import * as winston from 'winston';
import { MailModule } from './mail/mail.module.js';
import { AuthModule } from './auth/auth.module.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
@Module({
imports: [ConfigModule.forRoot(), RedisModule, MailModule, AuthModule,
ServeStaticModule.forRoot({
rootPath: join(__dirname, '..', 'public'), // `public` ist das Verzeichnis, wo Ihre statischen Dateien liegen
}),
WinstonModule.forRoot({
transports: [
new winston.transports.Console({
format: winston.format.combine(
winston.format.timestamp(),
winston.format.ms(),
nestWinstonModuleUtilities.format.nestLike('Bizmatch', {
colors: true,
prettyPrint: true,
}),
),
}),
// other transports...
],
// other options
})
],
controllers: [AppController, ListingsController, SelectOptionsController, SubscriptionsController, AccountController],
providers: [AppService, FileService, SelectOptionsService, ListingsService, AccountService],
})
export class AppModule {}

View File

@@ -0,0 +1,8 @@
import { Injectable } from '@nestjs/common';
@Injectable()
export class AppService {
getHello(): string {
return 'Hello World!';
}
}

View File

@@ -0,0 +1,66 @@
[
{
"id":"1",
"userId":"1",
"listingsCategory": "business",
"title": "Industrial Service Company In Corpus Christi For Sale - 1954",
"summary": ["Asking price: $5,500,000","Sales revenue: $1,200,000","Net profit: $650,000"],
"description": ["This company services a wide variety of industries. Asking price includes Business and the Real Estate and is approx 30,000 sq ft with room for expansion including approx 5 acres. Absentee run business."],
"type": "2",
"location": "Texas",
"price":5500000,
"salesRevenue":1200000,
"cashFlow":650000,
"brokerLicencing":"TREC Broker #516788",
"established":1954,
"realEstateIncluded":true
},
{
"id":"2",
"userId":"1",
"listingsCategory": "business",
"title": "Coastal Bend Manufacturing Business Plastic Injection For Sale - 1950",
"summary": ["Asking price: $165,000","Sales revenue: Undisclosed","Net profit: Undisclosed"],
"description": [""],
"type": "12",
"location": "Texas",
"price":165000,
"salesRevenue":null,
"cashFlow":null,
"brokerLicencing":"TREC Broker #516788",
"established":1950,
"realEstateIncluded":false
},
{
"id":"3",
"userId":"1",
"listingsCategory": "business",
"title": "Corner Property On Everhart South-side Corpus Christi For Sale - 1944",
"summary": ["Asking price: $830,000","Sales revenue: Undisclosed","Net profit: Undisclosed"],
"description": [""],
"type": "3",
"location": "Texas",
"price":830000,
"salesRevenue":null,
"cashFlow":null,
"brokerLicencing":"TREC Broker #516788",
"established":1944,
"realEstateIncluded":false
},
{
"id":"4",
"userId":"1",
"listingsCategory": "business",
"title": "Corpus Christi Dessert Business For Sale - 1941",
"summary": ["Asking price: $124,900","Sales revenue: $225,000","Net profit: $50,000"],
"description": [""],
"type": "13",
"location": "Texas",
"price":830000,
"salesRevenue":225000,
"cashFlow":50000,
"brokerLicencing":"TREC Broker #516788",
"established":1941,
"realEstateIncluded":false
}
]

View File

@@ -0,0 +1,14 @@
[{
"id":"1",
"userId":"e0811669-c7eb-4e5e-a699-e8334d5c5b01",
"level":"Business Broker",
"start":"2024-02-12T21:54:20.603Z",
"modified":"2024-02-12T21:54:20.603Z",
"end":"9999-02-12T21:54:20.603Z",
"status":"active",
"invoices":[{
"date":"2024-02-12T21:54:20.603Z",
"id":"C991853B99",
"price":0
}]
}]

View File

@@ -0,0 +1,29 @@
import { Injectable } from '@nestjs/common';
import { fstat, readFileSync } from 'fs';
import { join } from 'path';
import { fileURLToPath } from 'url';
import path from 'path';
import fs from 'fs-extra';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
@Injectable()
export class FileService {
private subscriptions: any;
constructor() {
this.loadSubscriptions();
}
private loadSubscriptions(): void {
const filePath = join(__dirname,'..', 'assets', 'subscriptions.json');
const rawData = readFileSync(filePath, 'utf8');
this.subscriptions = JSON.parse(rawData);
}
getSubscriptions() {
return this.subscriptions
}
async storeFile(file: Express.Multer.File,id: string){
const suffix = file.mimetype.includes('png')?'png':'jpg'
await fs.outputFile(`./public/profile_${id}`,file.buffer);
}
}

View File

@@ -0,0 +1,59 @@
import { Body, Controller, Delete, Get, Inject, Param, Post, Put } from '@nestjs/common';
import { FileService } from '../file/file.service.js';
import { convertStringToNullUndefined } from '../utils.js';
import { RedisService } from '../redis/redis.service.js';
import { ListingsService } from './listings.service.js';
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
import { Logger } from 'winston';
@Controller('listings')
export class ListingsController {
// private readonly logger = new Logger(ListingsController.name);
constructor(private readonly listingsService:ListingsService,@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger) {
}
@Get()
findAll(): any {
return this.listingsService.getAllListings();
}
@Get(':id')
findById(@Param('id') id:string): any {
return this.listingsService.getListingById(id);
}
// @Get(':type/:location/:minPrice/:maxPrice/:realEstateChecked')
// find(@Param('type') type:string,@Param('location') location:string,@Param('minPrice') minPrice:string,@Param('maxPrice') maxPrice:string,@Param('realEstateChecked') realEstateChecked:boolean): any {
// return this.listingsService.find(type,location,minPrice,maxPrice,realEstateChecked);
// }
@Post('search')
find(@Body() criteria: any): any {
return this.listingsService.find(criteria);
}
/**
* @param listing updates a new listing
*/
@Put(':id')
updateById(@Param('id') id:string, @Body() listing: any){
this.logger.info(`Update by ID: ${id}`);
this.listingsService.setListing(listing,id)
}
/**
* @param listing creates a new listing
*/
@Post()
create(@Body() listing: any){
this.logger.info(`Create Listing`);
this.listingsService.setListing(listing)
}
/**
* @param id deletes a listing
*/
@Delete(':id')
deleteById(@Param('id') id:string){
this.listingsService.deleteListing(id)
}
}

View File

@@ -0,0 +1,86 @@
import { Inject, Injectable } from '@nestjs/common';
import {
BusinessListing,
InvestmentsListing,
ListingCriteria,
ProfessionalsBrokersListing,
} from '../models/main.model.js';
import { LISTINGS, RedisService } from '../redis/redis.service.js';
import { convertStringToNullUndefined } from '../utils.js';
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
import { Logger } from 'winston';
@Injectable()
export class ListingsService {
// private readonly logger = new Logger(ListingsService.name);
constructor(private redisService: RedisService,@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger) {}
async setListing(
value: BusinessListing | ProfessionalsBrokersListing | InvestmentsListing,
id?: string,
) {
if (!id) {
id = await this.redisService.getId(LISTINGS);
value.id = id;
this.logger.info(`No ID - creating new one:${id}`)
} else {
this.logger.info(`ID available:${id}`)
}
this.redisService.setJson(id, value);
}
async getListingById(id: string) {
return await this.redisService.getJson(id, LISTINGS);
}
deleteListing(id: string){
this.redisService.delete(id);
this.logger.info(`delete listing with ID:${id}`)
}
async getAllListings(start?: number, end?: number) {
const searchResult = await this.redisService.search(LISTINGS, '*');
const listings = searchResult.slice(1).reduce((acc, item, index, array) => {
// Jedes zweite Element (beginnend mit dem ersten) ist ein JSON-String des Listings
if (index % 2 === 1) {
try {
const listing = JSON.parse(item[1]); // Parsen des JSON-Strings
acc.push(listing);
} catch (error) {
console.error('Fehler beim Parsen des JSON-Strings: ', error);
}
}
return acc;
}, []);
return listings;
}
//criteria.type,criteria.location,criteria.minPrice,criteria.maxPrice,criteria.realEstateChecked,criteria.listingsCategory
//async find(type:string,location:string,minPrice:string,maxPrice:string,realEstateChecked:boolean,listingsCategory:string): Promise<any> {
async find(criteria:ListingCriteria): Promise<any> {
let listings = await this.getAllListings();
listings=listings.filter(l=>l.listingsCategory===criteria.listingsCategory);
if (convertStringToNullUndefined(criteria.type)){
console.log(criteria.type);
listings=listings.filter(l=>l.type===criteria.type);
}
if (convertStringToNullUndefined(criteria.location)){
console.log(criteria.location);
listings=listings.filter(l=>l.location===criteria.location);
}
if (convertStringToNullUndefined(criteria.minPrice)){
console.log(criteria.minPrice);
listings=listings.filter(l=>l.price>=Number(criteria.minPrice));
}
if (convertStringToNullUndefined(criteria.maxPrice)){
console.log(criteria.maxPrice);
listings=listings.filter(l=>l.price<=Number(criteria.maxPrice));
}
if (convertStringToNullUndefined(criteria.realEstateChecked)){
console.log(criteria.realEstateChecked);
listings=listings.filter(l=>l.realEstateIncluded);
}
if (convertStringToNullUndefined(criteria.category)){
console.log(criteria.category);
listings=listings.filter(l=>l.category===criteria.category);
}
return listings
}
}

View File

@@ -0,0 +1,14 @@
import { Body, Controller, Get, Param, Post } from '@nestjs/common';
import { MailService } from './mail.service.js';
import { MailInfo } from '../models/server.model.js';
@Controller('mail')
export class MailController {
constructor(private mailService:MailService){
}
@Post(':id')
sendEMail(@Param('id') id:string,@Body() mailInfo: MailInfo): any {
return this.mailService.sendInquiry(id,mailInfo);
}
}

View File

@@ -0,0 +1,40 @@
import { Module } from '@nestjs/common';
import { MailService } from './mail.service.js';
import { MailController } from './mail.controller.js';
import { MailerModule } from '@nestjs-modules/mailer';
import path, { join } from 'path';
import { HandlebarsAdapter } from '@nestjs-modules/mailer/dist/adapters/handlebars.adapter.js';
import { fileURLToPath } from 'url';
import { AuthModule } from '../auth/auth.module.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
@Module({
imports: [AuthModule,
MailerModule.forRoot({
// transport: 'smtps://user@example.com:topsecret@smtp.example.com',
// or
transport: {
host: 'smtp.gmail.com',
secure: true,
auth: {
user: 'andreas.knuth@gmail.com',
pass: 'ksnh xjae dqbv xana',
},
},
defaults: {
from: '"No Reply" <noreply@example.com>',
},
template: {
dir: join(__dirname, 'templates'),
adapter: new HandlebarsAdapter(), // or new PugAdapter() or new EjsAdapter()
options: {
strict: true,
},
},
}),
],
providers: [MailService],
controllers: [MailController]
})
export class MailModule {}

View File

@@ -0,0 +1,24 @@
import { MailerService } from '@nestjs-modules/mailer';
import { Injectable } from '@nestjs/common';
import { AuthService } from '../auth/auth.service.js';
import { MailInfo } from '../models/server.model.js';
import { User } from 'src/models/main.model.js';
@Injectable()
export class MailService {
constructor(private mailerService: MailerService, private authService:AuthService) {}
async sendInquiry(userId:string,mailInfo: MailInfo) {
const user = await this.authService.getUser(userId) as User;
await this.mailerService.sendMail({
to: user.email,
from: '"Bizmatch Team" <info@bizmatch.net>', // override default from
subject: `Inquiry from ${mailInfo.sender.name}`,
template: './inquiry', // `.hbs` extension is appended automatically
context: { // ✏️ filling curly brackets with content
name: user.firstname,
inquiry:mailInfo.sender.comments
},
});
}
}

View File

@@ -0,0 +1,5 @@
<p>Hey {{ name }},</p>
<p>You got an inquiry a</p>
<p>
{{inquiry}}
</p>

View File

@@ -0,0 +1,15 @@
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module.js';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.setGlobalPrefix('bizmatch');
app.enableCors({
origin: '*',
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
allowedHeaders: 'Content-Type, Accept',
});
//origin: 'http://localhost:4200',
await app.listen(3000);
}
bootstrap();

View File

View File

@@ -0,0 +1,11 @@
export interface MailInfo {
sender:Sender;
userId:string;
}
export interface Sender {
name:string;
email:string;
phoneNumber:string;
state:string;
comments:string;
}

View File

@@ -0,0 +1,18 @@
import { Body, Controller, Get, HttpStatus, Param, Post, Res } from '@nestjs/common';
import { Response } from 'express';
import { RedisService } from './redis.service.js';
@Controller('redis')
export class RedisController {
constructor(private redisService:RedisService){}
// @Get(':id')
// getById(@Param('id') id:string){
// return this.redisService.getListingById(id);
// }
// @Post(':id')
// updateById(@Body() listing: any){
// this.redisService.setListing(listing);
// }
}

View File

@@ -0,0 +1,16 @@
// redis.module.ts
import { Module } from '@nestjs/common';
@Module({
providers: [RedisService],
exports: [RedisService],
controllers: [RedisController],
})
export class RedisModule {}
// redis.service.ts
import { Injectable } from '@nestjs/common';
import { RedisService } from './redis.service.js';
import { RedisController } from './redis.controller.js';

View File

@@ -0,0 +1,39 @@
// redis.service.ts
import { Injectable } from '@nestjs/common';
import { Redis } from 'ioredis';
import { BusinessListing, InvestmentsListing,ProfessionalsBrokersListing } from '../models/main.model.js';
export const LISTINGS = 'LISTINGS';
export const SUBSCRIPTIONS = 'SUBSCRIPTIONS';
export const USERS = 'USERS'
@Injectable()
export class RedisService {
private redis = new Redis(); // Verbindungsparameter nach Bedarf anpassen
// ######################################
// general methods
// ######################################
async setJson(id: string, value: any): Promise<void> {
await this.redis.call("JSON.SET", `${LISTINGS}:${id}`, "$", JSON.stringify(value));
}
async delete(id: string): Promise<void> {
await this.redis.del(`${LISTINGS}:${id}`);
}
async getJson(id: string, prefix:string): Promise<any> {
const result:string = await this.redis.call("JSON.GET", `${prefix}:${id}`) as string;
return JSON.parse(result);
}
async getId(prefix:'LISTINGS'|'SUBSCRIPTIONS'|'USERS'):Promise<string>{
const counter = await this.redis.call("INCR",`${prefix}_ID_COUNTER`) as number;
return counter.toString().padStart(15, '0')
}
async search(prefix:'LISTINGS'|'SUBSCRIPTIONS'|'USERS',clause:string):Promise<any>{
const result = await this.redis.call(`FT.SEARCH`, `${prefix}_INDEX`, `${clause}`, 'LIMIT', 0, 200);
return result;
}
}

View File

@@ -0,0 +1,17 @@
import { Controller, Get } from '@nestjs/common';
import { SelectOptionsService } from './select-options.service.js';
@Controller('select-options')
export class SelectOptionsController {
constructor(private selectOptionsService:SelectOptionsService){}
@Get()
getSelectOption():any{
return {
typesOfBusiness:this.selectOptionsService.typesOfBusiness,
prices:this.selectOptionsService.prices,
listingCategories:this.selectOptionsService.listingCategories,
categories:this.selectOptionsService.categories,
locations:this.selectOptionsService.locations,
}
}
}

View File

@@ -0,0 +1,102 @@
import { Injectable } from '@nestjs/common';
import { KeyValue, KeyValueStyle } from '../models/main.model.js';
@Injectable()
export class SelectOptionsService {
constructor() { }
public typesOfBusiness: Array<KeyValueStyle> = [
{ name: 'Automotive', value: '1', icon:'fa-solid fa-car',bgColorClass:'bg-green-100',textColorClass:'text-green-600' },
{ name: 'Industrial Services', value: '2', icon:'fa-solid fa-industry',bgColorClass:'bg-yellow-100',textColorClass:'text-yellow-600'},
{ name: 'Real Estate', value: '3' , icon:'pi pi-building',bgColorClass:'bg-blue-100',textColorClass:'text-blue-600'},
{ name: 'Uncategorized', value: '4' , icon:'pi pi-question',bgColorClass:'bg-cyan-100',textColorClass:'text-cyan-600'},
{ name: 'Retail', value: '5' , icon:'fa-solid fa-money-bill-wave',bgColorClass:'bg-pink-100',textColorClass:'text-pink-600'},
{ name: 'Oilfield SVE and MFG.', value: '6' , icon:'fa-solid fa-oil-well',bgColorClass:'bg-indigo-100',textColorClass:'text-indigo-600'},
{ name: 'Service', value: '7' , icon:'fa-solid fa-umbrella',bgColorClass:'bg-teal-100',textColorClass:'text-teal-600'},
{ name: 'Advertising', value: '8' , icon:'fa-solid fa-rectangle-ad',bgColorClass:'bg-orange-100',textColorClass:'text-orange-600'},
{ name: 'Agriculture', value: '9' , icon:'fa-solid fa-wheat-awn',bgColorClass:'bg-bluegray-100',textColorClass:'text-bluegray-600'},
{ name: 'Franchise', value: '10' , icon:'pi pi-star',bgColorClass:'bg-purple-100',textColorClass:'text-purple-600'},
{ name: 'Professional', value: '11' , icon:'fa-solid fa-user-gear',bgColorClass:'bg-gray-100',textColorClass:'text-gray-600'},
{ name: 'Manufacturing', value: '12' , icon:'fa-solid fa-industry',bgColorClass:'bg-red-100',textColorClass:'text-red-600'},
{ name: 'Food and Restaurant', value: '13' , icon:'fa-solid fa-utensils',bgColorClass:'bg-primary-100',textColorClass:'text-primary-600'},
];
public prices: Array<KeyValue> = [
{ name: '$100K', value: '100000' },
{ name: '$250K', value: '250000' },
{ name: '$500K', value: '500000' },
{ name: '$1M', value: '1000000' },
{ name: '$5M', value: '5000000' },
];
public listingCategories: Array<KeyValue> = [
{ name: 'Business', value: 'business' },
{ name: 'Professionals/Brokers Directory', value: 'professionals_brokers' },
{ name: 'Investment Property', value: 'investment' },
]
public categories: Array<KeyValueStyle> = [
{ name: 'Broker', value: 'broker', icon:'pi-image',bgColorClass:'bg-green-100',textColorClass:'text-green-600' },
{ name: 'Professional', value: 'professional', icon:'pi-globe',bgColorClass:'bg-yellow-100',textColorClass:'text-yellow-600' },
]
private usStates = [
{ name: 'ALABAMA', abbreviation: 'AL'},
{ name: 'ALASKA', abbreviation: 'AK'},
{ name: 'AMERICAN SAMOA', abbreviation: 'AS'},
{ name: 'ARIZONA', abbreviation: 'AZ'},
{ name: 'ARKANSAS', abbreviation: 'AR'},
{ name: 'CALIFORNIA', abbreviation: 'CA'},
{ name: 'COLORADO', abbreviation: 'CO'},
{ name: 'CONNECTICUT', abbreviation: 'CT'},
{ name: 'DELAWARE', abbreviation: 'DE'},
{ name: 'DISTRICT OF COLUMBIA', abbreviation: 'DC'},
{ name: 'FEDERATED STATES OF MICRONESIA', abbreviation: 'FM'},
{ name: 'FLORIDA', abbreviation: 'FL'},
{ name: 'GEORGIA', abbreviation: 'GA'},
{ name: 'GUAM', abbreviation: 'GU'},
{ name: 'HAWAII', abbreviation: 'HI'},
{ name: 'IDAHO', abbreviation: 'ID'},
{ name: 'ILLINOIS', abbreviation: 'IL'},
{ name: 'INDIANA', abbreviation: 'IN'},
{ name: 'IOWA', abbreviation: 'IA'},
{ name: 'KANSAS', abbreviation: 'KS'},
{ name: 'KENTUCKY', abbreviation: 'KY'},
{ name: 'LOUISIANA', abbreviation: 'LA'},
{ name: 'MAINE', abbreviation: 'ME'},
{ name: 'MARSHALL ISLANDS', abbreviation: 'MH'},
{ name: 'MARYLAND', abbreviation: 'MD'},
{ name: 'MASSACHUSETTS', abbreviation: 'MA'},
{ name: 'MICHIGAN', abbreviation: 'MI'},
{ name: 'MINNESOTA', abbreviation: 'MN'},
{ name: 'MISSISSIPPI', abbreviation: 'MS'},
{ name: 'MISSOURI', abbreviation: 'MO'},
{ name: 'MONTANA', abbreviation: 'MT'},
{ name: 'NEBRASKA', abbreviation: 'NE'},
{ name: 'NEVADA', abbreviation: 'NV'},
{ name: 'NEW HAMPSHIRE', abbreviation: 'NH'},
{ name: 'NEW JERSEY', abbreviation: 'NJ'},
{ name: 'NEW MEXICO', abbreviation: 'NM'},
{ name: 'NEW YORK', abbreviation: 'NY'},
{ name: 'NORTH CAROLINA', abbreviation: 'NC'},
{ name: 'NORTH DAKOTA', abbreviation: 'ND'},
{ name: 'NORTHERN MARIANA ISLANDS', abbreviation: 'MP'},
{ name: 'OHIO', abbreviation: 'OH'},
{ name: 'OKLAHOMA', abbreviation: 'OK'},
{ name: 'OREGON', abbreviation: 'OR'},
{ name: 'PALAU', abbreviation: 'PW'},
{ name: 'PENNSYLVANIA', abbreviation: 'PA'},
{ name: 'PUERTO RICO', abbreviation: 'PR'},
{ name: 'RHODE ISLAND', abbreviation: 'RI'},
{ name: 'SOUTH CAROLINA', abbreviation: 'SC'},
{ name: 'SOUTH DAKOTA', abbreviation: 'SD'},
{ name: 'TENNESSEE', abbreviation: 'TN'},
{ name: 'TEXAS', abbreviation: 'TX'},
{ name: 'UTAH', abbreviation: 'UT'},
{ name: 'VERMONT', abbreviation: 'VT'},
{ name: 'VIRGIN ISLANDS', abbreviation: 'VI'},
{ name: 'VIRGINIA', abbreviation: 'VA'},
{ name: 'WASHINGTON', abbreviation: 'WA'},
{ name: 'WEST VIRGINIA', abbreviation: 'WV'},
{ name: 'WISCONSIN', abbreviation: 'WI'},
{ name: 'WYOMING', abbreviation: 'WY' }
]
public locations:Array<any> = [...this.usStates.map(state=>({name:state.name, value:state.abbreviation}))].concat({name:'CANADA',value:"CA"});
}

View File

@@ -0,0 +1,12 @@
import { Controller, Get } from '@nestjs/common';
import { FileService } from '../file/file.service.js';
@Controller('subscriptions')
export class SubscriptionsController {
constructor(private readonly fileService: FileService){}
@Get()
findAll(): any {
return this.fileService.getSubscriptions();
}
}

View File

@@ -0,0 +1,13 @@
export function convertStringToNullUndefined(value) {
// Konvertiert den Wert zu Kleinbuchstaben für eine case-insensitive Überprüfung
const lowerCaseValue = typeof value === 'boolean' ? value : value?.toLowerCase();
if (lowerCaseValue === 'null') {
return null;
} else if (lowerCaseValue === 'undefined') {
return undefined;
}
// Gibt den Originalwert zurück, wenn es sich nicht um 'null' oder 'undefined' handelt
return value;
}