import { redirect, type Actions, type ServerLoad } from '@sveltejs/kit'; import { registerApiAuthRegisterPost } from '../../client/sdk.gen.ts'; export const load: ServerLoad = async ({ locals }) => { if (locals.authToken) redirect(307, '/app'); return {}; }; export const actions = { default: async ({ request }) => { const data = await request.formData(); const email = data.get('email') as string; const password = data.get('password') as string; const { response, data: body } = await registerApiAuthRegisterPost({ body: { email, password } }); if (response.status === 201 && body?.success) { return { success: true }; } return { success: false, error: body?.error_message ?? 'Registration failed. Please try again.' }; } } satisfies Actions;