feat: Initialize Next.js project with Prisma, Tailwind CSS, and API routes for device management and testing.

This commit is contained in:
2025-12-22 22:21:27 -05:00
commit 2e415d1897
33 changed files with 8222 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
import { NextResponse } from "next/server";
import { prisma } from "@/lib/prisma";
export async function POST(req: Request) {
try {
const { serialNumber, macAddress } = await req.json();
if (!serialNumber || !macAddress) {
return NextResponse.json(
{ error: "Serial number and MAC address are required" },
{ status: 400 }
);
}
// Check if device already exists
let device = await prisma.device.findFirst({
where: {
OR: [
{ serialNumber },
{ macAddress }
]
}
});
if (!device) {
// Register as pending
device = await prisma.device.create({
data: {
serialNumber,
macAddress,
status: "PENDING",
},
});
}
return NextResponse.json(device);
} catch (error) {
console.error("Registration error:", error);
return NextResponse.json(
{ error: "Internal Server Error" },
{ status: 500 }
);
}
}