add instance delete path
Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
parent
14fa48bd86
commit
9f4320a697
17
index.js
17
index.js
@ -9,6 +9,7 @@ var api = require("./package.json");
|
||||
|
||||
const {pveAPI, pveAPIToken, listenPort} = require("./vars.js");
|
||||
const { token } = require("morgan");
|
||||
const { response } = require("express");
|
||||
|
||||
const app = express();
|
||||
app.use(helmet());
|
||||
@ -123,6 +124,22 @@ app.post("/api/resources", async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
//app.post("/api/instance", async (req, res) => {});
|
||||
|
||||
app.delete("/api/instance", async (req, res) => {
|
||||
let vmpath = `/nodes/${req.body.node}/${req.body.type}/${req.body.vmid}`;
|
||||
|
||||
let auth = await checkAuth(req.cookies, vmpath);
|
||||
if (auth) {
|
||||
let result = await requestPVE(`${vmpath}`, "DELETE", req.cookies, null, pveAPIToken);
|
||||
result = await handleResponse(req.body.node, result);
|
||||
res.send({auth: auth, status: result.status, data: result.data.data});
|
||||
}
|
||||
else {
|
||||
res.send({auth: auth});
|
||||
}
|
||||
});
|
||||
|
||||
async function checkAuth (cookies, vmpath = null) {
|
||||
if (vmpath) {
|
||||
let result = await requestPVE(`/${vmpath}/config`, "GET", cookies);
|
||||
|
Loading…
Reference in New Issue
Block a user