Implement plugin loading in web interface

Add loading of plugin info to the web interface via webpack Module
Federation.
This commit is contained in:
Hornwitser committed 2020-10-27 18:24:45 +01:00
1 parent 542d8a798f
commit 6dbf29153e
25 files changed
+360 -102

No files matched your search

+15
View File
@@ -201,6 +201,16 @@ function validateSlaveToken(req, res, next) {
next();
}
app.get("/api/plugins", (req, res) => {
let plugins = [];
for (let pluginInfo of pluginInfos) {
let name = pluginInfo.name;
let enabled = masterPlugins.has(name) && masterConfig.group(name).get("enabled");
plugins.push({ name, enabled });
}
res.send(plugins);
});
// Handle an uploaded export package.
async function uploadExport(req, res, next) {
endpointHitCounter.labels(req.route.path).inc();
@@ -1744,6 +1754,11 @@ async function startServer() {
for (let route of pluginInfo.routes || []) {
app.get(route, serveWeb(route));
}
let pluginPackagePath = require.resolve(path.posix.join(pluginInfo.requirePath, "package.json"));
let staticPath = path.join(path.dirname(pluginPackagePath), "static");
console.log(`/plugin/${pluginInfo.name}`, staticPath);
app.use(`/plugin/${pluginInfo.name}`, express.static(staticPath));
}
// Load plugins