mirror of
http://172.20.10.11:3000/gitadmin/INSIGHT-MVP.git
synced 2026-06-25 01:36:39 +02:00
Adds complete Lexware Office integration to CRM service: - Rate-limited HTTP client (Token Bucket, 2 req/s) - Bidirectional contact sync (manual import + ERP-push) - Voucher caching (quotes, orders, invoices, credit notes) - Deal-voucher linking (m:n join table with audit) - Cron jobs: voucher refresh (4h), ERP push (30min) - Distributed locks via Redis for job deduplication - Health check extended with Lexware status - Prisma schema: LexwareVoucher, DealVoucher, VoucherType enum - Companies/Contacts/Deals services extended with Lexware data Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
71 lines
1.3 KiB
TypeScript
71 lines
1.3 KiB
TypeScript
import { plainToInstance } from 'class-transformer';
|
|
import { IsString, IsNumber, IsOptional, validateSync } from 'class-validator';
|
|
|
|
export class EnvironmentVariables {
|
|
@IsString()
|
|
DATABASE_URL!: string;
|
|
|
|
@IsString()
|
|
DATABASE_URL_DIRECT!: string;
|
|
|
|
@IsString()
|
|
@IsOptional()
|
|
REDIS_HOST?: string;
|
|
|
|
@IsNumber()
|
|
@IsOptional()
|
|
REDIS_PORT?: number;
|
|
|
|
@IsString()
|
|
@IsOptional()
|
|
REDIS_PASSWORD?: string;
|
|
|
|
@IsString()
|
|
@IsOptional()
|
|
JWT_PUBLIC_KEY_PATH?: string;
|
|
|
|
@IsString()
|
|
@IsOptional()
|
|
JWT_ISSUER?: string;
|
|
|
|
@IsNumber()
|
|
@IsOptional()
|
|
APP_PORT?: number;
|
|
|
|
@IsString()
|
|
@IsOptional()
|
|
NODE_ENV?: string;
|
|
|
|
@IsString()
|
|
@IsOptional()
|
|
CORS_ORIGINS?: string;
|
|
|
|
// Lexware Office Integration (optional)
|
|
@IsString()
|
|
@IsOptional()
|
|
LEXWARE_API_KEY?: string;
|
|
|
|
@IsString()
|
|
@IsOptional()
|
|
LEXWARE_API_URL?: string;
|
|
}
|
|
|
|
export function validate(
|
|
config: Record<string, unknown>,
|
|
): EnvironmentVariables {
|
|
const validatedConfig = plainToInstance(EnvironmentVariables, config, {
|
|
enableImplicitConversion: true,
|
|
});
|
|
|
|
const errors = validateSync(validatedConfig, {
|
|
skipMissingProperties: false,
|
|
});
|
|
|
|
if (errors.length > 0) {
|
|
throw new Error(
|
|
`Umgebungsvariablen-Validierung fehlgeschlagen:\n${errors.toString()}`,
|
|
);
|
|
}
|
|
|
|
return validatedConfig;
|
|
}
|