feat: enhance API response handling and add new components for module management
Some checks failed
Workflow / ʦ TypeScript (push) Failing after 4m50s
Workflow / ⚫️ Test (push) Has been skipped

This commit is contained in:
T. Zehetbauer
2026-04-01 15:18:24 +02:00
parent f82a366a52
commit 7b078f298b
58 changed files with 1845 additions and 398 deletions

View File

@@ -12,7 +12,8 @@
"exports": {
"./actions": "./src/actions/index.ts",
"./safe-action": "./src/actions/safe-action-client.ts",
"./routes": "./src/routes/index.ts"
"./routes": "./src/routes/index.ts",
"./route-helpers": "./src/routes/api-helpers.ts"
},
"scripts": {
"clean": "git clean -xdf .turbo node_modules",

View File

@@ -0,0 +1,28 @@
import 'server-only';
import { NextResponse } from 'next/server';
import * as z from 'zod';
/**
* Shared Zod schemas for public API route validation.
*/
export const emailSchema = z.string().email('Ungültige E-Mail-Adresse');
export const requiredString = (fieldName: string) =>
z.string().min(1, `${fieldName} ist erforderlich`);
/**
* Create a success JSON response.
* Shape: { success: true, data: T }
*/
export function apiSuccess<T>(data: T, status = 200) {
return NextResponse.json({ success: true, data }, { status });
}
/**
* Create an error JSON response.
* Shape: { success: false, error: string }
*/
export function apiError(error: string, status = 400) {
return NextResponse.json({ success: false, error }, { status });
}