wrapping some agent components.

This commit is contained in:
killian-larcher
2024-11-11 18:50:42 +01:00
parent 49e069c849
commit 09529fb701
23 changed files with 338 additions and 156 deletions
+47
View File
@@ -0,0 +1,47 @@
import {prisma} from "@/prisma";
import {NextResponse} from "next/server";
export async function POST(
request: Request,
{params}: { params: Promise<{ agentId: string }> }
) {
const agentId = (await params).agentId
const agent = await prisma.agent.findFirst({
where: {
id: agentId
}
})
if(!agent){
return NextResponse.json({error: "Agent not found"}, {status: 404})
}
await prisma.agent.update({
where: {
id: agent.id,
},
data: {
lastContact: new Date(),
}
});
const response = {
agent: {
id: agentId,
lastContact: agent.lastContact
},
backup: {
action: false,
cron : ""
},
restore: {
action: false,
file: ""
}
}
return Response.json({
message: response
})
}