feat: extract shop from mp/shop — initial libreshop/shop
Some checks failed
Build and publish / build (push) Failing after 19s

Source moved verbatim from mp/shop/ on 2026-04-29; mp was the first
concrete adapter consuming the libreshop toolkit. Builds and publishes
git.librete.ch/libreshop/shop on every main / v* push via the standard
.gitea/workflows/build.yml shared across libreshop components.
This commit is contained in:
Michael Czechowski
2026-04-29 17:48:56 +02:00
commit 44107c0734
134 changed files with 19521 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
import { fetchCms } from "~/server/utils/cmsApi";
export default defineEventHandler(async (event) => {
const uuid = getRouterParam(event, "uuid");
if (!uuid) {
throw createError({ statusCode: 400, statusMessage: "Missing order UUID" });
}
return await fetchCms(`/orders/${uuid}/cart`);
});

View File

@@ -0,0 +1,15 @@
import { fetchCms } from "~/server/utils/cmsApi";
export default defineEventHandler(async (event) => {
const uuid = getRouterParam(event, "uuid");
if (!uuid) {
throw createError({ statusCode: 400, statusMessage: "Missing order UUID" });
}
const body = await readBody(event);
return await fetchCms(`/orders/${uuid}/cart`, {
method: "PUT",
body
});
});

View File

@@ -0,0 +1,20 @@
import { fetchCms } from "~/server/utils/cmsApi";
export default defineEventHandler(async (event) => {
const uuid = getRouterParam(event, "uuid");
const productId = getRouterParam(event, "productId");
const query = getQuery(event);
if (!uuid) {
throw createError({ statusCode: 400, statusMessage: "Missing order UUID" });
}
if (!productId) {
throw createError({ statusCode: 400, statusMessage: "Missing product ID" });
}
const count = query.count || 1;
return await fetchCms(`/orders/${uuid}/add-product/${productId}?count=${count}`, {
method: "PUT"
});
});

View File

@@ -0,0 +1,17 @@
import { fetchCms } from "~/server/utils/cmsApi";
export default defineEventHandler(async (event) => {
const uuid = getRouterParam(event, "uuid");
const paypalOrderId = getRouterParam(event, "paypalOrderId");
if (!uuid) {
throw createError({ statusCode: 400, statusMessage: "Missing order UUID" });
}
if (!paypalOrderId) {
throw createError({ statusCode: 400, statusMessage: "Missing PayPal order ID" });
}
return await fetchCms(`/orders/${uuid}/capture/${paypalOrderId}`, {
method: "POST"
});
});

View File

@@ -0,0 +1,16 @@
import { fetchCms } from "~/server/utils/cmsApi";
export default defineEventHandler(async (event) => {
const uuid = getRouterParam(event, "uuid");
const query = getQuery(event);
if (!uuid) {
throw createError({ statusCode: 400, statusMessage: "Missing order UUID" });
}
const returnUrl = query.returnUrl || "";
return await fetchCms(`/orders/${uuid}/checkout?returnUrl=${encodeURIComponent(String(returnUrl))}`, {
method: "POST"
});
});

View File

@@ -0,0 +1,20 @@
import { fetchCms } from "~/server/utils/cmsApi";
export default defineEventHandler(async (event) => {
const uuid = getRouterParam(event, "uuid");
const productId = getRouterParam(event, "productId");
const query = getQuery(event);
if (!uuid) {
throw createError({ statusCode: 400, statusMessage: "Missing order UUID" });
}
if (!productId) {
throw createError({ statusCode: 400, statusMessage: "Missing product ID" });
}
const count = query.count || 1;
return await fetchCms(`/orders/${uuid}/remove-product/${productId}?count=${count}`, {
method: "PUT"
});
});

View File

@@ -0,0 +1,5 @@
import { fetchCms } from "~/server/utils/cmsApi";
export default defineEventHandler(async () => {
return await fetchCms(`/orders/`, { method: "POST" });
});