first commit

This commit is contained in:
Beyhan Oğur
2026-04-26 22:18:17 +03:00
commit 7b2b27a42c
1660 changed files with 123050 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
// Proxy to backend POST /api/v1/auth/register (with Turnstile verification)
export default defineEventHandler(async (event) => {
const body = await readBody(event) as { turnstile_token?: string; email?: string; first_name?: string; last_name?: string; username?: string; password?: string };
const token = body.turnstile_token;
if (!token) {
throw createError({ statusCode: 422, statusMessage: 'Güvenlik doğrulaması gerekli.', message: 'Güvenlik doğrulaması gerekli.' });
}
const validation = await verifyTurnstileToken(token, event);
if (!validation.success) {
throw createError({ statusCode: 400, statusMessage: 'Güvenlik doğrulaması başarısız.', message: 'Güvenlik doğrulaması başarısız.' });
}
const config = useRuntimeConfig();
const publicConfig = config.public as Record<string, unknown>;
const API_BASE = config.public.BASE_API_URL || (publicConfig.NUXT_PUBLIC_API_BASE as string) || 'http://127.0.0.1:8080';
const res = await $fetch(`${API_BASE}/api/v1/auth/register`, {
method: 'POST',
body: {
email: body.email,
first_name: body.first_name,
last_name: body.last_name,
password: body.password,
username: body.username,
},
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
},
}).catch((e: unknown) => {
const err = e as { data?: { statusCode?: number }; statusCode?: number; data?: { message?: string }; message?: string; response?: { _data?: unknown } };
throw createError({
statusCode: err?.data?.statusCode ?? err?.statusCode ?? 400,
statusMessage: (err?.data && typeof err.data === 'object' && 'message' in err.data ? (err.data as { message?: string }).message : null) ?? err?.message ?? 'Registration failed',
data: err?.data ?? err?.response?._data,
});
});
return res;
});