AeThex-OS/temp-forge-extract/aethex-forge-main/api/passport/project/[slug].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

98 lines
2.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 !== "GET") {
return res.status(405).json({ error: "Method not allowed" });
}
const { slug } = req.query;
if (!slug || typeof slug !== "string") {
return res.status(400).json({ error: "Project slug is required" });
}
try {
const admin = getAdminClient();
const projectFields = `
id,
title,
slug,
description,
user_id,
status,
image_url,
website,
technologies,
created_at,
updated_at
`;
// Try to look up project by slug first (case-insensitive)
let project: any = null;
try {
const result = await admin
.from("aethex_projects")
.select(projectFields)
.ilike("slug", `%${slug}%`)
.limit(1)
.single();
project = result.data;
} catch (e) {
// Continue to ID lookup
}
// If not found by slug, try by exact ID match
if (!project) {
try {
const result = await admin
.from("aethex_projects")
.select(projectFields)
.eq("id", slug)
.single();
project = result.data;
} catch (e) {
// Continue to error handling
}
}
if (!project) {
return res.status(404).json({ error: "Project not found" });
}
// Get project owner
let owner: any = null;
try {
const result = await admin
.from("user_profiles")
.select("id, username, full_name, avatar_url")
.eq("id", project.user_id)
.single();
owner = result.data;
} catch (e) {
// Owner may not exist or may be deleted
console.warn("[Passport Project] Could not find project owner:", e);
}
return res.status(200).json({
type: "project",
project,
owner: owner || null,
domain: req.headers.host || "",
});
} catch (error: any) {
console.error("[Passport Project Error]", error);
if (/SUPABASE_/.test(String(error?.message || ""))) {
return res.status(500).json({
error: `Server misconfigured: ${error.message}`,
});
}
return res.status(500).json({
error: error?.message || "Failed to load project",
});
}
}