new file: api/auth-login.ts

new file:   api/hello.ts
This commit is contained in:
MrPiglr 2025-12-23 22:21:05 +00:00
parent 106253255a
commit 0eddcc7d59
2 changed files with 34 additions and 0 deletions

28
api/auth-login.ts Normal file
View file

@ -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 });
}

6
api/hello.ts Normal file
View file

@ -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!' });
}