mirror of
https://github.com/SrIzan10/helium.git
synced 2026-06-06 00:56:58 +00:00
31 lines
743 B
TypeScript
31 lines
743 B
TypeScript
import {
|
|
getPresetAuthorData,
|
|
getPresetById,
|
|
userHasPresetAccess,
|
|
} from "~/lib/utils/presetsDb";
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const { isAuthenticated, userId } = event.context.auth();
|
|
|
|
if (!isAuthenticated || !userId) {
|
|
throw createError({ statusCode: 401, statusMessage: "Unauthorized" });
|
|
}
|
|
|
|
const id = getRouterParam(event, "id");
|
|
if (!id) {
|
|
throw createError({ statusCode: 400, statusMessage: "Missing preset ID" });
|
|
}
|
|
|
|
const preset = await getPresetById(id);
|
|
if (!preset) {
|
|
throw createError({ statusCode: 404, statusMessage: "Preset not found" });
|
|
}
|
|
const author = await getPresetAuthorData(event, id);
|
|
|
|
return {
|
|
success: true,
|
|
data: preset,
|
|
author,
|
|
};
|
|
});
|