chore: upload parte 1 - logica
DevSecOps Enterprise Pipeline / security-gate-and-deploy (push) Failing after 41s

This commit is contained in:
2026-06-01 15:35:53 +01:00
parent a63625d228
commit 9c14a19a87
127 changed files with 22255 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
import { NextRequest, NextResponse } from "next/server";
import { getDb } from "@/lib/db";
export async function PUT(
request: NextRequest,
{ params }: { params: Promise<{ id: string }> }
) {
const sql = getDb();
const { id } = await params;
const body = await request.json();
const { name, sku, description, version, status } = body;
const rows = await sql(
`UPDATE products SET
name = $1, sku = $2, description = $3, version = $4, status = $5, updated_at = NOW()
WHERE id = $6
RETURNING *`,
[name, sku, description || null, version || "1.0", status || "draft", Number(id)]
);
if (rows.length === 0) {
return NextResponse.json({ error: "Product not found" }, { status: 404 });
}
return NextResponse.json(rows[0]);
}
export async function DELETE(
_request: NextRequest,
{ params }: { params: Promise<{ id: string }> }
) {
const sql = getDb();
const { id } = await params;
await sql(`DELETE FROM products WHERE id = $1`, [Number(id)]);
return NextResponse.json({ success: true });
}
+37
View File
@@ -0,0 +1,37 @@
import { NextRequest, NextResponse } from "next/server";
import { getDb } from "@/lib/db";
export async function GET() {
const sql = getDb();
const rows = await sql(`
SELECT p.*,
COALESCE(bom.bom_count, 0) as bom_count,
COALESCE(bom.total_cost, 0) as total_cost
FROM products p
LEFT JOIN (
SELECT product_id,
COUNT(*) as bom_count,
SUM(bi.quantity * c.unit_price) as total_cost
FROM bom_items bi
JOIN components c ON bi.component_id = c.id
GROUP BY product_id
) bom ON p.id = bom.product_id
ORDER BY p.updated_at DESC
`);
return NextResponse.json(rows);
}
export async function POST(request: NextRequest) {
const sql = getDb();
const body = await request.json();
const { name, sku, description, version, status } = body;
const rows = await sql(
`INSERT INTO products (name, sku, description, version, status)
VALUES ($1, $2, $3, $4, $5)
RETURNING *`,
[name, sku, description || null, version || "1.0", status || "draft"]
);
return NextResponse.json(rows[0], { status: 201 });
}