-
|
I am building a small frontend for my peer configs. I have also built a small admin dashboard along side it and I cannot get deleting peers working. From looking at the API docs, there use to be an endpoint for this (deletePeers), I no longer see an endpoint in the new API. My current attempts have been using the savePeerScheduleJob endpoint to create a job to delete the peer if the date is larger than the current date. I am successfully creating the job, but the jobs are never run. Unless I am missing something in my code, this is a scheduler issue, which I have no clue how to fix. Any and all help is appreciated. <3 Additional info: The complete delete peer function: export async function deletePeerConfig(id: string) {
const configToDelete = await db.peerConfig.findUnique({
where: { id },
select: {
name: true,
publicKey: true,
configuration: {
select: {
id: true,
name: true,
},
},
},
})
if (!configToDelete) {
throw new Error("Peer config not found")
}
const aLongLongTimeAgo = "2000-01-01 00:00:00"
const jobPayload = {
Job: {
JobID: `delete-peer-${configToDelete.name}:${id}`,
Configuration: configToDelete.configuration.name,
Peer: configToDelete.publicKey,
Field: "date",
Operator: "lgt",
Value: aLongLongTimeAgo,
CreationDate: "",
ExpireDate: "",
Action: "delete",
},
}
const requestOptions: RequestInit = {
method: "POST",
headers: {
"Content-Type": "application/json",
"wg-dashboard-apikey": env.WIREGUARD_API_KEY,
},
body: JSON.stringify(jobPayload),
}
const response = await fetch(
`${env.WIREGUARD_API_ENDPOINT}/savePeerScheduleJob`,
requestOptions,
)
if (!response.ok) {
throw new Error(`Failed to delete peer config: ${response.statusText}`)
}
await db.peerConfig.delete({
where: { id },
})
await db.configuration.delete({
where: { id: configToDelete.configuration.id },
})
return {
success: true,
message: "Peer config deleted successfully",
}
}The API response: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Hi! I'm sorry that I forgot to add the deletePeers endpoint back to the new API documentation, I just updated it should be here: https://documenter.getpostman.com/view/31393369/2sA3s7hnzU#a2ceda59-7d28-4133-809a-3eca67dd2e3c Regarding I will need to check that and get back to you :) |
Beta Was this translation helpful? Give feedback.
-
|
You are the goat, thank you!! I just tested my app with that endpoint and it works flawlessly. to like all the other endpoints show. |
Beta Was this translation helpful? Give feedback.
Hi! I'm sorry that I forgot to add the deletePeers endpoint back to the new API documentation, I just updated it should be here: https://documenter.getpostman.com/view/31393369/2sA3s7hnzU#a2ceda59-7d28-4133-809a-3eca67dd2e3c
Regarding I will need to check that and get back to you :)