feat: extract shop from mp/shop — initial libreshop/shop
Some checks failed
Build and publish / build (push) Failing after 19s
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:
10
server/api/orders/[uuid].get.ts
Normal file
10
server/api/orders/[uuid].get.ts
Normal 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`);
|
||||
});
|
||||
15
server/api/orders/[uuid].put.ts
Normal file
15
server/api/orders/[uuid].put.ts
Normal 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
|
||||
});
|
||||
});
|
||||
20
server/api/orders/[uuid]/add-product/[productId].put.ts
Normal file
20
server/api/orders/[uuid]/add-product/[productId].put.ts
Normal 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"
|
||||
});
|
||||
});
|
||||
17
server/api/orders/[uuid]/capture/[paypalOrderId].post.ts
Normal file
17
server/api/orders/[uuid]/capture/[paypalOrderId].post.ts
Normal 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"
|
||||
});
|
||||
});
|
||||
16
server/api/orders/[uuid]/checkout.post.ts
Normal file
16
server/api/orders/[uuid]/checkout.post.ts
Normal 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"
|
||||
});
|
||||
});
|
||||
20
server/api/orders/[uuid]/remove-product/[productId].put.ts
Normal file
20
server/api/orders/[uuid]/remove-product/[productId].put.ts
Normal 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"
|
||||
});
|
||||
});
|
||||
5
server/api/orders/index.post.ts
Normal file
5
server/api/orders/index.post.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { fetchCms } from "~/server/utils/cmsApi";
|
||||
|
||||
export default defineEventHandler(async () => {
|
||||
return await fetchCms(`/orders/`, { method: "POST" });
|
||||
});
|
||||
Reference in New Issue
Block a user