chore: remove Directus CMS and related dependencies
All checks were successful
Monorepo Pipeline / ⚡ Prioritize Release (push) Successful in 3s
Monorepo Pipeline / 🧹 Lint (push) Successful in 1m19s
Monorepo Pipeline / 🧪 Test (push) Successful in 1m5s
Monorepo Pipeline / 🏗️ Build (push) Successful in 1m26s
Monorepo Pipeline / 🚀 Release (push) Has been skipped
Monorepo Pipeline / 🐳 Build Image Processor (push) Has been skipped
Monorepo Pipeline / 🐳 Build Directus (Base) (push) Has been skipped
Monorepo Pipeline / 🐳 Build Gatekeeper (Product) (push) Has been skipped
Monorepo Pipeline / 🐳 Build Build-Base (push) Has been skipped
Monorepo Pipeline / 🐳 Build Production Runtime (push) Has been skipped
All checks were successful
Monorepo Pipeline / ⚡ Prioritize Release (push) Successful in 3s
Monorepo Pipeline / 🧹 Lint (push) Successful in 1m19s
Monorepo Pipeline / 🧪 Test (push) Successful in 1m5s
Monorepo Pipeline / 🏗️ Build (push) Successful in 1m26s
Monorepo Pipeline / 🚀 Release (push) Has been skipped
Monorepo Pipeline / 🐳 Build Image Processor (push) Has been skipped
Monorepo Pipeline / 🐳 Build Directus (Base) (push) Has been skipped
Monorepo Pipeline / 🐳 Build Gatekeeper (Product) (push) Has been skipped
Monorepo Pipeline / 🐳 Build Build-Base (push) Has been skipped
Monorepo Pipeline / 🐳 Build Production Runtime (push) Has been skipped
This commit is contained in:
@@ -1,105 +1,24 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import {
|
||||
createDirectus,
|
||||
rest,
|
||||
staticToken,
|
||||
createItem,
|
||||
readItems,
|
||||
} from "@directus/sdk";
|
||||
|
||||
export interface CMSConfig {
|
||||
url: string;
|
||||
token: string;
|
||||
}
|
||||
|
||||
export function createCMSClient(config: CMSConfig) {
|
||||
return createDirectus(config.url)
|
||||
.with(staticToken(config.token))
|
||||
.with(rest());
|
||||
}
|
||||
|
||||
export async function handleFeedbackRequest(
|
||||
req: NextRequest,
|
||||
config: CMSConfig,
|
||||
_config: CMSConfig,
|
||||
) {
|
||||
const client = createCMSClient(config);
|
||||
|
||||
// Feedback functionality has been disabled as Directus was removed
|
||||
if (req.method === "GET") {
|
||||
try {
|
||||
const items = await client.request(
|
||||
readItems("visual_feedback", {
|
||||
fields: ["*", { comments: ["*"] }],
|
||||
sort: ["-date_created"],
|
||||
}),
|
||||
);
|
||||
return NextResponse.json(items);
|
||||
} catch (error: any) {
|
||||
return NextResponse.json({ error: error.message }, { status: 500 });
|
||||
}
|
||||
return NextResponse.json([]);
|
||||
}
|
||||
|
||||
if (req.method === "POST") {
|
||||
try {
|
||||
const body = await req.json();
|
||||
const { action, screenshot_base64, ...data } = body;
|
||||
|
||||
if (action === "reply") {
|
||||
const reply = await client.request(
|
||||
createItem("visual_feedback_comments", {
|
||||
feedback_id: data.feedbackId,
|
||||
user_name: data.userName,
|
||||
text: data.text,
|
||||
}),
|
||||
);
|
||||
return NextResponse.json(reply);
|
||||
}
|
||||
|
||||
let screenshotId = null;
|
||||
|
||||
if (screenshot_base64) {
|
||||
try {
|
||||
const base64Data = screenshot_base64.split(";base64,").pop();
|
||||
const buffer = Buffer.from(base64Data, "base64");
|
||||
const formData = new FormData();
|
||||
const blob = new Blob([buffer], { type: "image/png" });
|
||||
formData.append("file", blob, `feedback-${Date.now()}.png`);
|
||||
|
||||
const fileRes = await fetch(`${config.url}/files`, {
|
||||
method: "POST",
|
||||
headers: { Authorization: `Bearer ${config.token}` },
|
||||
body: formData,
|
||||
});
|
||||
|
||||
if (fileRes.ok) {
|
||||
const fileData = await fileRes.json();
|
||||
screenshotId = fileData.data.id;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Failed to upload screenshot:", e);
|
||||
}
|
||||
}
|
||||
|
||||
const feedback = await client.request(
|
||||
createItem("visual_feedback", {
|
||||
project: data.project || req.headers.get("host") || "unknown",
|
||||
url: data.url,
|
||||
selector: data.selector,
|
||||
x: data.x,
|
||||
y: data.y,
|
||||
type: data.type,
|
||||
text: data.text,
|
||||
user_name: data.userName,
|
||||
user_identity: data.userIdentity,
|
||||
status: "open",
|
||||
screenshot: screenshotId,
|
||||
company: data.companyId,
|
||||
}),
|
||||
);
|
||||
|
||||
return NextResponse.json(feedback);
|
||||
} catch (error: any) {
|
||||
return NextResponse.json({ error: error.message }, { status: 500 });
|
||||
}
|
||||
return NextResponse.json(
|
||||
{ error: "Feedback system disabled" },
|
||||
{ status: 501 },
|
||||
);
|
||||
}
|
||||
|
||||
return NextResponse.json({ error: "Method not allowed" }, { status: 405 });
|
||||
|
||||
Reference in New Issue
Block a user