major rework of backend loading and usage:
- split config from user data to config.json, add config.hson.template - moved default user data localdb to root folder - moved pve, localdb, ldap backend handlers to backends sub folder - add dynamic loading of all backends - add dynamic mapping for auth backends to support multiple auth sources - update affected endpoints
This commit is contained in:
+3
-6
@@ -1,11 +1,8 @@
|
||||
import { Router } from "express";
|
||||
export const router = Router({ mergeParams: true }); ;
|
||||
|
||||
const db = global.db;
|
||||
const requestPVE = global.pve.requestPVE;
|
||||
const checkAuth = global.utils.checkAuth;
|
||||
const getUserResources = global.utils.getUserResources;
|
||||
const pveAPIToken = global.db.pveAPIToken;
|
||||
|
||||
/**
|
||||
* GET - get db user resource information including allocated, free, and maximum resource values along with resource metadata
|
||||
@@ -43,7 +40,7 @@ router.get("/config/:key", async (req, res) => {
|
||||
}
|
||||
const allowKeys = ["resources", "cluster", "nodes"];
|
||||
if (allowKeys.includes(params.key)) {
|
||||
const config = db.getUser(req.cookies.username);
|
||||
const config = global.db.getUser(req.cookies.username);
|
||||
res.status(200).send(config[params.key]);
|
||||
}
|
||||
else {
|
||||
@@ -64,9 +61,9 @@ router.get("/iso", async (req, res) => {
|
||||
return;
|
||||
}
|
||||
// get user iso config
|
||||
const userIsoConfig = db.getGlobal().useriso;
|
||||
const userIsoConfig = global.config.useriso;
|
||||
// get all isos
|
||||
const isos = (await requestPVE(`/nodes/${userIsoConfig.node}/storage/${userIsoConfig.storage}/content?content=iso`, "GET", { token: pveAPIToken })).data.data;
|
||||
const isos = (await global.pve.requestPVE(`/nodes/${userIsoConfig.node}/storage/${userIsoConfig.storage}/content?content=iso`, "GET", { token: true })).data.data;
|
||||
const userIsos = [];
|
||||
isos.forEach((iso) => {
|
||||
iso.name = iso.volid.replace(`${userIsoConfig.storage}:iso/`, "");
|
||||
|
||||
Reference in New Issue
Block a user