From 0eddcc7d59e23348014839d85a15691b707da2c5 Mon Sep 17 00:00:00 2001 From: MrPiglr <31398225+MrPiglr@users.noreply.github.com> Date: Tue, 23 Dec 2025 22:21:05 +0000 Subject: [PATCH] new file: api/auth-login.ts new file: api/hello.ts --- api/auth-login.ts | 28 ++++++++++++++++++++++++++++ api/hello.ts | 6 ++++++ 2 files changed, 34 insertions(+) create mode 100644 api/auth-login.ts create mode 100644 api/hello.ts diff --git a/api/auth-login.ts b/api/auth-login.ts new file mode 100644 index 0000000..5adcecb --- /dev/null +++ b/api/auth-login.ts @@ -0,0 +1,28 @@ +// Vercel serverless function for /api/auth/login +import type { VercelRequest, VercelResponse } from '@vercel/node'; +import { loginSchema } from '../shared/schema.js'; +import { supabase } from '../server/supabase.js'; + +export default async function handler(req: VercelRequest, res: VercelResponse) { + if (req.method !== 'POST') { + res.status(405).json({ error: 'Method not allowed' }); + return; + } + + const result = loginSchema.safeParse(req.body); + if (!result.success) { + res.status(400).json({ error: 'Invalid email or password format' }); + return; + } + + const { email, password } = result.data; + const { data, error } = await supabase.auth.signInWithPassword({ email, password }); + + if (error || !data.user) { + res.status(401).json({ error: error?.message || 'Invalid credentials' }); + return; + } + + // You may want to set a cookie or return a token here for client auth + res.status(200).json({ user: data.user }); +} diff --git a/api/hello.ts b/api/hello.ts new file mode 100644 index 0000000..8522d90 --- /dev/null +++ b/api/hello.ts @@ -0,0 +1,6 @@ +// Basic Vercel serverless function example for AeThex-OS +import type { VercelRequest, VercelResponse } from '@vercel/node'; + +export default function handler(req: VercelRequest, res: VercelResponse) { + res.status(200).json({ message: 'Hello from AeThex-OS API!' }); +}