Files
litlyx/dashboard/server/api/feedback/send.post.ts
2025-11-28 16:49:20 +01:00

18 lines
506 B
TypeScript

import { FeedbackModel } from "~/shared/schema/FeedbackSchema";
export default defineEventHandler(async event => {
if (isSelfhosted()) return;
const ctx = await getRequestContext(event, 'pid');
const { project_id, user_id } = ctx;
const { text } = await readBody(event);
if (!text || typeof text != 'string' || text.length == 0) {
throw createError({ status: 400, message: 'Something went wrong.' })
}
await FeedbackModel.create({ project_id, user_id, text })
});