feat: Phase 1 – Plattform-Grundgerüst (Docker, NestJS, React, Auth)
This commit is contained in:
37
apps/platform-frontend/src/lib/schemas.ts
Normal file
37
apps/platform-frontend/src/lib/schemas.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Globale Plattform-Rollen (muss zum Backend passen). */
|
||||
export const ROLE_NAMES = ['ADMIN', 'USER'] as const;
|
||||
export type RoleName = (typeof ROLE_NAMES)[number];
|
||||
|
||||
/** Öffentliche Benutzerdaten (API-Vertrag /api/v1/auth/me). */
|
||||
export const authUserSchema = z.object({
|
||||
id: z.string(),
|
||||
username: z.string(),
|
||||
email: z.string(),
|
||||
displayName: z.string(),
|
||||
role: z.enum(ROLE_NAMES),
|
||||
});
|
||||
export type AuthUser = z.infer<typeof authUserSchema>;
|
||||
|
||||
/** Login-Anfrage (Client-Validierung ist UX; Server validiert erneut). */
|
||||
export const loginSchema = z.object({
|
||||
username: z.string().trim().min(1, 'Benutzername ist erforderlich'),
|
||||
password: z.string().min(1, 'Passwort ist erforderlich'),
|
||||
});
|
||||
export type LoginDto = z.infer<typeof loginSchema>;
|
||||
|
||||
/** Health-Antwort (API-Vertrag /api/v1/health). */
|
||||
export const healthSchema = z.object({
|
||||
status: z.enum(['healthy', 'unhealthy']),
|
||||
version: z.string(),
|
||||
uptimeSeconds: z.number(),
|
||||
components: z.object({
|
||||
backend: z.enum(['healthy']),
|
||||
database: z.object({
|
||||
status: z.enum(['healthy', 'unhealthy']),
|
||||
latencyMs: z.number(),
|
||||
}),
|
||||
}),
|
||||
});
|
||||
export type Health = z.infer<typeof healthSchema>;
|
||||
Reference in New Issue
Block a user