diverse änderungen

This commit is contained in:
marco committed 2026-11-05 15:16:54 +01:00
1 parent 3dc1ad623c
commit f51631100d
85 files changed
+1880 -56

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
import { BadRequestException } from '@nestjs/common';
import { parseMotorRequest } from './motor.dto';
import type { EndschalterDirection } from '../graphics/elements/types';
export function parseEndschalterRequest(input: unknown) {
if (!input || typeof input !== 'object' || Array.isArray(input)) {
throw new BadRequestException('Erwartet werden config und optional options');
}
const request = input as Record<string, unknown>;
const options = request.options === undefined ? {} : request.options;
if (typeof options !== 'object' || options === null || Array.isArray(options)) {
throw new BadRequestException('Endschalter-options muss ein Objekt sein');
}
const { direction = 'unten', ...colors } = options as Record<string, unknown>;
if (typeof direction !== 'string' || !['oben', 'unten', 'rechts', 'links'].includes(direction)) {
throw new BadRequestException('direction muss oben, unten, rechts oder links sein');
}
const parsed = parseMotorRequest({ ...request, options: colors });
return { config: parsed.config, options: { ...parsed.options, direction: direction as EndschalterDirection } };
}