Liesten ProCon

This commit is contained in:
marco committed 2026-10-27 10:23:39 +01:00
1 parent 4bfd5d9bf7
commit f43053d7b3
102 files changed
+2376 -86

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
import { BadRequestException } from '@nestjs/common';
export type AnlageDurminConfig = Record<string, never>;
export type AnlageDurminOptions = Record<string, never>;
export function parseAnlageDurminRequest(input: unknown): { config: AnlageDurminConfig; options: AnlageDurminOptions } {
const object = (value: unknown): value is Record<string, unknown> => !!value && typeof value === 'object' && !Array.isArray(value);
if (!object(input) || Object.keys(input).some(key => !['config', 'options'].includes(key)) ||
!object(input.config) || Object.keys(input.config).length ||
(input.options !== undefined && (!object(input.options) || Object.keys(input.options).length)))
throw new BadRequestException('AnlageDurmin erwartet config: {} und optional options: {}; die Hintergrundgeometrie ist fest');
return { config: {}, options: {} };
}
+20
View File
@@ -0,0 +1,20 @@
import { BadRequestException } from '@nestjs/common';
import type { FahrwagenConfig, FahrwagenOptions } from '../graphics/elements/types';
export function parseFahrwagenObenRequest(input: unknown): { config: FahrwagenConfig; options: FahrwagenOptions } {
const object = (value: unknown): value is Record<string, unknown> => !!value && typeof value === 'object' && !Array.isArray(value);
if (!object(input) || Object.keys(input).some(key => !['config', 'options'].includes(key)) || !object(input.config))
throw new BadRequestException('Erwartet werden config und optional options');
const { config } = input;
if (Object.keys(config).some(key => !['length', 'width'].includes(key)) ||
[config.length, config.width].some(value => typeof value !== 'number' || !Number.isFinite(value) || value <= 0))
throw new BadRequestException('length und width müssen positive endliche Zahlen sein');
const options = input.options === undefined ? {} : input.options;
if (!object(options) || Object.entries(options).some(([key, value]) => key === 'fromNorthToSouth' ? typeof value !== 'boolean'
: key === 'fill' ? typeof value !== 'string' || (value !== 'none' && !/^#[0-9a-fA-F]{6}$/.test(value)) : true))
throw new BadRequestException('options erlaubt fromNorthToSouth als Boolean und fill als Hexfarbe #RRGGBB oder none');
return { config: { length: config.length as number, width: config.width as number }, options: {
fromNorthToSouth: options.fromNorthToSouth as boolean ?? false,
fill: '#808080',
} };
}