AeThex-OS/temp-forge-extract/aethex-forge-main/api/interests.ts
MrPiglr b3c308b2c8 Add functional marketplace modules, bottom nav bar, root terminal, arcade games
- ModuleManager: Central tracking for installed marketplace modules
- DataAnalyzerWidget: Real-time CPU/RAM/Battery/Storage widget (unlocked by Data Analyzer module)
- BottomNavBar: Navigation bar for Projects/Chat/Marketplace/Settings
- RootShell: Real root command execution utility
- TerminalActivity: Full root shell with neofetch, sysinfo, real Linux commands
- Terminal Pro module: Adds aliases (ll, la, h), command history
- ArcadeActivity + SnakeGame: Pixel Arcade module unlocks retro games
- fade_in/fade_out animations for smooth transitions
2026-02-18 22:03:50 -07:00

37 lines
1.3 KiB
TypeScript

import type { VercelRequest, VercelResponse } from "@vercel/node";
import { getAdminClient } from "./_supabase.js";
export default async function handler(req: VercelRequest, res: VercelResponse) {
if (req.method !== "POST")
return res.status(405).json({ error: "Method not allowed" });
const { user_id, interests } = (req.body || {}) as {
user_id?: string;
interests?: string[];
};
if (!user_id || !Array.isArray(interests))
return res.status(400).json({ error: "invalid payload" });
try {
const admin = getAdminClient();
const { error: delErr } = await admin
.from("user_interests")
.delete()
.eq("user_id", user_id);
if (delErr) return res.status(500).json({ error: delErr.message });
if (interests.length) {
const rows = interests.map((interest) => ({ user_id, interest }));
const { error } = await admin.from("user_interests").insert(rows);
if (error) return res.status(500).json({ error: error.message });
}
return res.json({ ok: true });
} catch (e: any) {
if (/SUPABASE_/.test(String(e?.message || ""))) {
return res
.status(500)
.json({ error: `Server misconfigured: ${e.message}` });
}
return res.status(500).json({ error: e?.message || String(e) });
}
}