1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Removed plugins references

This commit is contained in:
Anna Thomas 2014-11-21 11:31:07 +00:00
parent 70f101497d
commit 4c9d53388c
4 changed files with 5 additions and 120 deletions

View File

@ -19,7 +19,6 @@ var util = require('util');
var ui = require("./ui"); var ui = require("./ui");
var nodes = require("./nodes"); var nodes = require("./nodes");
var plugins = require("./plugins");
var flows = require("./flows"); var flows = require("./flows");
var library = require("./library"); var library = require("./library");
@ -59,16 +58,11 @@ function init(adminApp) {
adminApp.get("/nodes/:mod/:set",nodes.getSet); adminApp.get("/nodes/:mod/:set",nodes.getSet);
adminApp.put("/nodes/:mod/:set",nodes.putSet); adminApp.put("/nodes/:mod/:set",nodes.putSet);
// Plugins
adminApp.get("/plugins",plugins.getAll);
adminApp.get("/plugins/:id",plugins.get);
// Library // Library
adminApp.post(new RegExp("/library/flows\/(.*)"),library.post); adminApp.post(new RegExp("/library/flows\/(.*)"),library.post);
adminApp.get("/library/flows",library.getAll); adminApp.get("/library/flows",library.getAll);
adminApp.get(new RegExp("/library/flows\/(.*)"),library.get); adminApp.get(new RegExp("/library/flows\/(.*)"),library.get);
// Error Handler // Error Handler
adminApp.use(errorHandler); adminApp.use(errorHandler);
} }

View File

@ -1,32 +0,0 @@
/**
* Copyright 2014 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
var redNodes = require("../nodes");
module.exports = {
getAll: function(req,res) {
res.json(redNodes.getModuleList());
},
get: function(req,res) {
var id = req.params.id;
var result = redNodes.getModuleInfo(id);
if (result) {
res.send(result);
} else {
res.send(404);
}
}
};

View File

@ -1,77 +0,0 @@
/**
* Copyright 2014 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
var should = require("should");
var request = require('supertest');
var express = require('express');
var sinon = require('sinon');
var when = require('when');
var app = express();
var redNodes = require("../../../red/nodes");
var server = require("../../../red/server");
var settings = require("../../../red/settings");
var plugins = require("../../../red/api/plugins");
describe("plugins api", function() {
var app;
before(function() {
app = express();
app.use(express.json());
app.get("/plugins",plugins.getAll);
app.get("/plugins/:id",plugins.get);
});
describe('get plugins', function() {
it('returns plugins list', function(done) {
var getPluginList = sinon.stub(redNodes,'getModuleList', function() {
return [1,2,3];
});
request(app)
.get('/plugins')
.expect(200)
.end(function(err,res) {
getPluginList.restore();
if (err) {
throw err;
}
res.body.should.be.an.Array.and.have.lengthOf(3);
done();
});
});
it('returns an individual plugin info', function(done) {
var getPluginInfo = sinon.stub(redNodes,'getModuleInfo', function(id) {
return {"name":"123", "nodes":[1,2,3]};
});
request(app)
.get('/plugins/123')
.expect(200)
.end(function(err,res) {
getPluginInfo.restore();
if (err) {
throw err;
}
res.body.should.have.property("name","123");
res.body.should.have.property("nodes",[1,2,3]);
done();
});
});
});
});

View File

@ -402,7 +402,7 @@ describe('NodeRegistry', function() {
}); });
it('returns plugins list', function(done) { it('returns modules list', function(done) {
var fs = require("fs"); var fs = require("fs");
var path = require("path"); var path = require("path");
@ -454,7 +454,7 @@ describe('NodeRegistry', function() {
}); });
}); });
it('returns plugin info', function(done) { it('returns module info', function(done) {
var fs = require("fs"); var fs = require("fs");
var path = require("path"); var path = require("path");
@ -489,9 +489,9 @@ describe('NodeRegistry', function() {
typeRegistry.addModule("TestNodeModule").then(function(nodes) { typeRegistry.addModule("TestNodeModule").then(function(nodes) {
var list = typeRegistry.getModuleList(); var list = typeRegistry.getModuleList();
var plugin = typeRegistry.getModuleInfo(list[0].name); var module = typeRegistry.getModuleInfo(list[0].name);
plugin.should.have.property("name", list[0].name); module.should.have.property("name", list[0].name);
plugin.should.have.property("nodes", nodes); module.should.have.property("nodes", nodes);
done(); done();
}).catch(function(e) { }).catch(function(e) {
done(e); done(e);