mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
removed endpoint
This commit is contained in:
parent
038f75e48f
commit
ba9ddefbee
@ -1,33 +0,0 @@
|
||||
// Dynamic loading support for editor libraries
|
||||
|
||||
var apiUtils = require("../util");
|
||||
var fs = require("fs");
|
||||
var path = require("path");
|
||||
|
||||
var lib2path = {
|
||||
"mermaid": "../../../editor-client/public/vendor/mermaid/mermaid.min.js",
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
init: function(_settings, _runtimeAPI) {
|
||||
settings = _settings;
|
||||
},
|
||||
|
||||
get: function(req,res) {
|
||||
var name = req.params.name;
|
||||
|
||||
if (name in lib2path) {
|
||||
try {
|
||||
var lib = path.join(__dirname, lib2path[name]);
|
||||
var code = fs.readFileSync(lib);
|
||||
res.send(code);
|
||||
}
|
||||
catch (e) {
|
||||
res.status(500).json({code: "runtime_error", message: e.toString()});
|
||||
}
|
||||
}
|
||||
else {
|
||||
res.status(400).json({code: "invalid_request", message: `no library: ${name}`});
|
||||
}
|
||||
},
|
||||
}
|
@ -116,11 +116,6 @@ module.exports = {
|
||||
// SSH keys
|
||||
editorApp.use("/settings/user/keys",needsPermission("settings.write"),info.sshkeys());
|
||||
|
||||
// Editor Libraries
|
||||
var editorLibs = require("./editor-libs");
|
||||
editorLibs.init(settings, runtimeAPI);
|
||||
editorApp.get("/editor-libs/:name", needsPermission("editor-libs.read"), editorLibs.get, apiUtil.errorHandler);
|
||||
|
||||
return editorApp;
|
||||
}
|
||||
},
|
||||
|
@ -18,7 +18,7 @@ var mermaid = (function () {
|
||||
}
|
||||
if (enabled) {
|
||||
initializing = true;
|
||||
$.getScript("/editor-libs/mermaid",
|
||||
$.getScript("vendor/mermaid/mermaid.min.js",
|
||||
function (data, stat, jqxhr) {
|
||||
$(".mermaid").show();
|
||||
// invoke loaded mermaid API
|
||||
|
@ -1,49 +0,0 @@
|
||||
const should = require("should");
|
||||
const request = require('supertest');
|
||||
const express = require('express');
|
||||
const bodyParser = require("body-parser");
|
||||
const sinon = require('sinon');
|
||||
|
||||
let app;
|
||||
|
||||
const NR_TEST_UTILS = require("nr-test-utils");
|
||||
const editorLibs = NR_TEST_UTILS.require("@node-red/editor-api/lib/editor/editor-libs");
|
||||
|
||||
describe("api/editor/editor-libs", function() {
|
||||
before(function() {
|
||||
app = express();
|
||||
app.use(bodyParser.json());
|
||||
app.get("/editor-libs/:name", editorLibs.get);
|
||||
});
|
||||
|
||||
it("returns the editor library for mermaid", function(done) {
|
||||
const settings = {};
|
||||
const runtimeAPI = {};
|
||||
|
||||
editorLibs.init(settings, runtimeAPI);
|
||||
|
||||
request(app)
|
||||
.get("/editor-libs/mermaid")
|
||||
.expect(200)
|
||||
.end(function(err,res) {
|
||||
if (err || (typeof res.error === "object")) {
|
||||
return done(err || res.error);
|
||||
}
|
||||
res.should.have.property("statusCode",200);
|
||||
res.should.have.property("_body");
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should error when called with unknown library', function(done) {
|
||||
const settings = {};
|
||||
const runtimeAPI = {};
|
||||
|
||||
editorLibs.init(settings, runtimeAPI);
|
||||
|
||||
request(app)
|
||||
.get("/editor-libs/unknown")
|
||||
.expect(400)
|
||||
.end(done);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user